
Open.pudu
Pudu48 lines2.3 KB
1/** @Mediator.Open.Seam — components that apply to every kind of message */2module PuduLangMediator.Open34import PuduLangMediator.Context as Context5import PuduLangMediator.Message as Message6import PuduLangMediator as Messaging7import PuduLangMediator.Request as Request8import PuduLangMediator.Stream as Stream910/** @Mediator.Open.Behavior — wraps the pipeline of every request */11export trait Behavior {12 13 fn handleRequest[Q, R, E](self: &Self, request: &Q, info: &Message.Info, context: Context.Context, next: Request.Next[R, E]) -> Messaging.Outcome[R, E]14}1516/** @Mediator.Open.PreProcessor — runs before the handler of every request */17export trait PreProcessor {18 19 fn beforeRequest[Q, E](self: &Self, request: &Q, info: &Message.Info, context: Context.Context) -> Messaging.Outcome[(), E]20}2122/** @Mediator.Open.PostProcessor — runs after the handler of every request */23export trait PostProcessor {24 25 fn afterRequest[Q, R, E](self: &Self, request: &Q, response: &R, info: &Message.Info, context: Context.Context) -> Messaging.Outcome[(), E]26}2728/** @Mediator.Open.ExceptionAction — observes the failure of every request */29export trait ExceptionAction {30 31 fn onFailure[Q, E](self: &Self, request: &Q, failure: &Messaging.Failure[E], info: &Message.Info, context: Context.Context) -> ()32}3334/** @Mediator.Open.NotificationHandler — receives every notification */35export trait NotificationHandler {36 37 fn handleNotification[N, E](self: &Self, notification: &N, info: &Message.Info, context: Context.Context) -> Messaging.Outcome[(), E]38}3940/** @Mediator.Open.StreamBehavior — wraps the pipeline of every stream */41export trait StreamBehavior {42 43 fn handleStream[Q, T, E](self: &Self, request: &Q, info: &Message.Info, context: Context.Context, sink: Stream.Sink[T], next: Stream.Next[T, E]) -> Messaging.Outcome[(), E]44}4546/** @Mediator.Open.Listener — an open notification handler and the name it is reported by */47export type Listener = { name: Str, handler: dynamic NotificationHandler }48