API reference
The public declarations of @chrismichaelps/pudu-lang-mediator 0.1.0.
PuduLangMediator
Failuretype@Mediator.Root.Failure — why a mediated message produced no value
Outcometype@Mediator.Root.Outcome — the value or failure of one message
Violationtype@Mediator.Root.Violation — one rule a message broke
No failure for none, the failure itself for one, and one flat
Aggregatefor several.One sentence saying what went wrong.
Whether the failure is a cancellation.
The outcome of a handler that answers a plain
Result.An outcome holding the handler's own error.
The handler's own error, when the failure is one.
An outcome refused for
reason; the failure an open component answers, since it cannot nameE.An outcome holding a value.
One line naming an outcome.
Every violation the failure holds, including those inside an aggregate, in order.
PuduLangMediator.Behaviors.Logging
FAILED: StrconstThe event written when a message fails; its properties are the name, elapsed milliseconds, and failure.
HEARD: StrconstThe event written when a notification is heard; its property is the kind's name.
Recordertype@Mediator.Behaviors.Logging.Recorder — writes one event per message start and end
STARTED: StrconstThe event written when a message starts; its properties are the kind's name and shape.
STREAMED: StrconstThe event written when a stream ends; its properties are the name, item count, and elapsed milliseconds.
SUCCEEDED: StrconstThe event written when a message succeeds; its properties are the name and elapsed milliseconds.
A recorder writing to
loggerunder the sourcePuduLangMediator.
PuduLangMediator.Behaviors.Resilient
A behavior running the rest of the pipeline under
pipeline's retry, timeout, circuit, rate,hedging, and fallback policies. Each attempt observes the strategies' token through its
context; a failure of the rest of the pipeline reaches the strategies as
Raised, except acancellation, which stays one.
The resilience behavior of one request kind.
translated: &PuduLangResilience.Failure[PuduLangMediator.Failure[E]] -> PuduLangMediator.Failure[E]fnA resilience failure as a mediator failure: the pipeline's own failure unchanged, a
cancellation or crash as one, and a strategy's rejection refused with its description.
PuduLangMediator.Behaviors.Validation
A behavior answering
Invalidwith every violation whenvalidatorrejects the request, andrunning the rest of the pipeline otherwise.
The validation behavior of one request kind.
The stream validation behavior of one stream kind.
A stream behavior answering
Invalidbefore any item whenvalidatorrejects the request.Every failure of a validation result as a violation, in rule order.
PuduLangMediator.Catalog
Assemblytype@Mediator.Catalog.Assembly — the open components and options every kind is built with
Catalogtype@Mediator.Catalog.Catalog — the registrations of one mediator, by shape and name
Compiledtype@Mediator.Catalog.Compiled — one kind's composed pipeline, typed and untyped
Dispatchtype@Mediator.Catalog.Dispatch — how an envelope of one kind is answered
Entrytype@Mediator.Catalog.Entry — one kind's registrations, counted, before composition
Scopetype@Mediator.Catalog.Scope — which failures exception actions observe
Every entry of a table composed with the catalog's assembly.
A catalog with no registrations, publishing with
publisherand scoping actions byactionScope.The catalog with one more registration of
layerfor the kindname, in order.Every problem with the catalog's registrations, requests first, then notifications, then streams.
The table with
changeapplied to the route of the kindinfonames, counting the handlersand components it adds. A first registration starts from
blank; a registration whose routedoes not read back through
routesbelongs to another kind of the same name and is countedas a collision instead.
PuduLangMediator.Compose
How a notification kind's entry is composed once the catalog is complete.
A notification kind's publication: its own handlers and the open ones in registration order,
run by the assembly's publishing strategy.
How a request kind's entry is composed once the catalog is complete.
A request kind's handler wrapped, outermost first, in its exception layers (actions outside
handlers for
ForUnhandled, inside them forForAll), its pre-processors, itspost-processors, and its behaviors in registration order. A layer with no components is left out.
How a stream kind's entry is composed once the catalog is complete.
A stream kind's handler wrapped in its behaviors, open and its own, in registration order.
PuduLangMediator.Constants.Messages
AGGREGATE: StrconstSeveral failures of one publication;
<1>is their count and<2>their descriptions.CANCELLED: StrconstA cancellation;
<1>is its reason.CRASHED: StrconstA handler that stopped its thread;
<1>is what it said.A request or stream kind with more than one handler;
<1>is its name and<2>the count.EMPTY_NAME: StrconstA kind registered without a name.
INVALID: StrconstA message that failed validation;
<1>is its violations.A mediator refused at build time;
<1>is its problems.MISMATCHED: StrconstA message routed to another kind of the same name;
<1>is the name.NAME_TAKEN: StrconstTwo kinds sharing one name;
<1>is the name.RAISED: StrconstA failure raised by a handler;
<1>is the error.READER_CLOSED: StrconstA stream reader closed before its stream ended.
REFUSED: StrconstA message an open component refused;
<1>is the reason.SEPARATOR: StrconstWhat separates problems and descriptions listed in one sentence.
SUCCEEDED: StrconstAn outcome holding a value;
<1>is the value.UNHANDLED: StrconstA message without a handler;
<1>is its kind's name.VIOLATION: StrconstOne validation violation;
<1>is the property and<2>the message.WITHOUT_HANDLER: StrconstA request or stream kind with components but no handler;
<1>is its name.
PuduLangMediator.Context
Contexttype@Mediator.Context.Context — what one message carries through its pipeline
Keytype@Mediator.Context.Key — a typed name for one item
@Mediator.Context.Key — a typed name for one item
Asks the message holding this context to stop. The first reason given is kept.
A fresh context whose message stops when
tokenfires.Okwhile the token has not fired, andCancelledonce it has, so a handler stops with?.A context with a token that fires only when cancelled, and no items.
The same context with a token that fires when the original's does, after
millis, or whencancelled itself; items stay shared.
The item under a key, when it is present and was stored through the same key.
The item under a key, or
fallbackwhen it is absent.Whether an item is stored under the key's name.
A key whose items read back as
T. Two keys made by separate calls never read each other'sitems, even under one name; make each key once and share it.
The names of every stored item, in the order they were first stored.
Sleeps
millis, or answersCancelledas soon as the token fires.Removes the item under a key.
Stores an item, replacing any item under the same name.
Whether the context's token has fired.
The same context observing another token; items stay shared with the original.
PuduLangMediator.Domain.Census
Censustype@Mediator.Domain.Census.Census — the registrations counted for one kind
Every problem with one kind's registrations: a missing name, a name two kinds share, and, for
a kind that takes exactly one handler, more than one or components without any.
PuduLangMediator.Domain.Order
Layertype@Mediator.Domain.Order.Layer — the kinds of component a pipeline orders
Marktype@Mediator.Domain.Order.Mark — one registration, open or for one kind
Picktype@Mediator.Domain.Order.Pick — a shared open component or the kind's own
The components of one layer that apply to the kind named
name, in registration order: everyopen one by its index among open components, and each of the kind's own by its index among
the kind's own.
PuduLangMediator.Mediator
@Mediator.Mediator.Invalid — every reason a mediator could not be built
Mediatortype@Mediator.Mediator.Mediator — every kind's composed pipeline, by shape and name
Optionstype@Mediator.Mediator.Options — how notifications are published and failures observed
Publishes a notification whose type the caller does not name, with a fresh context.
Publishes a notification whose type the caller does not name, with the given context. A kind
the mediator does not know is answered as heard by nobody.
A mediator of
registrationswith the default options.A mediator of
registrations, applied in order, or every problem found in them: a kind withouta name, two kinds under one name, and a request or stream kind without exactly one handler.
Every item of a stream request, or its failure.
Sequential publishing, and exception actions that observe only failures no exception handler
answered.
Sends a request whose type the caller does not name, with a fresh context.
Sends a request whose type the caller does not name, with the given context. Read the answer
back with the kind's
answerOf.Every problem in one sentence.
Every registered kind: requests, then notifications, then streams, each in registration order.
Publishes a notification to every handler with a fresh context.
Publishes a notification to its handlers and the open ones, through the mediator's publishing
strategy, with the given context. A kind with no handlers succeeds without running anything.
A reader of a stream request produced on its own thread with the given context, holding at
most
capacityitems ahead of the consumer. Close it once done with it.The composed pipeline of a request kind, to call many times without looking it up again;
Unhandledwhen the kind has no handler andMismatchedwhen another kind took its name.Sends a request through its pipeline with a fresh context.
Sends a request through its pipeline with the given context.
Runs a stream request with a fresh context, handing each item to
sinkuntil it declines one.Runs a stream request whose type the caller does not name, handing each packed item to
sinkuntil it declines one. Read items back with the kind's
itemOf, and the answer with itsanswerOf.Runs a stream request with the given context, handing each item to
sinkuntil it declines one.
PuduLangMediator.Message
Answertype@Mediator.Message.Answer — what an envelope's handler answered
Deliverytype@Mediator.Message.Delivery — the outcome of an envelope, why there is none, or no listener
Envelopetype@Mediator.Message.Envelope — a message whose type the sender does not name
Faulttype@Mediator.Message.Fault — why an envelope reached no handler
Infotype@Mediator.Message.Info — the name, shape, and tags of one kind
@Mediator.Message.Info — the name, shape, and tags of one kind
Shapetype@Mediator.Message.Shape — a request with or without a response, a notification, or a stream
The answer holding
outcome, readable back only throughoutcomes.The failure an undelivered envelope answers, for any error type.
Whether the kind carries
tag.The outcome an answer holds, read through
outcomes;Nonewhen another kind answered it ornobody heard it.
The envelope carrying
message, readable back only throughmessages.The shape's name.
The answer of an envelope that reached no handler.
The answer of a notification envelope whose kind has no handler: a publication nobody heard.
PuduLangMediator.Notification
Handlertype@Mediator.Notification.Handler — receives one notification
Kindtype@Mediator.Notification.Kind — the typed identity of one notification
Namedtype@Mediator.Notification.Named — a handler with the name publishers report it by
@Mediator.Notification.Named — a handler with the name publishers report it by
Routetype@Mediator.Notification.Route — every handler registered for one kind
The outcome an answer holds, when this kind answered it; a publication nobody heard succeeded.
An envelope carrying
notification, for a publisher that does not name its type.A kind of notification whose handlers fail with
E. Make each kind once and share it.A route with no handlers.
The same kind carrying
tagsas well, which open components may read.
PuduLangMediator.Open
Behaviortrait@Mediator.Open.Behavior — wraps the pipeline of every request
ExceptionActiontrait@Mediator.Open.ExceptionAction — observes the failure of every request
Listenertype@Mediator.Open.Listener — an open notification handler and the name it is reported by
NotificationHandlertrait@Mediator.Open.NotificationHandler — receives every notification
PostProcessortrait@Mediator.Open.PostProcessor — runs after the handler of every request
PreProcessortrait@Mediator.Open.PreProcessor — runs before the handler of every request
StreamBehaviortrait@Mediator.Open.StreamBehavior — wraps the pipeline of every stream
PuduLangMediator.Publisher
Publishertrait@Mediator.Publisher.Publisher — publishes notifications; a mediator or a test double
PuduLangMediator.Publishing
Boundedtype@Mediator.Publishing.Bounded — every handler, at most
workersat a timeContinuingtype@Mediator.Publishing.Continuing — one handler at a time, every handler, every failure
Executortype@Mediator.Publishing.Executor — one handler, ready to run with a context
Paralleltype@Mediator.Publishing.Parallel — every handler on its own thread at once
Sequentialtype@Mediator.Publishing.Sequential — one handler at a time, stopping at the first failure
Strategytrait@Mediator.Publishing.Strategy — runs the executors of one publication
PuduLangMediator.Reader
Readertype@Mediator.Reader.Reader — the consuming end of a stream produced on its own thread
Steptype@Mediator.Reader.Step — one item, or the end of the stream with its outcome
Stops the producer, discards what it had produced, and waits for its thread to end.
The next item, waiting for the producer when none is ready; the stream's failure once, when
it ended with one; and
Noneafter it ended or the reader was closed.A reader of what
produceemits on a thread of its own, holding at mostcapacityitems(at least one) ahead of the consumer. The producer waits while the reader is full and stops
once the reader is closed or
contextis cancelled.Every item still to come, or the stream's failure.
PuduLangMediator.Registration
Registrationtype@Mediator.Registration.Registration — one change to the catalog a mediator is built from
A behavior around the pipeline of one request kind, ordered among every behavior by registration.
An exception action of one request kind, ordered among every exception action by registration.
An exception handler of one request kind; the kind's exception handlers are tried in registration order.
Several registrations as one, applied in order.
The handler of a request kind. A request kind takes exactly one.
A handler of a notification kind, reported to publishing strategies as
name. A notificationkind takes any number, ordered among every notification handler by registration.
openBehavior: dynamic PuduLangMediator.Open.Behavior -> PuduLangMediator.Registration.RegistrationfnA behavior around the pipeline of every request kind.
An exception action of every request kind.
A handler of every notification kind, reported to publishing strategies as
name. An envelopereaches it only when its kind is registered with the mediator.
A post-processor of every request kind.
A pre-processor of every request kind.
A behavior around the pipeline of every stream kind.
A post-processor of one request kind, ordered among every post-processor by registration.
A pre-processor of one request kind, ordered among every pre-processor by registration.
A behavior around the pipeline of one stream kind, ordered among every stream behavior by registration.
The handler of a stream kind. A stream kind takes exactly one.
PuduLangMediator.Request
Behaviortype@Mediator.Request.Behavior — wraps the rest of the pipeline for one kind
ExceptionActiontype@Mediator.Request.ExceptionAction — observes a failure that keeps propagating
ExceptionHandlertype@Mediator.Request.ExceptionHandler — may answer a value in place of a failure
Handlertype@Mediator.Request.Handler — answers one request
Kindtype@Mediator.Request.Kind — the typed identity of one request
Nexttype@Mediator.Request.Next — the rest of the pipeline, given the context to run it with
PostProcessortype@Mediator.Request.PostProcessor — runs after a handler that answered a value
PreProcessortype@Mediator.Request.PreProcessor — runs before the handler; a failure stops the request
Routetype@Mediator.Request.Route — every component registered for one kind
The outcome an answer holds, when this kind answered it.
A kind of request answering no value.
An envelope carrying
request, for a sender that does not name its type.A kind of request answering
Ror failing withE. Make each kind once and share it: twokinds made by separate calls are different kinds, even under one name.
A route with no components.
The same kind carrying
tagsas well, which open components may read.
PuduLangMediator.Sender
Sendertrait@Mediator.Sender.Sender — sends requests and streams; a mediator or a test double
PuduLangMediator.Stream
Behaviortype@Mediator.Stream.Behavior — wraps the rest of the stream pipeline for one kind
Handlertype@Mediator.Stream.Handler — emits the items of one stream request
Kindtype@Mediator.Stream.Kind — the typed identity of one stream request
Nexttype@Mediator.Stream.Next — the rest of the stream pipeline
Routetype@Mediator.Stream.Route — every component registered for one kind
Sinktype@Mediator.Stream.Sink — takes one item and answers whether it wants another
The outcome an answer holds, when this kind answered it.
Hands each item to the sink in order until it declines one.
An envelope carrying
request, for a sender that does not name its type.An item an untyped stream emitted, when this kind emitted it.
A kind of stream request emitting
Tor failing withE. Make each kind once and share it.A route with no components.
The same kind carrying
tagsas well, which open components may read.
PuduLangMediator.Utils.Erasure
Packedtype@Utils.Erasure.Packed — a value whose type only its slot knows
Slottype@Utils.Erasure.Slot — the one place a packed value of
Treads backThe value packed so that only
targetreads it back.A slot of its own: values packed through it read back only through it.
The value packed through
source, orNonewhen it was packed through another slot.
PuduLangMediator.Utils.Template
The template with each
<n>replaced by thenth value, counting from 1, in one pass: texttaken from a value is never filled again. A slot without a value is kept as written.
PuduLangMediator.Utils.Threads
The message a stopped thread left, or the error itself when it left none.
