Class RedisTransport

java.lang.Object
com.iantapply.orchestra.adapter.redis.RedisTransport
All Implemented Interfaces:
com.iantapply.orchestra.port.NetworkTransport, AutoCloseable

public final class RedisTransport extends Object implements com.iantapply.orchestra.port.NetworkTransport
Redis Pub/Sub transport with daemon subscription threads and reconnect handling.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface com.iantapply.orchestra.port.NetworkTransport

    com.iantapply.orchestra.port.NetworkTransport.Subscription
  • Constructor Summary

    Constructors
    Constructor
    Description
    RedisTransport(URI uri, String namespace)
    Creates a Redis Pub/Sub transport.
    RedisTransport(URI uri, String namespace, Consumer<String> failureCounter)
    Creates a Redis transport with an operational failure counter sink.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    boolean
    Checks whether Redis accepts a short authenticated PING request.
    void
    publish(String channel, byte[] payload)
     
    com.iantapply.orchestra.port.NetworkTransport.Subscription
    subscribe(String channel, Consumer<byte[]> listener)
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RedisTransport

      public RedisTransport(URI uri, String namespace)
      Creates a Redis Pub/Sub transport.
      Parameters:
      uri - Redis URI, optionally containing credentials and database number
      namespace - prefix applied to logical channels
    • RedisTransport

      public RedisTransport(URI uri, String namespace, Consumer<String> failureCounter)
      Creates a Redis transport with an operational failure counter sink.
      Parameters:
      uri - Redis URI
      namespace - channel namespace
      failureCounter - counter-name sink
  • Method Details

    • publish

      public void publish(String channel, byte[] payload)
      Specified by:
      publish in interface com.iantapply.orchestra.port.NetworkTransport
    • subscribe

      public com.iantapply.orchestra.port.NetworkTransport.Subscription subscribe(String channel, Consumer<byte[]> listener)
      Specified by:
      subscribe in interface com.iantapply.orchestra.port.NetworkTransport
    • isReachable

      public boolean isReachable()
      Checks whether Redis accepts a short authenticated PING request.
      Returns:
      true when Redis replies with PONG
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface com.iantapply.orchestra.port.NetworkTransport