ProtocolStack

zio.http.ProtocolStack
See theProtocolStack companion object
sealed trait ProtocolStack[-Env, -IncomingIn, +IncomingOut, -OutgoingIn, +OutgoingOut]

A zio.http.ProtocolStack represents a linear stack of protocol layers, each of which can statefully transform incoming and outgoing values of some handler.

Protocol stacks can be thought of as a formal model of the process of transforming one handler into another handler.

Protocol stacks are designed to support precise semantics around error handling. In particular, if a layer successfully processes an incoming value of a handler, then that same layer will also have a chance to process the outgoing value of the handler. This requirement constrains the ways in which layers can fail, and the types of handlers they may be applied to.

In particular, protocol stacks can be applied to handlers that fail with the same type as their output type. This guarantees that should a handler fail, it will still produce an outgoing value that can be processed by all the layers that successfully transformed the incoming value.

Further, a layer may only fail while it processes an incoming value, and it may only value with the same type as its outgoing value. This guarantees that should a layer fail, it will still produce an outgoing value that can be processed by all the earlier layers that successfully transformed the incoming value.

In a way, the entire design of protocol stacks is geared at ensuring layers that successfully process incoming values will also have a chance to process outgoing values.

The only composition operator on protocol stacks is ++, which simply chains two stacks together. This operator is associative and has an identity (which is the protocol stack that neither transforms incoming nor outgoing values, and which acts as an identity when used to transform handlers).

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
ProtocolStack[Env, IncomingIn, IncomingOut, OutgoingIn, OutgoingOut]

Members list

Type members

Types

type State

Value members

Concrete methods

final def ++[Env1 <: Env, MiddleIncoming, MiddleOutgoing](that: ProtocolStack[Env1, IncomingOut, MiddleIncoming, MiddleOutgoing, OutgoingIn]): ProtocolStack[Env1, IncomingIn, MiddleIncoming, MiddleOutgoing, OutgoingOut]
final def apply[Env1 <: Env, Err >: OutgoingOut, IncomingOut1 >: IncomingOut, OutgoingIn1 <: OutgoingIn](handler: Handler[Env1, Err, IncomingOut1, OutgoingIn1])(implicit trace: Trace): Handler[Env1, Err, IncomingIn, OutgoingOut]
def mapIncoming[IncomingOut2](f: IncomingOut => IncomingOut2): ProtocolStack[Env, IncomingIn, IncomingOut2, OutgoingIn, OutgoingOut]
def mapOutgoing[OutgoingOut2](f: OutgoingOut => OutgoingOut2): ProtocolStack[Env, IncomingIn, IncomingOut, OutgoingIn, OutgoingOut2]
def provideEnvironment(env: ZEnvironment[Env])(implicit trace: Trace): ProtocolStack[Any, IncomingIn, IncomingOut, OutgoingIn, OutgoingOut]

Concrete fields

lazy val incomingHandler: Handler[Env, OutgoingOut, IncomingIn, (State, IncomingOut)]
lazy val outgoingHandler: Handler[Env, Nothing, (State, OutgoingIn), OutgoingOut]