Package org.apache.curator.x.discovery
Class ServiceDiscoveryBuilder<T>
java.lang.Object
org.apache.curator.x.discovery.ServiceDiscoveryBuilder<T>
-
Method Summary
Modifier and TypeMethodDescriptionRequired - set the base path to store in ZK, seepathConstructor(DiscoveryPathConstructor)
for alternativebuild()
Build a new service discovery with the currently set values.static <T> ServiceDiscoveryBuilder
<T> Return a new builder.client
(CuratorFramework client) Required - set the client to usepathConstructor
(DiscoveryPathConstructor pathConstructor) Required - shape the service tree in ZK, seebasePath(String)
for alternativeserializer
(InstanceSerializer<T> serializer) optional - change the serializer used (the default isJsonInstanceSerializer
thisInstance
(ServiceInstance<T> thisInstance) Optional - instance that represents the service that is running.watchInstances
(boolean watchInstances) Optional - if true, watches for changes to locally registered instances (viathisInstance(ServiceInstance)
orServiceDiscovery.registerService(ServiceInstance)
).
-
Method Details
-
builder
Return a new builder.- Parameters:
payloadClass
- the class of the payload of your service instance (you can useVoid
if your instances don't need a payload)- Returns:
- new builder
-
build
Build a new service discovery with the currently set values. If not set, the builder will be defaulted with aJsonInstanceSerializer
.- Returns:
- new service discovery
-
client
Required - set the client to use- Parameters:
client
- client- Returns:
- this
-
basePath
Required - set the base path to store in ZK, seepathConstructor(DiscoveryPathConstructor)
for alternative- Parameters:
basePath
- base path- Returns:
- this
-
pathConstructor
Required - shape the service tree in ZK, seebasePath(String)
for alternative- Parameters:
pathConstructor
- custom service tree- Returns:
- this
-
serializer
optional - change the serializer used (the default isJsonInstanceSerializer
- Parameters:
serializer
- the serializer- Returns:
- this
-
thisInstance
Optional - instance that represents the service that is running. The instance will get auto-registered- Parameters:
thisInstance
- initial instance- Returns:
- this
-
watchInstances
Optional - if true, watches for changes to locally registered instances (viathisInstance(ServiceInstance)
orServiceDiscovery.registerService(ServiceInstance)
). If the data for instances changes, they are reloaded.- Parameters:
watchInstances
- true to watch instances- Returns:
- this
-