Skip to content

Add CallAsync analogue without a context #62

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

Open
oleg-jukovec opened this issue Mar 29, 2025 · 4 comments
Open

Add CallAsync analogue without a context #62

oleg-jukovec opened this issue Mar 29, 2025 · 4 comments

Comments

@oleg-jukovec
Copy link

oleg-jukovec commented Mar 29, 2025

The context usage:

Context(ctx).

leads to creating a goroutine for each request. It's very expensive (especially in context.Background() case). A faster way is to rely on setting a timeout on the entire connection with tarantool.Opts.Timeout:

https://github.com/tarantool/go-tarantool/blob/c0a8ad307468471132652fb3829525b813762bc7/connection.go#L281-L292

So there is should be something like (need to think about naming):

func (rs *Replicaset) CallAsyncWithTimeout(opts ReplicasetCallOpts, fnc string, args interface{}) *tarantool.Future {

I would suggest adapting the request logic from the Go connector in the v3 library. This logic with FooAsync, FooTyped, FooWithContext, FooWithoutContextAsync it only seems simple, but in fact it is hard to maintain all this stuff.

@oleg-jukovec
Copy link
Author

oleg-jukovec commented Mar 29, 2025

Workaround is use nil as a context:

CallAsync(nil, opts, "foo", []any{})

But it is really very strange.

@nurzhan-saktaganov
Copy link
Collaborator

leads to creating a goroutine for each request.

@oleg-jukovec you mean go-tarantool creates a goroutine for request if there is a non-nil context?

@oleg-jukovec
Copy link
Author

oleg-jukovec commented Mar 30, 2025

@oleg-jukovec you mean go-tarantool creates a goroutine for request if there is a non-nil context?

Yes, I am.

@nurzhan-saktaganov
Copy link
Collaborator

Does using the Pooler() method solve your issue?

func (rs *Replicaset) Pooler() pool.Pooler {
return rs.conn
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants