public final class Descriptor extends Object
A descriptor is a set of calls descriptors that the service provides, coupled with metadata about how the service and its calls are to be served. Metadata may include versioning and migrations, SLA's, sharding hints, circuit breaker strategies etc.
Modifier and Type | Class and Description |
---|---|
static class |
Descriptor.Call<Request,Response>
Describes a service call.
|
static class |
Descriptor.CallId
The Call ID.
|
static class |
Descriptor.NamedCallId
A named call ID.
|
static class |
Descriptor.PathCallId
A path based call ID.
|
static class |
Descriptor.Properties<Message>
Holds a map of properties.
|
static class |
Descriptor.RestCallId
A REST call ID.
|
static interface |
Descriptor.ServiceCallHolder
Holds the service call itself.
|
static class |
Descriptor.TopicCall<Message>
Describes a topic call.
|
static interface |
Descriptor.TopicHolder
Holds the topic implementation.
|
Modifier and Type | Method and Description |
---|---|
org.pcollections.PSequence<ServiceAcl> |
acls()
The manually configured ACLs for this service.
|
boolean |
autoAcl()
Whether this descriptor will auto generate ACLs for each call.
|
org.pcollections.PSequence<Descriptor.Call<?,?>> |
calls() |
CircuitBreaker |
circuitBreaker()
Get the default circuit breaker mode used by this service.
|
ExceptionSerializer |
exceptionSerializer() |
HeaderFilter |
headerFilter()
The header filter to use for this service.
|
boolean |
locatableService()
Whether this is a locatable service.
|
org.pcollections.PMap<Type,MessageSerializer<?,?>> |
messageSerializers() |
String |
name() |
org.pcollections.PMap<Type,PathParamSerializer<?>> |
pathParamSerializers() |
Descriptor |
publishing(Descriptor.TopicCall<?>... topicCalls)
Deprecated.
use
withTopics(TopicCall[]) instead. |
Descriptor |
replaceAllAcls(org.pcollections.PSequence<ServiceAcl> acls)
Replace all the ACLs with the given ACL sequence.
|
Descriptor |
replaceAllCalls(org.pcollections.PSequence<Descriptor.Call<?,?>> calls)
Replace all the service calls provided by this descriptor with the the given service calls.
|
Descriptor |
replaceAllMessageSerializers(org.pcollections.PMap<Type,MessageSerializer<?,?>> messageSerializers)
Replace all the message serializers registered with this descriptor with the the given message
serializers.
|
Descriptor |
replaceAllPathParamSerializers(org.pcollections.PMap<Type,PathParamSerializer<?>> pathParamSerializers)
Replace all the path param serializers registered with this descriptor with the the given path
param serializers.
|
Descriptor |
replaceAllTopicCalls(org.pcollections.PSequence<Descriptor.TopicCall<?>> topicCalls)
Replace all the topic calls provided by this descriptor with the the given topic calls.
|
SerializerFactory |
serializerFactory() |
org.pcollections.PSequence<Descriptor.TopicCall<?>> |
topicCalls() |
Descriptor |
withAutoAcl(boolean autoAcl)
Set whether the service calls in this descriptor should default to having an ACL automatically
generated for them.
|
Descriptor |
withCalls(Descriptor.Call<?,?>... calls)
Add the given service calls to this service.
|
Descriptor |
withCircuitBreaker(CircuitBreaker circuitBreaker)
Set the default circuit breaker to use for this service.
|
Descriptor |
withExceptionSerializer(ExceptionSerializer exceptionSerializer)
Use the given exception serializer to serialize and deserialized exceptions handled by this
service.
|
Descriptor |
withHeaderFilter(HeaderFilter headerFilter)
Configure the given header filter.
|
Descriptor |
withLocatableService(boolean locatableService)
Set whether this service is locatable.
|
<T> Descriptor |
withMessageSerializer(Class<T> messageType,
MessageSerializer<T,?> messageSerializer)
Provide a custom MessageSerializer for the given message type.
|
Descriptor |
withMessageSerializer(Type messageType,
MessageSerializer<?,?> messageSerializer)
Provide a custom MessageSerializer for the given message type.
|
<T> Descriptor |
withPathParamSerializer(Class<T> pathParamType,
PathParamSerializer<T> pathParamSerializer)
Provide a custom path param serializer for the given path param type.
|
Descriptor |
withPathParamSerializer(Type pathParamType,
PathParamSerializer<?> pathParamSerializer)
Provide a custom path param serializer for the given path param type.
|
Descriptor |
withSerializerFactory(SerializerFactory serializerFactory)
Use the given serializer factory with this service.
|
Descriptor |
withServiceAcls(ServiceAcl... acls)
Add the given manual ACLs.
|
Descriptor |
withTopics(Descriptor.TopicCall<?>... topicCalls)
Add the given topic calls to this service.
|
public String name()
public org.pcollections.PSequence<Descriptor.Call<?,?>> calls()
public org.pcollections.PMap<Type,PathParamSerializer<?>> pathParamSerializers()
public org.pcollections.PMap<Type,MessageSerializer<?,?>> messageSerializers()
public SerializerFactory serializerFactory()
public ExceptionSerializer exceptionSerializer()
public boolean autoAcl()
public org.pcollections.PSequence<ServiceAcl> acls()
public HeaderFilter headerFilter()
public boolean locatableService()
Locatable services are registered with the service locator and/or gateway, so that they can be consumed by other services. Services that are not locatable are typically services for infrastructure purposes, such as providing metrics.
public CircuitBreaker circuitBreaker()
This is what will be used if no service breaker is explicitly set on the service call.
public org.pcollections.PSequence<Descriptor.TopicCall<?>> topicCalls()
public <T> Descriptor withPathParamSerializer(Class<T> pathParamType, PathParamSerializer<T> pathParamSerializer)
pathParamType
- The path param type.pathParamSerializer
- The path param serializer.public Descriptor withPathParamSerializer(Type pathParamType, PathParamSerializer<?> pathParamSerializer)
pathParamType
- The path param type.pathParamSerializer
- The path param serializer.public <T> Descriptor withMessageSerializer(Class<T> messageType, MessageSerializer<T,?> messageSerializer)
messageType
- The type of the message.messageSerializer
- The message serializer for that type.public Descriptor withMessageSerializer(Type messageType, MessageSerializer<?,?> messageSerializer)
messageType
- The type of the message.messageSerializer
- The message serializer for that type.public Descriptor withCalls(Descriptor.Call<?,?>... calls)
calls
- The calls to add.public Descriptor replaceAllCalls(org.pcollections.PSequence<Descriptor.Call<?,?>> calls)
calls
- The calls to replace the existing ones with.public Descriptor replaceAllPathParamSerializers(org.pcollections.PMap<Type,PathParamSerializer<?>> pathParamSerializers)
pathParamSerializers
- The path param serializers to replace the existing ones with.public Descriptor replaceAllMessageSerializers(org.pcollections.PMap<Type,MessageSerializer<?,?>> messageSerializers)
messageSerializers
- The message serializers to replace the existing ones with.public Descriptor replaceAllTopicCalls(org.pcollections.PSequence<Descriptor.TopicCall<?>> topicCalls)
topicCalls
- The topic calls to replace the existing ones with.public Descriptor withExceptionSerializer(ExceptionSerializer exceptionSerializer)
exceptionSerializer
- The exception handler to use.public Descriptor withSerializerFactory(SerializerFactory serializerFactory)
serializerFactory
- The serializer factory to use.public Descriptor withAutoAcl(boolean autoAcl)
By default, this will not happen.
Note that each service call can override this by calling withAutoAcl on them.
autoAcl
- Whether autoAcl should be true.public Descriptor withServiceAcls(ServiceAcl... acls)
If auto ACLs are configured, these will be added in addition to the auto ACLs.
acls
- The ACLs to add.public Descriptor replaceAllAcls(org.pcollections.PSequence<ServiceAcl> acls)
This will not replace ACLs generated by autoAcl, to disable autoAcl, turn it off.
acls
- The ACLs to use.public Descriptor withHeaderFilter(HeaderFilter headerFilter)
headerFilter
- The header filter to use.public Descriptor withLocatableService(boolean locatableService)
Locatable services are registered with the service locator and/or gateway, so that they can be consumed by other services. Services that are not locatable are typically services for infrastructure purposes, such as providing metrics.
locatableService
- Whether this service should be locatable or not.public Descriptor withCircuitBreaker(CircuitBreaker circuitBreaker)
This circuit breaker mode will be used for any service calls that don't explicitly configure their own circuit breaker configuration.
circuitBreaker
- The circuit breaker mode.@Deprecated public Descriptor publishing(Descriptor.TopicCall<?>... topicCalls)
withTopics(TopicCall[])
instead.topicCalls
- The topic calls to add.public Descriptor withTopics(Descriptor.TopicCall<?>... topicCalls)
topicCalls
- The topic calls to add.