8000 [FEATURE] adds InitChan() to create a chan generator by nlepage · Pull Request #7 · nrednav/cuid2 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[FEATURE] adds InitChan() to create a chan generator #7

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
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nlepage
Copy link
@nlepage nlepage commented Mar 20, 2025

Hi @nrednav

I was having a look at your port, and saw the use of sync/atomic for the session counter.
I figured this could be a bottleneck for use cases where a lot of Cuids need to be generated by several goroutines.

The proposition is to add an InitChan() func which returns a channel from which cuids can be received.
The buffer size of the channel can be configured, and defaults to 10.
InitChan() also returns a cancel function, which stops the generation of new Cuids.
A specific Context can also be configured (e.g. an HTTP request Context), which will stop the generation as soon as the Context is done.

What do you think?
Feel free to make the changes you want to or tell me what changes would be necessary to merge this.

Cheers!

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

Successfully merging this pull request may close these issues.

1 participant
0