Skip to content

Commit

Permalink
Executor and Executor Factories in Options can be created via propert…
Browse files Browse the repository at this point in the history
…ies (#1257)
  • Loading branch information
scottf authored Dec 4, 2024
1 parent 1962352 commit 6cb9ead
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/main/java/io/nats/client/Options.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ public class Options {
// PROTOCOL CONNECT OPTION CONSTANTS * not related to options, but here because Options code uses them
// CLASS VARIABLES * add a variable to the class
// BUILDER VARIABLES * add a variable in builder
// BUILDER COPY CONSTRUCTOR * update builder constructor to ensure new variables are set
// BUILD CONSTRUCTOR PROPS * update build props constructor to read new props
// BUILDER METHODS * add a chainable method in builder for new variable
// BUILD IMPL * update build() implementation if needed
// BUILDER COPY CONSTRUCTOR * update builder constructor to ensure new variables are set
// CONSTRUCTOR * update constructor to ensure new variables are set from builder
// GETTERS * update getter to be able to retrieve class variable value
// HELPER FUNCTIONS * just helpers
Expand Down Expand Up @@ -502,6 +502,21 @@ public class Options {
* Property used to configure a builder from a Properties object. {@value}, see {@link Builder#forceFlushOnRequest() forceFlushOnRequest}.
*/
public static final String PROP_FORCE_FLUSH_ON_REQUEST = PFX + "force.flush.on.request";
/**
* Property used to set class name for the Executor Service (executor) class
* {@link Builder#executor(ExecutorService) executor}.
*/
public static final String PROP_EXECUTOR_SERVICE_CLASS = "executor.service.class";
/**
* Property used to set class name for the Connect Thread Factory
* {@link Builder#connectThreadFactory(ThreadFactory) connectThreadFactory}.
*/
public static final String PROP_CONNECT_THREAD_FACTORY_CLASS = "connect.thread.factory.class";
/**
* Property used to set class name for the Callback Thread Factory
* {@link Builder#callbackThreadFactory(ThreadFactory) callbackThreadFactory}.
*/
public static final String PROP_CALLBACK_THREAD_FACTORY_CLASS = "callback.thread.factory.class";

// ----------------------------------------------------------------------------------------------------
// PROTOCOL CONNECT OPTION CONSTANTS
Expand Down Expand Up @@ -896,6 +911,9 @@ public Builder properties(Properties props) {

classnameProperty(props, PROP_SERVERS_POOL_IMPLEMENTATION_CLASS, o -> this.serverPool = (ServerPool) o);
classnameProperty(props, PROP_DISPATCHER_FACTORY_CLASS, o -> this.dispatcherFactory = (DispatcherFactory) o);
classnameProperty(props, PROP_EXECUTOR_SERVICE_CLASS, o -> this.executor = (ExecutorService) o);
classnameProperty(props, PROP_CONNECT_THREAD_FACTORY_CLASS, o -> this.connectThreadFactory = (ThreadFactory) o);
classnameProperty(props, PROP_CALLBACK_THREAD_FACTORY_CLASS, o -> this.callbackThreadFactory = (ThreadFactory) o);

return this;
}
Expand Down

0 comments on commit 6cb9ead

Please sign in to comment.