elasticstream/client.go

44 lines
722 B
Go

package elasticstream
import (
"github.com/elastic/go-elasticsearch/v8"
)
type Client struct {
es *elasticsearch.Client
config *Config
}
func NewClient() (*Client, error) {
es, err := elasticsearch.NewDefaultClient()
if err != nil {
return nil, err
}
return &Client{es: es}, nil
}
func (c *Client) Configure(config *Config) error {
c.config = config
return nil
}
func (c *Client) Open() error {
// create a buffer channel
ch := make(chan Data, 1)
for index, from := range c.config.Indexes {
NewWorker(c.es, index, from, c.config.BatchSize, ch)
}
return nil
}
func (c *Client) Read() (Data, error) {
return Data{}, nil
}
// close the client
func (c *Client) Teardown() error {
return nil
}