
com.netflix.curator.x.discovery.ServiceDiscoveryBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of curator-x-discovery Show documentation
Show all versions of curator-x-discovery Show documentation
curator developed by Netflix
The newest version!
/*
*
* Copyright 2011 Netflix, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package com.netflix.curator.x.discovery;
import com.netflix.curator.framework.CuratorFramework;
import com.netflix.curator.x.discovery.details.InstanceSerializer;
import com.netflix.curator.x.discovery.details.JsonInstanceSerializer;
import com.netflix.curator.x.discovery.details.ServiceDiscoveryImpl;
public class ServiceDiscoveryBuilder
{
private CuratorFramework client;
private String basePath;
private InstanceSerializer serializer;
private ServiceInstance thisInstance;
/**
* Return a new builder. The builder will be defaulted with a {@link JsonInstanceSerializer}.
*
* @param payloadClass the class of the payload of your service instance (you can use {@link Void}
* if your instances don't need a payload)
* @return new builder
*/
public static ServiceDiscoveryBuilder builder(Class payloadClass)
{
return new ServiceDiscoveryBuilder(payloadClass).serializer(new JsonInstanceSerializer(payloadClass));
}
/**
* Build a new service discovery with the currently set values
*
* @return new service discovery
*/
public ServiceDiscovery build()
{
return new ServiceDiscoveryImpl(client, basePath, serializer, thisInstance);
}
/**
* Required - set the client to use
*
* @param client client
* @return this
*/
public ServiceDiscoveryBuilder client(CuratorFramework client)
{
this.client = client;
return this;
}
/**
* Required - set the base path to store in ZK
*
* @param basePath base path
* @return this
*/
public ServiceDiscoveryBuilder basePath(String basePath)
{
this.basePath = basePath;
return this;
}
/**
* optional - change the serializer used (the default is {@link JsonInstanceSerializer}
*
* @param serializer the serializer
* @return this
*/
public ServiceDiscoveryBuilder serializer(InstanceSerializer serializer)
{
this.serializer = serializer;
return this;
}
/**
* Optional - instance that represents the service that is running. The instance will get auto-registered
*
* @param thisInstance initial instance
* @return this
*/
public ServiceDiscoveryBuilder thisInstance(ServiceInstance thisInstance)
{
this.thisInstance = thisInstance;
return this;
}
ServiceDiscoveryBuilder(Class payloadClass)
{
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy