From c359f6d17aa6990ac82d04f4c6b366111ca478f3 Mon Sep 17 00:00:00 2001 From: Kryvchun Date: Thu, 22 Dec 2022 20:53:07 +0200 Subject: [PATCH] close conn --- sonic/control.go | 1 + sonic/controller.go | 1 + sonic/ingester.go | 6 ++++++ sonic/search.go | 2 ++ 4 files changed, 10 insertions(+) diff --git a/sonic/control.go b/sonic/control.go index 596e437..a21ad35 100644 --- a/sonic/control.go +++ b/sonic/control.go @@ -58,6 +58,7 @@ func (c controlChannel) Trigger(action Action) (err error) { if err != nil { return err } + defer d.close() err = d.write(fmt.Sprintf("TRIGGER %s", action)) if err != nil { diff --git a/sonic/controller.go b/sonic/controller.go index 5071330..736602d 100644 --- a/sonic/controller.go +++ b/sonic/controller.go @@ -44,6 +44,7 @@ func (c *driversHolder) Ping() error { if err != nil { return err } + defer d.close() return d.Ping() } diff --git a/sonic/ingester.go b/sonic/ingester.go index dfaa280..9e9669b 100644 --- a/sonic/ingester.go +++ b/sonic/ingester.go @@ -106,6 +106,7 @@ func (i ingesterChannel) Push(collection, bucket, object, text string, lang Lang if err != nil { return err } + defer d.close() // patterns := []struct { @@ -210,6 +211,7 @@ func (i ingesterChannel) Pop(collection, bucket, object, text string) (err error if err != nil { return err } + defer d.close() err = d.write(fmt.Sprintf("%s %s %s %s \"%s\"", pop, collection, bucket, object, text)) if err != nil { @@ -265,6 +267,7 @@ func (i ingesterChannel) Count(collection, bucket, object string) (cnt int, err if err != nil { return 0, err } + defer d.close() err = d.write(fmt.Sprintf("%s %s %s", count, collection, buildCountQuery(bucket, object))) if err != nil { @@ -295,6 +298,7 @@ func (i ingesterChannel) FlushCollection(collection string) (err error) { if err != nil { return err } + defer d.close() err = d.write(fmt.Sprintf("%s %s", flushc, collection)) if err != nil { @@ -314,6 +318,7 @@ func (i ingesterChannel) FlushBucket(collection, bucket string) (err error) { if err != nil { return err } + defer d.close() err = d.write(fmt.Sprintf("%s %s %s", flushb, collection, bucket)) if err != nil { @@ -333,6 +338,7 @@ func (i ingesterChannel) FlushObject(collection, bucket, object string) (err err if err != nil { return err } + defer d.close() err = d.write(fmt.Sprintf("%s %s %s %s", flusho, collection, bucket, object)) if err != nil { diff --git a/sonic/search.go b/sonic/search.go index 4ea2a18..116b9ab 100644 --- a/sonic/search.go +++ b/sonic/search.go @@ -63,6 +63,7 @@ func (s searchChannel) Query(collection, bucket, term string, limit, offset int, if err != nil { return nil, err } + defer d.close() err = d.write(fmt.Sprintf("%s %s %s \"%s\" LIMIT(%d) OFFSET(%d)"+langFormat(lang), query, collection, bucket, term, limit, offset, lang)) if err != nil { @@ -88,6 +89,7 @@ func (s searchChannel) Suggest(collection, bucket, word string, limit int) (resu if err != nil { return nil, err } + defer d.close() err = d.write(fmt.Sprintf("%s %s %s \"%s\" LIMIT(%d)", suggest, collection, bucket, word, limit)) if err != nil {