Package org.apache.curator.x.discovery
Class ServiceDiscoveryBuilder<T>
- java.lang.Object
-
- org.apache.curator.x.discovery.ServiceDiscoveryBuilder<T>
-
public class ServiceDiscoveryBuilder<T> extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ServiceDiscoveryBuilder<T>basePath(java.lang.String basePath)Required - set the base path to store in ZKServiceDiscovery<T>build()Build a new service discovery with the currently set values.static <T> ServiceDiscoveryBuilder<T>builder(java.lang.Class<T> payloadClass)Return a new builder.ServiceDiscoveryBuilder<T>client(org.apache.curator.framework.CuratorFramework client)Required - set the client to useServiceDiscoveryBuilder<T>serializer(InstanceSerializer<T> serializer)optional - change the serializer used (the default isJsonInstanceSerializerServiceDiscoveryBuilder<T>thisInstance(ServiceInstance<T> thisInstance)Optional - instance that represents the service that is running.ServiceDiscoveryBuilder<T>watchInstances(boolean watchInstances)Optional - if true, watches for changes to locally registered instances (viathisInstance(ServiceInstance)orServiceDiscovery.registerService(ServiceInstance)).
-
-
-
Method Detail
-
builder
public static <T> ServiceDiscoveryBuilder<T> builder(java.lang.Class<T> payloadClass)
Return a new builder.- Parameters:
payloadClass- the class of the payload of your service instance (you can useVoidif your instances don't need a payload)- Returns:
- new builder
-
build
public ServiceDiscovery<T> 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
public ServiceDiscoveryBuilder<T> client(org.apache.curator.framework.CuratorFramework client)
Required - set the client to use- Parameters:
client- client- Returns:
- this
-
basePath
public ServiceDiscoveryBuilder<T> basePath(java.lang.String basePath)
Required - set the base path to store in ZK- Parameters:
basePath- base path- Returns:
- this
-
serializer
public ServiceDiscoveryBuilder<T> serializer(InstanceSerializer<T> serializer)
optional - change the serializer used (the default isJsonInstanceSerializer- Parameters:
serializer- the serializer- Returns:
- this
-
thisInstance
public ServiceDiscoveryBuilder<T> thisInstance(ServiceInstance<T> thisInstance)
Optional - instance that represents the service that is running. The instance will get auto-registered- Parameters:
thisInstance- initial instance- Returns:
- this
-
watchInstances
public ServiceDiscoveryBuilder<T> watchInstances(boolean 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
-
-