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

Improving Options with better construction via properties #946

Merged
merged 9 commits into from Jul 24, 2023

Conversation

scottf
Copy link
Contributor

@scottf scottf commented Jul 23, 2023

  • Allow creation of connections requiring an AuthHandler for JWT to specify the credentials file in a properties files, instead of needing to provide an instance of AuthHandler in code.
  • Allow creation of connections requiring an SSL context to specify key and trust store information in a properties files so an SSLContext can be created automatically instead of needing to provide an instance of an SSLContext in code.
  • Support properties keys with or without the prefix 'io.nats.client.'
Property Description
credential.path Used to set the path to a credentials file to be used in a FileAuthHandler
keyStore Property for the keystore path used to create an SSLContext
trustStore Property for the truststore path used to create an SSLContext
keyStorePassword Property for the keystore password used to create an SSLContext
trustStorePassword Property for the truststore password used to create an SSLContext
tls.algorithm Property for the algorithm used to create an SSLContext

@scottf scottf marked this pull request as draft July 23, 2023 15:27
@scottf scottf marked this pull request as ready for review July 24, 2023 14:26
@scottf scottf changed the title Improving options to allow creation of TLS and JWT based connection via properties file Improving Options with better construction via properties Jul 24, 2023
@ColinSullivan1
Copy link
Member

Looks good, really like the per-connection properties here. A minor suggestion would be the ability to build the with options and override. E.g. to set the props file in the builder via method and also be able to set a name, reconnect tries, etc. Best of both worlds.

Copy link
Contributor

@RichardHightower RichardHightower left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Docs added to the readme would be swell. :)

@scottf
Copy link
Contributor Author

scottf commented Jul 24, 2023

A minor suggestion would be the ability to build the with options and override.

I've added a builder setter to take properties. When it comes to the builder, the last one called wins.

// last one wins
props.setProperty(Options.PROP_MAX_MESSAGES_IN_OUTGOING_QUEUE, "500");
o = new Options.Builder(props)
    .maxMessagesInOutgoingQueue(1000)
    .build();
assertEquals(1000, o.getMaxMessagesInOutgoingQueue());

o = new Options.Builder()
    .maxMessagesInOutgoingQueue(1000)
    .properties(props)
    .build();
assertEquals(500, o.getMaxMessagesInOutgoingQueue());

@scottf scottf merged commit 97c4bc2 into main Jul 24, 2023
2 checks passed
@scottf scottf deleted the options-improvement-properties-handling branch July 24, 2023 19:25
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.

None yet

3 participants