-
Notifications
You must be signed in to change notification settings - Fork 59
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
Proposal to change driver interface to context #48
Comments
There is couple of questions:
|
|
And please describe, why do you think using Context may help to eliminate DeadlineIO structure? DeadlineIO is for handling networking and tarantool outage, it is not for request timeout. |
Context could be add to Future with some kind of api, and Future.wait may select for both Even this simple steps are already not free. Adding context field will increase size of structure, and it will use next allocation size (now it fits into 64byte allocation, after addition it will be 96 byte allocation). And But this way there will be no huge change in internal structures. Is it acceptable solution? |
With context you just changed the way to implement timeout. Golang "select" from several channel is pretty fast, and I can not imagine how it can slow the driver
Ah, yes, of course.
Because context is direct solution for all kind of timeout, does not matter network or not.
It is known and expected issue. Golang net/http server uses several different timeout for that (in addition to user context.
Typical application does NOT use a lot of connection. Typically amount of connection is about several tenners.
I am not too familiar with tarantool golang driver code. I think you will make better decision ,than I. So, to summarize, why context is usefull and has liked by users... Please take a look more attentive to context API: you have four capability:
|
You can not. I can. Golang "select" from several channel's is slow. Look at timeout implementation in this code. I doubt there is way to make it faster. (But it leads to restriction that all requests through single connection uses same timeout).
Got for Dial . Now show me for Write and Read.
go-tarantool connector uses single connection for single tarantool instance. It uses pipe-lining to achieve 1Mrps using single connection and 4 cores.
go-tarantool uses single connection, so there is no need to cancel connection establishing. And there is no way to cancel long-running query at all in tarantool. Single trouble I see is Future.wait() is not composable with select. It is easy to achieve by exposing Future.ready channel. Then you can combine it with waiting on context.Done().
As I already said, to achieve performance there is no per-request timeout in this driver. So I cannot use ctx for timeout cancelling. And still, current timeout code just fill Future with error. There is no way to inform Tarantool to cancel the query.
Slides are great. But you should first force Tarantool to implement this concept. Then it will be possible to use it in driver. But now there is no way to cancel query that is already sent to Tarantool. And no way set deadline for request (if I didn't miss some changes in protocol).
If it doesn't matter for this ticket, why you mentioned it? Look, man. You are writing in a way I'm dumb man who doesn't know anything about Context. I'm aware about Context and about it greatness. The best I can do at the moment it is solution I suggest in my previous message. All other dreams could not be implemented without loss in performance. |
and it cancels future on context close. fixes #48
@excavador , could you look at e11b662 , please? |
Typically context passes to every call, because in working with a database connection you require different timeouts for different operation (one for write, another for read), or different timeouts for different reads (for instance) If you need global cancel you may create a single context for that, then create children timeot contexts for every specific operation (instead of single context for whole connection) Just my 2 cents based on 2+ years experience of golang development |
That is why there is fluent method resp, err = conn.WithCtx(context).Select(...)
resp, err = conn.WithCtx(context).Insert(...) Isn't such fluent method enough? |
jfyi, currently it is a bad idea to mix requests with radically different timeouts in a single connection to Tarantool (regardless of connector). |
Please, I also have a huge Ego. Lets play without it, ok? |
any update? |
Not yet. There are a lot of changes. |
I want to stop fork hell and offer both speed and convenience (or at least a choice) for users. My plan is the following:
Corrections and suggestions are welcome. (No huge Ego and, to be honest, I'm new in Go.) |
This patch adds the support of using context in API. The proposed API is based on using request objects. Added tests that cover almost all cases of using the context in a query. Added benchamrk tests are equivalent to other, that use the same query but without any context. Closes #48
This patch adds the support of using context in API. The proposed API is based on using request objects. Added tests that cover almost all cases of using the context in a query. Added benchamrk tests are equivalent to other, that use the same query but without any context. Closes #48
This patch adds the support of using context in API. The proposed API is based on using request objects. Added tests that cover almost all cases of using the context in a query. Added benchamrk tests are equivalent to other, that use the same query but without any context. Closes #48
This patch adds the support of using context in API. The proposed API is based on using request objects. Added tests that cover almost all cases of using the context in a query. Added benchamrk tests are equivalent to other, that use the same query but without any context. Closes #48
This patch adds the support of using context in API. The proposed API is based on using request objects. Added tests that cover almost all cases of using the context in a query. Added benchamrk tests are equivalent to other, that use the same query but without any context. Closes #48
This patch adds the support of using context in API. The proposed API is based on using request objects. Added tests that cover almost all cases of using the context in a query. Added benchamrk tests are equivalent to other, that use the same query but without any context. Closes #48
This patch adds the support of using context in API. The proposed API is based on using request objects. Added tests that cover almost all cases of using the context in a query. Added benchamrk tests are equivalent to other, that use the same query but without any context. Closes #48
This patch adds the support of using context in API. The proposed API is based on using request objects. Added tests that cover almost all cases of using the context in a query. Added benchamrk tests are equivalent to other, that use the same query but without any context. Closes #48
This patch adds the support of using context in API. The proposed API is based on using request objects. Added tests that cover almost all cases of using the context in a query. Added benchamrk tests are equivalent to other, that use the same query but without any context. Closes #48
This patch adds the support of using context in API. The proposed API is based on using request objects. Added tests that cover almost all cases of using the context in a query. Added benchamrk tests are equivalent to other, that use the same query but without any context. Closes #48
This patch adds the support of using context in API. The proposed API is based on using request objects. Added tests that cover almost all cases of using the context in a query. Added benchamrk tests are equivalent to other, that use the same query but without any context. Closes #48
This patch adds the support of using context in API. The proposed API is based on using request objects. Added tests that cover almost all cases of using the context in a query. Added benchamrk tests are equivalent to other, that use the same query but without any context. Closes #48
This patch adds the support of using context in API. The proposed API is based on using request objects. Added tests that cover almost all cases of using the context in a query. Added benchamrk tests are equivalent to other, that use the same query but without any context. Closes #48
This patch adds the support of using context in API. The proposed API is based on using request objects. Added tests that cover almost all cases of using the context in a query. Added benchamrk tests are equivalent to other, that use the same query but without any context. Closes #48
This patch adds the support of using context in API. The proposed API is based on using request objects. Added tests that cover almost all cases of using the context in a query. Added benchamrk tests are equivalent to other, that use the same query but without any context. Closes #48
This patch adds the support of using context in API. The proposed API is based on using request objects. Added tests that cover almost all cases of using the context in a query. Added benchamrk tests are equivalent to other, that use the same query but without any context. Closes #48
This patch adds the support of using context in API. The API is based on using request objects. Added tests that cover almost all cases of using the context in a query. Added benchamrk tests are equivalent to other, that use the same query but without any context. Closes #48
This patch adds the support of using context in API. The API is based on using request objects. Added tests that cover almost all cases of using the context in a query. Added benchamrk tests are equivalent to other, that use the same query but without any context. Closes #48
This patch adds the support of using context in API. The API is based on using request objects. Added tests that cover almost all cases of using the context in a query. Added benchamrk tests are equivalent to other, that use the same query but without any context. Closes #48
This patch adds the support of using context in API. The API is based on using request objects. Added tests that cover almost all cases of using the context in a query. Added benchamrk tests are equivalent to other, that use the same query but without any context. Closes #48
This patch adds the support of using context in API. The API is based on using request objects. Added tests that cover almost all cases of using the context in a query. Added benchamrk tests are equivalent to other, that use the same query but without any context. Closes #48
This patch adds the support of using context in API. The API is based on using request objects. Added tests that cover almost all cases of using the context in a query. Added benchamrk tests are equivalent to other, that use the same query but without any context. Closes #48
This patch adds the support of using context in API. The API is based on using request objects. Added tests that cover almost all cases of using the context in a query. Added benchamrk tests are equivalent to other, that use the same query but without any context. Closes #48
Add context, streams, SQL and push messages support in Go connector Follows up tarantool/go-tarantool#48 Follows up tarantool/go-tarantool#62 Follows up tarantool/go-tarantool#67 Follows up tarantool/go-tarantool#101
Add context, streams, SQL and push messages support in Go connector Follows up tarantool/go-tarantool#48 Follows up tarantool/go-tarantool#62 Follows up tarantool/go-tarantool#67 Follows up tarantool/go-tarantool#101
Overview This release adds a number of features. The extending of the public API has become possible with a new way of creating requests. New types of requests are created via chain calls: selectReq := NewSelectRequest("space"). Context(ctx). Index(1). Offset(5). Limit(10) future := conn.Do(selectReq) Streams, context and prepared statements support are based on this idea: stream, err := conn.NewStream() beginReq := NewBeginRequest().Context(ctx) if response, err := stream.Do(beginReq).Get(); err != nil { selectFuture := stream.Do(selectReq) commitFuture := stream.Do(NewCommitRequest()) // ... } ``` Breaking changes NewErrorFuture function removed (#190). `IPROTO_*` constants that identify requests renamed from `<Name>Request` to `<Name>RequestCode` (#126) New features SSL support (#155). IPROTO_PUSH messages support (#67). Public API with request object types (#126). Support decimal type in msgpack (#96). Support datetime type in msgpack (#118). Prepared SQL statements (#117). Context support for request objects (#48). Streams and interactive transactions support (#101). `Call16` method, support build tag `go_tarantool_call_17` to choose default behavior for `Call` method as Call17 (#125) Bugfixes Add `ExecuteAsync` and `ExecuteTyped` to common connector interface (#62).
Overview This release adds a number of features. The extending of the public API has become possible with a new way of creating requests. New types of requests are created via chain calls: selectReq := NewSelectRequest("space"). Context(ctx). Index(1). Offset(5). Limit(10) future := conn.Do(selectReq) Streams, context and prepared statements support are based on this idea: stream, err := conn.NewStream() beginReq := NewBeginRequest().Context(ctx) if response, err := stream.Do(beginReq).Get(); err != nil { selectFuture := stream.Do(selectReq) commitFuture := stream.Do(NewCommitRequest()) // ... } ``` Breaking changes NewErrorFuture function removed (#190). `IPROTO_*` constants that identify requests renamed from `<Name>Request` to `<Name>RequestCode` (#126) New features SSL support (#155). IPROTO_PUSH messages support (#67). Public API with request object types (#126). Support decimal type in msgpack (#96). Support datetime type in msgpack (#118). Prepared SQL statements (#117). Context support for request objects (#48). Streams and interactive transactions support (#101). `Call16` method, support build tag `go_tarantool_call_17` to choose default behavior for `Call` method as Call17 (#125) Bugfixes Add `ExecuteAsync` and `ExecuteTyped` to common connector interface (#62).
Overview This release adds a number of features. The extending of the public API has become possible with a new way of creating requests. New types of requests are created via chain calls: selectReq := NewSelectRequest("space"). Context(ctx). Index(1). Offset(5). Limit(10) future := conn.Do(selectReq) Streams, context and prepared statements support are based on this idea: stream, err := conn.NewStream() beginReq := NewBeginRequest().Context(ctx) if response, err := stream.Do(beginReq).Get(); err != nil { selectFuture := stream.Do(selectReq) commitFuture := stream.Do(NewCommitRequest()) // ... } ``` Breaking changes NewErrorFuture function removed (#190). `IPROTO_*` constants that identify requests renamed from `<Name>Request` to `<Name>RequestCode` (#126) New features SSL support (#155). IPROTO_PUSH messages support (#67). Public API with request object types (#126). Support decimal type in msgpack (#96). Support datetime type in msgpack (#118). Prepared SQL statements (#117). Context support for request objects (#48). Streams and interactive transactions support (#101). `Call16` method, support build tag `go_tarantool_call_17` to choose default behavior for `Call` method as Call17 (#125) Bugfixes Add `ExecuteAsync` and `ExecuteTyped` to common connector interface (#62).
The patch adds context, streams, SQL, push messages and master discovery support for connection pool to go-tarantool. It also updates GitHub starts for Go connectors. Follows up tarantool/go-tarantool#48 Follows up tarantool/go-tarantool#62 Follows up tarantool/go-tarantool#67 Follows up tarantool/go-tarantool#101 Follows up tarantool/go-tarantool#113
Resolves #3094 The patch adds context, streams, SQL, push messages and master discovery support for connection pool to go-tarantool. It also updates GitHub starts for Go connectors. Follows up tarantool/go-tarantool#48 Follows up tarantool/go-tarantool#62 Follows up tarantool/go-tarantool#67 Follows up tarantool/go-tarantool#101 Follows up tarantool/go-tarantool#113
Golang has standard library named "context"
https://golang.org/pkg/context/
This library widely used in golang libraries to implement
Please read about context and how it used.
Golang standard libraries does not use context directly only because keep compatibility of API since golang 1.0.
But in some libraries you can find usage of context, for instance here:
https://golang.org/pkg/database/sql/#Conn.QueryContext
I propose to get rid of DeadlineIO struct and rewrite driver API to context usage.
It's more explicit and more golang-way, than actual implementation
The text was updated successfully, but these errors were encountered: