Service

smithy4s.Service
See theService companion object
trait Service[Alg[_[_, _, _, _, _]]] extends FunctorK5[Alg], HasId

Generic representation of a service, as a list of "endpoints" (mapping to smithy operations).

This abstraction lets us retrieve all information necessary to the generic implementation of protocols, as well as transform implementations of finally-encoded interfaces into interpreters (polymorphic functions) that operate on initially-encoded GADTs.

Type parameters

Alg:

a finally-encoded interface (commonly called algebra) that works against an abstract "effect" that takes 5 type parameters: Input, Error, Output, StreamedInput, StreamedOutput

Op:

an initially encoded version of the finally-encoded interface. Typically, a GADT that acts as a reification of the operations. Passing the reified versions around makes it drastically easier to implement logic generically, without involving metaprogramming.

Attributes

Companion
object
Graph
Supertypes
trait HasId
trait FunctorK5[Alg]
class Object
trait Matchable
class Any
Known subtypes
trait Mixin[Alg, Op]
trait Reflective[Op]

Members list

Type members

Types

A EndpointCompiler specialised for effects of kind * -> (*, *), like Either or bifunctor IO

A EndpointCompiler specialised for effects of kind * -> (*, *), like Either or bifunctor IO

Attributes

type BiFunctorInterpreter[F[_, _]] = Interpreter[<none>]

An interpreter specialised for effects of kind * -> (*, *), like Either or bifunctor IO.

An interpreter specialised for effects of kind * -> (*, *), like Either or bifunctor IO.

Attributes

type Endpoint[I, E, O, SI, SO] = Endpoint[Operation, I, E, O, SI, SO]

An endpoint is the set of schemas tied to types associated with an Operation. It has a method to wrap the input in an operation instance I => Operation[I, E, O, SI, SO].

An endpoint is the set of schemas tied to types associated with an Operation. It has a method to wrap the input in an operation instance I => Operation[I, E, O, SI, SO].

You can think of the endpoint as a "template for an Operation". It contains everything needed to decode/encode operation calls to/from low-level representations (like http requests).

Attributes

type EndpointCompiler[F[_, _, _, _, _]] = PolyFunction5[Endpoint, <none>]

A polymorphic function that can take an Endpoint (associated to this service) and produces an handler for it, namely a function that takes the input type of the operation, and produces an effect.

A polymorphic function that can take an Endpoint (associated to this service) and produces an handler for it, namely a function that takes the input type of the operation, and produces an effect.

Attributes

type ErrorAware[F[_, _]] = BiFunctorAlgebra[Alg, F]

A short-hand for algebras that are specialised for effects of kind * -> (*, *). This is meant to be used in userland, e.g:

A short-hand for algebras that are specialised for effects of kind * -> (*, *). This is meant to be used in userland, e.g:

 val myService = MyService.ErrorAware[Either] 

Attributes

A EndpointCompiler specialised for effects of kind * -> *, like Try or monofunctor IO

A EndpointCompiler specialised for effects of kind * -> *, like Try or monofunctor IO

Attributes

type FunctorInterpreter[F[_]] = Interpreter[<none>]

An interpreter specialised for effects of kind * -> *, like Try or monofunctor IO.

An interpreter specialised for effects of kind * -> *, like Try or monofunctor IO.

Attributes

type Impl[F[_]] = FunctorAlgebra[Alg, F]

A short-hand for algebras that are specialised for effects of kind * -> *.

A short-hand for algebras that are specialised for effects of kind * -> *.

NB: this alias should be used in polymorphic implementations. When using the Smithy4s code generator, equivalent aliases that are named after the service are generated (e.g. Weather corresponding to WeatherGen).

Attributes

type Interpreter[F[_, _, _, _, _]] = PolyFunction5[Operation, F]

This is a polymorphic function that runs an instance of an operation and produces an effect F.

This is a polymorphic function that runs an instance of an operation and produces an effect F.

Attributes

type Operation[I, E, O, SI, SO]

A datatype (typically a sealed trait) that reifies an operation call within a service. It essentially captures the input and type indexes that the operation deals with. It also typically captures an input value.

A datatype (typically a sealed trait) that reifies an operation call within a service. It essentially captures the input and type indexes that the operation deals with. It also typically captures an input value.

It is possible to think of Operation as an "applied Endpoint", or a "call to an Endpoint".

Type parameters

E:

the error type associated to the operation (typically represented as a sealed-trait)

I:

the input of the operation

O:

the output of the operation

SI:

the streamed input of an operation. Operations can have unary components and streamed components. For instance, an http call can send headers (unary I) and a stream of bytes (streamed SI) to the server.

SO:

the streamed output of the operation.

Attributes

Value members

Abstract methods

def endpoints: IndexedSeq[Endpoint[Operation, _, _, _, _, _]]
def fromPolyFunction[P[_, _, _, _, _]](function: PolyFunction5[Operation, P]): Alg[P]
def hints: Hints
def input[I, E, O, SI, SO](op: Operation[I, E, O, SI, SO]): I
def ordinal[I, E, O, SI, SO](op: Operation[I, E, O, SI, SO]): Int
def reified: Alg[Operation]
def toPolyFunction[P[_, _, _, _, _]](algebra: Alg[P]): PolyFunction5[Operation, P]

Concrete methods

final def algebra[F[_, _, _, _, _]](compiler: EndpointCompiler[F]): Alg[F]

A function that takes an endpoint compiler and produces an Algebra (typically an instance of the generated interfaces), backed by an interpreter.

A function that takes an endpoint compiler and produces an Algebra (typically an instance of the generated interfaces), backed by an interpreter.

This is useful for writing generic functions that result in the instantiation of a client instance that abides by the service interface.

Attributes

A bifunctor-specialised version of interpreter

A bifunctor-specialised version of interpreter

Attributes

def endpoint[I, E, O, SI, SO](op: Operation[I, E, O, SI, SO]): Endpoint[I, E, O, SI, SO]
final def errorAware[F[_, _]](compiler: BiFunctorEndpointCompiler[F]): ErrorAware[F]

A monofunctor-specialised version of algebra

A monofunctor-specialised version of algebra

Attributes

A monofunctor-specialised version of interpreter

A monofunctor-specialised version of interpreter

Attributes

final def impl[F[_]](compiler: FunctorEndpointCompiler[F]): Impl[F]

A monofunctor-specialised version of algebra

A monofunctor-specialised version of algebra

Attributes

final def interpreter[F[_, _, _, _, _]](compiler: EndpointCompiler[F]): Interpreter[F]

Given a generic way to turn an endpoint into some handling function (like I => F[I, E, O, SI, SO]), this method takes care of the logic necessary to produce an interpreter that takes an Operation associated to the service and routes it to the correct function, returning the result.

Given a generic way to turn an endpoint into some handling function (like I => F[I, E, O, SI, SO]), this method takes care of the logic necessary to produce an interpreter that takes an Operation associated to the service and routes it to the correct function, returning the result.

Attributes

Inherited methods

def id: ShapeId

Attributes

Inherited from:
HasId
def mapK5[F[_, _, _, _, _], G[_, _, _, _, _]](alg: Alg[F], function: PolyFunction5[F, G]): Alg[G]

Attributes

Inherited from:
FunctorK5

Concrete fields

val service: Service[Alg]