Package com.caplin.datasource
Interface Service
public interface Service
This describes a service that this DataSource provides.
This includes information such as which requests are capable of being routed to it and object mappings to be applied by Liberator.
This includes information such as which requests are capable of being routed to it and object mappings to be applied by Liberator.
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic enum
The minimum state peers for this service must be in for Liberator to begin accepting client connections.static enum
Dictates the style of data publication supported by this service and how subscriptions should be re-balanced on peer connection and disconnection. -
Method Summary
Modifier and TypeMethodDescriptionaddExcludePattern
(@NotNull String pattern) Add a pattern for which requests will never be routed to this service when the requested subject matches.addIfLabelPattern
(@NotNull String pattern) Adds a regular expression pattern to use when determining whether this service should be considered by a remote peer or not.addIncludePattern
(@NotNull String pattern) Add a pattern for which requests will be routed to this service when the requested subject matches.addObjectMap
(@NotNull String from, @NotNull String to) Adds an object mapping for a given subject pattern.static @NotNull Service
Creates a new instance of aService
with the provided name.setDiscardTimeout
(@NotNull Duration discardTimeout) Sets the discard timeout - i.e.setOpenSubscriptions
(boolean openSubscriptions) Sets the value indicating whether the service has open subscriptions enabled or not.setRemoteLabelPattern
(@NotNull String remoteLabelPattern) Sets the remote label pattern for the service.setRequiredState
(@NotNull Service.RequiredState requiredState) Sets the required state for the service.setThrottleTime
(@NotNull Duration throttleTime) Sets the throttle time for the service - i.e.setType
(@NotNull Service.Type type) Sets the type of the service.
-
Method Details
-
named
Creates a new instance of aService
with the provided name.- Parameters:
name
- the name of the service- Returns:
- a new instance of a
Service
with the provided name - See Also:
-
setOpenSubscriptions
Sets the value indicating whether the service has open subscriptions enabled or not.- Parameters:
openSubscriptions
-true
if the service has open subscriptions,false
otherwise.- Returns:
- This
Service
object to allow for method chaining. - See Also:
-
setDiscardTimeout
Sets the discard timeout - i.e. the time after which Liberator will discard the subscription once the last client has unsubscribed from the data. -
setThrottleTime
Sets the throttle time for the service - i.e. the time in which consecutive updates on a subject will be conflated by Liberator in order to reduce network load. -
setRequiredState
Sets the required state for the service.- Parameters:
requiredState
- The required state for the service. Must not benull
.- Returns:
- This
Service
object to allow for method chaining. - See Also:
-
setRemoteLabelPattern
Sets the remote label pattern for the service. This will be used to determine the peers to be considered as providing this service.
For example, if the pattern is `my-adapter-*`, a request associated with this service will be routed to a connected peer with a `local-label` matching this pattern, such as `my-adapter-1`.
Note: This pattern must be POSIX-Extended Regular Expressions compatible.- Parameters:
remoteLabelPattern
- The remote label pattern for the service. Must not benull
.- Returns:
- This
Service
object to allow for method chaining. - See Also:
-
setType
Sets the type of the service.- Parameters:
type
- The type of the service. Must not benull
.- Returns:
- This
Service
object to allow for method chaining. - See Also:
-
addIfLabelPattern
Adds a regular expression pattern to use when determining whether this service should be considered by a remote peer or not. If this pattern matches the remote peer's local-label, the remote peer will include the service. If the pattern does not match then this service definition will be ignored.
For example, if the list contains patterns such as["liberator-*", "proxy-*"]
, the service will be considered by a remote peer whose `local-label` matches either pattern.
Note: This pattern must be POSIX-Extended Regular Expressions compatible.- Parameters:
pattern
- The pattern to use for matching remote peers' local-label. Must not benull
.- Returns:
- This
Service
object to allow for method chaining. - See Also:
-
addObjectMap
Adds an object mapping for a given subject pattern.
Note: Please refer to the object mapping documentation for the pattern format.- Parameters:
from
- The pattern to match the original subject. Must not benull
.to
- The pattern with which to create the mapped subject. Must not benull
.- Returns:
- This
Service
object to allow for method chaining. - See Also:
-
addIncludePattern
Add a pattern for which requests will be routed to this service when the requested subject matches.
Note: This pattern must be POSIX-Extended Regular Expressions compatible.- Parameters:
pattern
- The pattern to use for matching subjects. Must not benull
.- Returns:
- This
Service
object to allow for method chaining. - See Also:
-
addExcludePattern
Add a pattern for which requests will never be routed to this service when the requested subject matches.
Note: This pattern must be POSIX-Extended Regular Expressions compatible.- Parameters:
pattern
- The pattern to use for matching subjects. Must not benull
.- Returns:
- This
Service
object to allow for method chaining. - See Also:
-