Package io.hekate.election
Class ElectionServiceFactory
- java.lang.Object
-
- io.hekate.election.ElectionServiceFactory
-
- All Implemented Interfaces:
ServiceFactory<ElectionService>
public class ElectionServiceFactory extends Object implements ServiceFactory<ElectionService>
Factory forElectionService
.This class represents a configurable factory for
ElectionService
. Instances of this class can beregistered
within theHekateBootstrap
in order to customize options of theElectionService
.For more details about the
ElectionService
and its capabilities please see the documentation ofElectionService
interface.- See Also:
ElectionService
-
-
Constructor Summary
Constructors Constructor Description ElectionServiceFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ElectionService
createService()
Constructs a new service instance based on the configuration options of this factory.List<CandidateConfig>
getCandidates()
Returns the list of election candidate configurations that should be automatically registered during the leader election service startup (seesetCandidates(List)
).List<CandidateConfigProvider>
getConfigProviders()
Returns the list of leader election configuration providers (seesetConfigProviders(List)
).void
setCandidates(List<CandidateConfig> candidates)
Sets the list of election candidate configurations that should be automatically registered during the leader election service startup.void
setConfigProviders(List<CandidateConfigProvider> configProviders)
Sets the list of leader election configuration providers.String
toString()
ElectionServiceFactory
withCandidate(CandidateConfig candidate)
Fluent-style version ofsetCandidates(List)
.CandidateConfig
withCandidate(String group)
Fluent-style shortcut to register a newCandidateConfig
with the specifiedgroup
.ElectionServiceFactory
withConfigProvider(CandidateConfigProvider configProvider)
Fluent-style version ofsetConfigProviders(List)
.
-
-
-
Method Detail
-
getCandidates
public List<CandidateConfig> getCandidates()
Returns the list of election candidate configurations that should be automatically registered during the leader election service startup (seesetCandidates(List)
).- Returns:
- List of election candidate configurations.
-
setCandidates
public void setCandidates(List<CandidateConfig> candidates)
Sets the list of election candidate configurations that should be automatically registered during the leader election service startup.- Parameters:
candidates
- Election candidate configurations.
-
withCandidate
public ElectionServiceFactory withCandidate(CandidateConfig candidate)
Fluent-style version ofsetCandidates(List)
.- Parameters:
candidate
- Election candidate configurations.- Returns:
- This instance.
-
withCandidate
public CandidateConfig withCandidate(String group)
Fluent-style shortcut to register a newCandidateConfig
with the specifiedgroup
.- Parameters:
group
- Group name (seeCandidateConfig.setGroup(String)
).- Returns:
- New configuration.
-
getConfigProviders
public List<CandidateConfigProvider> getConfigProviders()
Returns the list of leader election configuration providers (seesetConfigProviders(List)
).- Returns:
- Leader election configuration providers.
-
setConfigProviders
public void setConfigProviders(List<CandidateConfigProvider> configProviders)
Sets the list of leader election configuration providers.- Parameters:
configProviders
- Leader election configuration providers.- See Also:
CandidateConfigProvider
-
withConfigProvider
public ElectionServiceFactory withConfigProvider(CandidateConfigProvider configProvider)
Fluent-style version ofsetConfigProviders(List)
.- Parameters:
configProvider
- Leader election configuration provider.- Returns:
- This instance.
-
createService
public ElectionService createService()
Description copied from interface:ServiceFactory
Constructs a new service instance based on the configuration options of this factory.- Specified by:
createService
in interfaceServiceFactory<ElectionService>
- Returns:
- New service instance.
-
-