package elasticstream import ( "github.com/elastic/go-elasticsearch/v8" ) type Client struct { es *elasticsearch.Client config *Config } func NewClient(config *Config) (*Client, error) { client := &Client{ config: config, } cfg := elasticsearch.Config{ Addresses: []string{ config.Host, }, } es, err := elasticsearch.NewClient(cfg) if err != nil { return nil, err } client.es = es return client, 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 }