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(nats-connection): implement named executor thread factories #1254

Merged
merged 4 commits into from
Nov 26, 2024

Conversation

krzysiekigry
Copy link
Contributor

goodbye, "pool-2-thread-1"

@scottf
Copy link
Contributor

scottf commented Nov 21, 2024

@krzysiekigry So the idea is fine, but it needs to be done in an optional way, since someone might currently rely on that naming scheme in their existing application / logs.

In the Options Builder, you can call public Builder executor(ExecutorService executor), so maybe add these:

public Builder callbackExecutor(ExecutorService executor) 
public Builder connectExecutor(ExecutorService executor) 

With the defaults matching exactly the existing i.e. newSingleThreadExecutor()

And so starting at line 159 of NatsConnection, that block of code would look like this:

this.executor = options.getExecutor();
this.callbackRunner = options.getCallbackExecutor();
this.connectExecutor = options.getConnectExecutor();

Also, please sign your commits. Here is a good link to help with that: https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits

@krzysiekigry
Copy link
Contributor Author

krzysiekigry commented Nov 25, 2024

Thanks for the suggestion, but I believe this approach works better. When NatsConnection shuts down, it terminates the executors. This can cause issues when attempting to create a new NatsConnection, as the executors would already be shut down. Please let me know if I’m mistaken.

@scottf
Copy link
Contributor

scottf commented Nov 25, 2024

Factory is a good idea.

@scottf scottf merged commit a76dd02 into nats-io:main Nov 26, 2024
1 check passed
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.

2 participants