Crate speakeasy

Source
Expand description

Completely generic request/response client built on tower::Service, futures::Stream and futures::Sink.

sequenceDiagram
    participant app as Your Application
    participant svc as ez_client::Service
    participant task as ez_client::Task
    participant transport as TransportT

    autonumber

    app->>svc: RequestT
    svc->>task: ez_client::Ask
    note over svc,task: message over a Sink/Stream
    task->>transport: (RequestT, IdT)
    note over task,transport: message over a Sink/Stream
    note over task: wait for response...
    transport->>task: (ResponseT, IdT)
    task->>app: ResponseT

  1. Create a Service and Task.
    • Connect them to each other over a Stream/Sink, allowing you to configure your own e.g queue depth, MPSC etc.
    • Give the Task a Stream/Sink transport to own. This is typically a wrapper over e.g a websocket connection.
  2. You call the Service with a Dialogue.
  3. The Service formats this into an Ask for the Task.
  4. The Task assigns the request an identifier for correlation using an IdFactory, and sends the pair to the transport.
  5. A response eventually arrives on the transport.
  6. The Task reacts to the response, resolving the Future returned in (1).

Tasks also handle timeouts, and propogating errors from the transport.

Modules§

ask
Contains ask::Kind.
dialogue
Types when a Service handles a Dialogue.
error_factory
Utility implementors of ErrorFactory.
future
Futures used by this crate.
id_factory
Utility implementations of IdFactory.
notification
Types when a Service handles a Notification.
task
Contains task::Error, emitted by a Task.
util
General utilities.

Structs§

Ask
Application-level input to a Task.
Dialogue
Indicate to a Service that the Task should assign an ID, and wait for a response until the timeout.
Notification
Indicate to a Service that the Task should NOT assign an ID, or wait for a response.
Service
Implementor of Service which dispatches to a Task.
Task
Generic dispatcher for notifications and request/response pairs.

Traits§

ErrorFactory
A transport error for `Task which can be broadcast to all clients.
IdFactory
Issuer of identifiers for requests in Task.