Package net.sodacan.core.config
Class BaseBuilder
java.lang.Object
net.sodacan.core.config.BaseBuilder
- Direct Known Subclasses:
SimpleBuilder
Contains all the logic for configuration but no actual configuration. This is an abstract class.
If you want a custom configuration from scratch, it's best to subclass this class and provide configuration
settings there, see SimpleBuilder for an example. You can also subclass SimpleBuilder and not have to
start from scratch.
These builders also come with a copy constructor making it easy to do mixins (last configuration setting wins).
-
Field Summary
FieldsModifier and TypeFieldDescription -
Constructor Summary
ConstructorsConstructorDescriptionStart with an empty builderBaseBuilder
(BaseBuilder from) Copy constructor builder. -
Method Summary
Modifier and TypeMethodDescriptionactorGroup
(BiFunction<Config, Integer, ActorGroup> actorGroupFn) Local factoryactorGroupAssigner
(Function<Config, ActorGroupAssigner> actorGroupAssignerFn) Local singletonactorGroupReplicas
(int actorGroupReplicas) The number of replicas of a actorGroup to maintain.actorGroupReplicas
(Function<Config, Integer> actorGroupReplicasFn) actorGroups
(int actorGroups) Specify the number of actorGroups in the system.actorGroups
(Function<Config, Integer> actorGroupsFn) actorGroupThreads
(int actorGroupThreads) Local dynamic (maybe) Change effective in new actorGroups onlyactorGroupThreads
(Function<Config, Integer> actorGroupThreadsFn) actorIdFactory
(Function<Config, ActorIdFactory> actorIdFactoryFn) Local factorybackpressureLimit
(int backpressureLimit) backpressureLimit
(Function<Config, Integer> backpressureLimitFn) Global dynamicbackpressureWaitMs
(int backpressureWaitMs) Specify the backpressure limit in an ActorGroup.backpressureWaitMs
(Function<Config, Integer> backpressureWaitMsFn) Specify the backpressure limit in an ActorGroup.build()
Build the Config objectcoordinator
(Function<Config, Coordinator> coordinatorFn) Local singletoneviction
(int eviction) Global dynamiclocal singletonhostNumber
(int hostNumber) Local StatichostNumber
(Function<Config, Integer> hostNumberFn) persisterFactory
(Function<Config, PersisterFactory> persisterFactoryFn) Set a system propertyregisterActorsInPackage
(String packageName) global staticregisterActorType
(String actorType, Class<? extends Actor> type) Register a new ActorType with a default constructorregisterActorType
(String actorType, Class<? extends Actor> type, BiFunction<Config, ActorId, Actor> factory) global static Explicitly register an actor type name to actor class.rootDirectory
(String rootDirectory) rootDirectory
(Function<Config, String> rootDirectoryFn) scheduler
(BiFunction<Config, ActorGroup, Scheduler> schedulerFn) Local factoryserializerFactory
(Function<Config, SerializerFactory> serializerFactoryFn) shutdownWaitMs
(int ms) global dynamic
-
Field Details
-
hostNumberFn
-
clockFn
-
randomFn
-
rootDirectoryFn
-
actorGroupsFn
-
actorGroupReplicasFn
-
backpressureLimitFn
-
backpressureWaitMsFn
-
shutdownWaitMsFn
-
evictionFn
-
actorGroupThreadsFn
-
actorGroupAssignerFn
-
schedulerFn
-
actorIdFactoryFn
-
actorGroupFn
-
coordinatorFn
-
hostFn
-
messageIdFn
-
messageFn
-
persisterFactoryFn
-
serializerFactoryFn
-
actorMetadata
-
-
Constructor Details
-
BaseBuilder
public BaseBuilder()Start with an empty builder -
BaseBuilder
Copy constructor builder. Any setting in the source (from) builder overrides this builder.
-
-
Method Details
-
hostNumber
Local Static- Parameters:
hostNumber
-- Returns:
-
hostNumber
-
clock
-
random
-
rootDirectory
-
rootDirectory
-
actorGroups
Specify the number of actorGroups in the system. Default is 1 Global Static- Parameters:
actorGroups
-- Returns:
-
actorGroups
-
actorGroupReplicas
The number of replicas of a actorGroup to maintain. Zero is valid. It means that only a primary actorGroup exists. The default is zero.
- Parameters:
actorGroupReplicas
-- Returns:
-
actorGroupReplicas
-
eviction
Global dynamicThis is the extra number of threads we add to allow that number of ActorEntry threads to be removed to make room for new messages. If this value is zero, it's very likely to cause a deadlock in the ActorGroup because there is more work to do but no Actors can be evicted in order to perform that work.
This number should be above 5 to improve performance. The less the number, the more often the eviction process has to begin.
- Parameters:
eviction
-- Returns:
-
eviction
-
actorGroupThreads
Local dynamic (maybe) Change effective in new actorGroups only- Parameters:
actorGroupThreads
-- Returns:
-
actorGroupThreads
-
backpressureLimit
Global dynamic- Parameters:
backpressureLimitFn
-- Returns:
-
backpressureLimit
-
backpressureWaitMs
Specify the backpressure limit in an ActorGroup. When the number of in-flight messages exceeds this limit, inbound messages are blocked. Global dynamic- Parameters:
backpressureWaitMsFn
-- Returns:
-
backpressureWaitMs
Specify the backpressure limit in an ActorGroup. When the number of in-flight messages exceeds this limit, inbound messages are blocked. Global static- Parameters:
backpressureWaitMs
-- Returns:
-
actorGroupAssigner
Local singleton- Parameters:
actorGroupAssignerFn
-- Returns:
-
messageId
- Parameters:
messageIdFn
- A function that will return a MessageId- Returns:
-
persisterFactory
-
serializerFactory
-
message
- Parameters:
messageFn
- A function that will return a new Message- Returns:
-
registerActorsInPackage
global static- Parameters:
packageName
-- Returns:
-
registerActorType
public BaseBuilder registerActorType(String actorType, Class<? extends Actor> type, BiFunction<Config, ActorId, Actor> factory) global static Explicitly register an actor type name to actor class. If the actor has an ActorType annotation, this registration is not needed. If this is called after the package containing the actor is registered, then this setting takes priority- Parameters:
actorType
-type
-- Returns:
- Builder object to allow chaining
-
registerActorType
Register a new ActorType with a default constructor- Parameters:
actorType
-type
-- Returns:
-
shutdownWaitMs
global dynamic- Parameters:
ms
-- Returns:
-
shutdownWaitMs
-
coordinator
Local singleton- Parameters:
coordinatorFn
-- Returns:
-
host
local singleton- Parameters:
hostFn
-- Returns:
-
scheduler
Local factory- Parameters:
schedulerFn
-- Returns:
-
actorIdFactory
Local factory- Parameters:
actorIdFactoryFn
-- Returns:
-
actorGroup
Local factory- Parameters:
actorGroupFn
-- Returns:
-
property
Set a system property- Parameters:
name
-value
-- Returns:
-
build
Build the Config object- Returns:
-