Skip to content

io7m-com/hibiscus

Repository files navigation

hibiscus

Maven Central Maven Central (snapshot) Codecov Java Version

com.io7m.hibiscus

JVM Platform Status
OpenJDK (Temurin) Current Linux Build (OpenJDK (Temurin) Current, Linux)
OpenJDK (Temurin) LTS Linux Build (OpenJDK (Temurin) LTS, Linux)
OpenJDK (Temurin) Current Windows Build (OpenJDK (Temurin) Current, Windows)
OpenJDK (Temurin) LTS Windows Build (OpenJDK (Temurin) LTS, Windows)

Hibiscus

An API specification for simple RPC clients.

Motivation

Many io7m projects implement some form of RPC client. The Hibiscus API is an attempt to define some common interface types so that unrelated projects nevertheless end up with a consistent look and feel across client implementations.

Architecture

architecture

  1. A Configuration is passed to a ClientFactory to produce a Client.
  2. The Client sends ConnectionParameters to the server to log in.
  3. The Server sends back Messages indicating if the login succeeded or failed.
  4. Assuming success, the Client sends Messages to the server to perform operations.
  5. The Server sends Messages in response to Messages.

State

Clients conform to a simple state machine:

state

  1. Clients begin in the DISCONNECTED state.
  2. A Login operation moves the client into the CONNECTING state.
  3. If the login succeeds, the client moves to the CONNECTED state after passing through the CONNECTION_SUCCEEDED state.
  4. If the login fails, the client moves to the DISCONNECTED state after passing through the CONNECTION_FAILED state.

In the CONNECTED state, the client can:

  • Disconnect, moving to the DISCONNECTED state.
  • Send messages, remaining in the CONNECTED state.

A client maintains an internal Transport that performs the actual communication.

Transport

A Transport represents an object that can be used to read and write messages. A Transport exposes the following operations:

  • receive: Read a message from the transport.
  • sendAndForget: Write a message to the transport, potentially discarding any response that might come back.
  • sendAndWait: Write a message to the transport and wait for a response to come back.
  • send: Write a message to the transport but do not wait for a response to come back. The response can be fetched later with receive.

The package includes multiple example transports: