Skip to content

Commit

Permalink
close conn
Browse files Browse the repository at this point in the history
  • Loading branch information
Kryvchun committed Dec 22, 2022
1 parent 97836c3 commit c359f6d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions sonic/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions sonic/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func (c *driversHolder) Ping() error {
if err != nil {
return err
}
defer d.close()

return d.Ping()
}
6 changes: 6 additions & 0 deletions sonic/ingester.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions sonic/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down

0 comments on commit c359f6d

Please sign in to comment.