Skip to content
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

feat(client): blocking LineSenderPool #53

Merged
merged 10 commits into from
Aug 14, 2024
Merged

Conversation

puzpuzpuz
Copy link
Collaborator

@puzpuzpuz puzpuzpuz commented Aug 12, 2024

Breaking change of an experimental API

The pool now blocks if there are already too many senders in use. Pooled senders are released implicitly, via the Close call.

	sender, err := pool.Sender(ctx)
	if err != nil {
		panic(err)
	}

	// ...

	// Close call returns the sender back to the pool
	if err := sender.Close(ctx); err != nil {
		panic(err)
	}

@puzpuzpuz puzpuzpuz added the enhancement New feature or request label Aug 12, 2024
@puzpuzpuz puzpuzpuz self-assigned this Aug 12, 2024
@puzpuzpuz
Copy link
Collaborator Author

@sklarsa I tried making the pool behave similarly to the "traditional" connection pools, i.e. you obtain a connection (sender in our case) with a call to the pool and then close the connection when you're done. Now it also blocks if there is already the maximum number of pooled senders. WDYT?

sender_pool.go Outdated Show resolved Hide resolved
sender_pool.go Outdated Show resolved Hide resolved
sender_pool.go Show resolved Hide resolved
sender_pool.go Outdated Show resolved Hide resolved
sender_pool.go Outdated Show resolved Hide resolved
sender_pool.go Show resolved Hide resolved
@sklarsa
Copy link
Contributor

sklarsa commented Aug 12, 2024

@sklarsa I tried making the pool behave similarly to the "traditional" connection pools, i.e. you obtain a connection (sender in our case) with a call to the pool and then close the connection when you're done. Now it also blocks if there is already the maximum number of pooled senders. WDYT?

This is very cool! Definitely more along the lines of how I originally envisioned the pool concept.

@puzpuzpuz puzpuzpuz marked this pull request as ready for review August 13, 2024 13:24
@puzpuzpuz puzpuzpuz requested a review from sklarsa August 13, 2024 13:33
sender.go Show resolved Hide resolved
sender_pool.go Show resolved Hide resolved
sender_pool_test.go Outdated Show resolved Hide resolved
sender_pool_test.go Outdated Show resolved Hide resolved
@puzpuzpuz
Copy link
Collaborator Author

@sklarsa thanks for the comprehensive review!

@puzpuzpuz puzpuzpuz merged commit 9c27421 into main Aug 14, 2024
3 checks passed
@puzpuzpuz puzpuzpuz deleted the puzpuzpuz_blocking_pool branch August 14, 2024 14:26
@sklarsa sklarsa mentioned this pull request Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants