Skip to content

Commit

Permalink
Close streams asynchronously in ResetSession
Browse files Browse the repository at this point in the history
This is a temporary workaround for the server not supporting
closing and opening a stream in a single pipeline request.

Once tursodatabase/libsql#621
is merged and deployed to all databases we can revert this commit.

Signed-off-by: Piotr Jastrzebski <piotr@chiselstrike.com>
  • Loading branch information
haaawk committed Nov 15, 2023
1 parent eb095ba commit da03110
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions libsql/internal/http/hranaV2/hranaV2.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,12 @@ func (h *hranaV2Conn) closeStream(ctx context.Context) error {

func (h *hranaV2Conn) ResetSession(ctx context.Context) error {
if h.baton != "" {
err := h.closeStream(ctx)
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)
h.baton = ""
return err
}
return nil
}

0 comments on commit da03110

Please sign in to comment.