Pudu programming language
Menu
Package

@chrismichaelps / pudu-lang-mediator

In-process messaging for Pudu: requests, notifications, streams, pipeline behaviors, processors, and exception handling

0.1.0Apache-2.01

InstallClose

Sender.pudu

Pudu35 lines1.7 KB

GitHub ↗
1/** @Mediator.Sender.Seam — what a component that only sends requests depends on */2module PuduLangMediator.Sender34import PuduLangMediator.Context as Context5import PuduLangMediator.Mediator as Mediator6import PuduLangMediator.Message as Message7import PuduLangMediator as Messaging8import PuduLangMediator.Request as Request9import PuduLangMediator.Stream as Stream1011/** @Mediator.Sender.Sender — sends requests and streams; a mediator or a test double */12export trait Sender {13  /// The request's outcome through its pipeline.14  fn send[Q, R, E](self: &Self, subject: &Request.Kind[Q, R, E], request: Q, context: Context.Context) -> Messaging.Outcome[R, E]15  /// The answer to a request whose type the caller does not name.16  fn dispatch(self: &Self, envelope: Message.Envelope, context: Context.Context) -> Message.Answer17  /// Hands each item of a stream request to `sink` until it declines one.18  fn stream[Q, T, E](self: &Self, subject: &Stream.Kind[Q, T, E], request: Q, context: Context.Context, sink: Stream.Sink[T]) -> Messaging.Outcome[(), E]19}2021impl Sender for Mediator.Mediator {22  /// `Mediator.sendWith`.23  fn send[Q, R, E](self: &Self, subject: &Request.Kind[Q, R, E], request: Q, context: Context.Context) -> Messaging.Outcome[R, E] {24    Mediator.sendWith(self, subject, request, context)25  }2627  /// `Mediator.dispatchWith`.28  fn dispatch(self: &Self, envelope: Message.Envelope, context: Context.Context) -> Message.Answer { Mediator.dispatchWith(self, envelope, context) }2930  /// `Mediator.streamWith`.31  fn stream[Q, T, E](self: &Self, subject: &Stream.Kind[Q, T, E], request: Q, context: Context.Context, sink: Stream.Sink[T]) -> Messaging.Outcome[(), E] {32    Mediator.streamWith(self, subject, request, context, sink)33  }34}35