elasticstream/source/elastic/teardown.go

29 lines
401 B
Go
Raw Normal View History

2024-10-07 15:25:13 +05:30
package elastic
import (
"context"
2024-10-07 16:49:36 +05:30
"fmt"
2024-10-07 22:41:59 +05:30
"log"
2024-10-07 15:25:13 +05:30
)
// close the client
2024-10-07 16:26:41 +05:30
func (c *Client) Teardown(ctx context.Context) error {
2024-10-07 22:41:59 +05:30
log.Println(">>>> elastic.Teardown()")
defer log.Println("<<<< elastic.Teardown()")
2024-10-07 16:49:36 +05:30
if c == nil || c.ch == nil {
return fmt.Errorf("error source not opened for reading")
}
2024-10-07 22:41:59 +05:30
close(c.shutdown)
c.wg.Wait()
close(c.ch)
c.ch = nil
// c.es.Close()
2024-10-07 15:25:13 +05:30
return nil
}