You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
783 B
Go
34 lines
783 B
Go
package index
|
|
|
|
//go:generate mockgen -destination=../index_mock/index_mock.go -package=index_mock . Index
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
const (
|
|
// Elastic is an Index backed by ES instance
|
|
Elastic = "elastic"
|
|
// Local is an Index backed by local FS instance
|
|
Local = "local"
|
|
)
|
|
|
|
// Index is the interface used to abstract communication
|
|
// with the persistence unit
|
|
type Index interface {
|
|
IndexResource(url string, time time.Time, body string, headers map[string]string) error
|
|
}
|
|
|
|
// NewIndex create a new index using given driver, destination
|
|
func NewIndex(driver string, dest string) (Index, error) {
|
|
switch driver {
|
|
case Elastic:
|
|
return newElasticIndex(dest)
|
|
case Local:
|
|
return newLocalIndex(dest)
|
|
default:
|
|
return nil, fmt.Errorf("no driver named %s found", driver)
|
|
}
|
|
}
|