Class HubSpokeBuilder
java.lang.Object
com.tnsai.coordination.groups.hubspoke.HubSpokeBuilder
Builder for creating HubSpoke instances.
Usage Example
HubSpoke hs = HubSpoke.builder()
.name("Task Distributor")
.hub(coordinator)
.spoke(worker1)
.spoke(worker2)
.loadBalancing(LoadBalancer.Strategy.ROUND_ROBIN)
.build();
-
Method Summary
Modifier and TypeMethodDescriptionautoStart(boolean autoStart) Sets whether to auto-start after build.build()Builds the HubSpoke.description(String description) Sets the hub-spoke description.hub(com.tnsai.agents.Agent agent) Sets the hub agent.Sets the hub-spoke ID.loadBalancing(LoadBalancer.Strategy strategy) Sets the load balancing strategy.Sets the hub-spoke name.policy(com.tnsai.agents.groups.GroupPolicy policy) Sets the group policy.spoke(com.tnsai.agents.Agent agent) Adds a spoke agent.spokes(com.tnsai.agents.Agent... agents) Adds multiple spoke agents.
-
Method Details
-
id
Sets the hub-spoke ID.- Parameters:
id- hub-spoke ID- Returns:
- this builder
-
name
Sets the hub-spoke name.- Parameters:
name- hub-spoke name- Returns:
- this builder
-
description
Sets the hub-spoke description.- Parameters:
description- hub-spoke description- Returns:
- this builder
-
policy
Sets the group policy.- Parameters:
policy- policy- Returns:
- this builder
-
hub
Sets the hub agent.- Parameters:
agent- hub agent- Returns:
- this builder
-
spoke
Adds a spoke agent.- Parameters:
agent- spoke agent- Returns:
- this builder
-
spokes
Adds multiple spoke agents.- Parameters:
agents- spoke agents- Returns:
- this builder
-
loadBalancing
Sets the load balancing strategy.- Parameters:
strategy- load balancing strategy- Returns:
- this builder
-
autoStart
Sets whether to auto-start after build.- Parameters:
autoStart- auto-start flag- Returns:
- this builder
-
build
Builds the HubSpoke.- Returns:
- new HubSpoke instance
- Throws:
IllegalStateException- if hub is not set
-