1 unstable release

new 0.1.0 Apr 17, 2025

#3 in #ask

MIT/Apache

51KB
1K SLoC

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

<script type="module"> import mermaid from "https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs"; var doc_theme = localStorage.getItem("rustdoc-theme"); if (doc_theme === "dark" || doc_theme === "ayu") mermaid.initialize({theme: "dark"}); </script>
  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.

Dependencies

~1.6–2.4MB
~42K SLoC