tursodatabase / libsql-client-go

Go client API for libSQL
MIT License
180 stars 24 forks source link

Pass ctx down to http calls #15

Closed avinassh closed 1 year ago

avinassh commented 1 year ago

Though the ExecContext and QueryContext take ctx parameter, they were not using them. This PR, makes these methods to pass them to callSqld method, which can be used in http calls.

E.g. if a user wants to cancel the operation if it isn't completed in under 1 second, the code would be:

ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()
res, err := db.QueryContext(ctx, stmt, args...)