-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.go
47 lines (39 loc) · 1.13 KB
/
client.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package elasticsteps
import (
"context"
"encoding/json"
)
// Client is an interface for interacting with Elasticsearch.
type Client interface {
IndexGetter
IndexCreator
IndexDeleter
DocumentFinder
DocumentIndexer
DocumentDeleter
}
// IndexGetter gets index.
type IndexGetter interface {
GetIndex(ctx context.Context, index string) (json.RawMessage, error)
}
// IndexCreator creates indices.
type IndexCreator interface {
CreateIndex(ctx context.Context, index string, config *string) error
RecreateIndex(ctx context.Context, index string, config *string) error
}
// IndexDeleter deletes indices.
type IndexDeleter interface {
DeleteIndex(ctx context.Context, indices ...string) error
}
// DocumentIndexer indexes documents.
type DocumentIndexer interface {
IndexDocuments(ctx context.Context, index string, documents ...Document) error
}
// DocumentFinder gets documents.
type DocumentFinder interface {
FindDocuments(ctx context.Context, index string, query *string) ([]json.RawMessage, error)
}
// DocumentDeleter deletes documents.
type DocumentDeleter interface {
DeleteAllDocuments(ctx context.Context, index string) error
}