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.
  • Method Details

    • named

      @Contract("_ -> new") @NotNull static @NotNull Service named(String name)
      Creates a new instance of a Service 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

      Service setOpenSubscriptions(boolean openSubscriptions)
      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

      Service setDiscardTimeout(@NotNull @NotNull Duration discardTimeout)
      Sets the discard timeout - i.e. the time after which Liberator will discard the subscription once the last client has unsubscribed from the data.
      Parameters:
      discardTimeout - The discard timeout as a Duration object. Must not be null.
      Returns:
      This Service object to allow for method chaining.
      See Also:
    • setThrottleTime

      Service setThrottleTime(@NotNull @NotNull Duration throttleTime)
      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.
      Parameters:
      throttleTime - The throttle time as a Duration object. Must not be null.
      Returns:
      This Service object to allow for method chaining.
      See Also:
    • setRequiredState

      Service setRequiredState(@NotNull @NotNull Service.RequiredState requiredState)
      Sets the required state for the service.
      Parameters:
      requiredState - The required state for the service. Must not be null.
      Returns:
      This Service object to allow for method chaining.
      See Also:
    • setRemoteLabelPattern

      Service setRemoteLabelPattern(@NotNull @NotNull String remoteLabelPattern)
      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 be null.
      Returns:
      This Service object to allow for method chaining.
      See Also:
    • setType

      Service setType(@NotNull @NotNull Service.Type type)
      Sets the type of the service.
      Parameters:
      type - The type of the service. Must not be null.
      Returns:
      This Service object to allow for method chaining.
      See Also:
    • addIfLabelPattern

      Service addIfLabelPattern(@NotNull @NotNull String pattern)
      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 be null.
      Returns:
      This Service object to allow for method chaining.
      See Also:
    • addObjectMap

      Service addObjectMap(@NotNull @NotNull String from, @NotNull @NotNull String to)
      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 be null.
      to - The pattern with which to create the mapped subject. Must not be null.
      Returns:
      This Service object to allow for method chaining.
      See Also:
    • addIncludePattern

      Service addIncludePattern(@NotNull @NotNull String pattern)
      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 be null.
      Returns:
      This Service object to allow for method chaining.
      See Also:
    • addExcludePattern

      Service addExcludePattern(@NotNull @NotNull String pattern)
      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 be null.
      Returns:
      This Service object to allow for method chaining.
      See Also: