-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/receive server query #70
Conversation
* Implement elapsed time in query progress * add debug
27915c3
to
0980329
Compare
I merged proton PR to encode server node id into query UUID in https://github.com/timeplus-io/proton-enterprise/pull/5460 This golang driver PR is to receive the server generated query ID and return it to the caller. In order to use the query id (eg. kill query/get pipeline in cluster), caller need provide callback function in QueryOption as below. Please help to review the PR. func WithReceiveQueryID(fn func(string)) QueryOption {
return func(o *QueryOptions) error {
o.events.receiveQueryID = fn
return nil
}
} Also refer to ut code. |
@yuzifeng1984 I'm purely speaking from the user side (the user of proton-go-driver): ctx = proton.Context(context.Background())
conn, err = proton.Open(...)
serverGenearatedID, _, err := conn.Query(ctx, "SELECT 123") For the |
@ye11ow The unit test case is just for testing purpose. In real case, user could either give an ID or leave it unset to allow server generate one with the node id in sending query.
|
@yuzifeng1984 I see. idCh = make(chan string, 1)
ctx = proton.Context(context.Background(), proton.WithReceiveQueryID(func(id string) {
idCh <- id
close(idCh)
}))
conn, _ = proton.Open(...)
_, err := conn.Query(ctx, "SELECT 123")
id := <-idCh
// do whatever with id I'd prefer ctx = proton.Context(context.Background())
conn, _ = proton.Open(...)
id, _, err := conn.Query(ctx, "SELECT 123")
// do whatever with id There are few issues with the current approach
|
@ye11ow Yes. the callback method is a little ugly. While changing Query method interface to return query id seems even worse, it will break every existing user code. Also, as the new signature is not consistent with golang std lib, a lot of under layer code need be changed. For the callback itself, it will be called synchronously before Query method return. There is some boilerplate code which you may not want to add in neutron. I am thinking if proton-go-driver to provide a new API to wrap these; such as |
@ye11ow I checked the neutron code. It looks the query is through the sql.DB in golang lib whose methods can not be changed. We have no choice than the WithReceiveQueryID approach to return the query ID. https://github.com/timeplus-io/neutron/blob/develop/internal/proton/driver.go#L19 |
@yuzifeng1984 You are right, I almost forgot this: we are using std golang SQL interface so you cannot really change the signature. Yeah, then we don't even have an option here. Have to go with the |
Is it safe to do following since string is immutable ? my gut feeling is either using ctx or callback for customization. Callback is more straight forward / explicit in my view
|
is it possible to mutate
|
@@ -0,0 +1,60 @@ | |||
// Licensed to ClickHouse, Inc. under one or more contributor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't think we need this ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is cherry picked from click house driver to support protocol 54459. since we bump the client protocol to 54461 for uuid.
@chenziliang @ye11ow |
This is much easier and totally makes sense to me |
Update protocol to support receiving query id from server