Skip to content

Commit

Permalink
Close stream in hranaV2Conn.Close
Browse files Browse the repository at this point in the history
Signed-off-by: Piotr Jastrzebski <[email protected]>
  • Loading branch information
haaawk committed Nov 15, 2023
1 parent da03110 commit 8156737
Showing 1 changed file with 7 additions and 17 deletions.
24 changes: 7 additions & 17 deletions libsql/internal/http/hranaV2/hranaV2.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,13 @@ func (h *hranaV2Conn) PrepareContext(ctx context.Context, query string) (driver.
}

func (h *hranaV2Conn) Close() error {
if h.baton != "" {
go func(baton, url, jwt, host string) {
msg := hrana.PipelineRequest{Baton: baton}
msg.Add(hrana.CloseStream())
_, _, _ = sendPipelineRequest(context.Background(), &msg, url, jwt, host)
}(h.baton, h.url, h.jwt, h.host)
}
return nil
}

Expand Down Expand Up @@ -378,23 +385,6 @@ func (h *hranaV2Conn) QueryContext(ctx context.Context, query string, args []dri
}
}

func (h *hranaV2Conn) closeStream(ctx context.Context) error {
msg := &hrana.PipelineRequest{}
msg.Add(hrana.CloseStream())
result, err := h.sendPipelineRequest(ctx, msg, true)
if err != nil {
return fmt.Errorf("failed to close stream: %w", err)
}

if result.Results[0].Error != nil {
return fmt.Errorf("failed to close stream: %s", result.Results[0].Error.Message)
}
if result.Results[0].Response == nil {
return errors.New("failed to close stream: no response received")
}
return nil
}

func (h *hranaV2Conn) ResetSession(ctx context.Context) error {
if h.baton != "" {
go func(baton, url, jwt, host string) {
Expand Down

0 comments on commit 8156737

Please sign in to comment.