mu-rpc-0.2.0.0: Protocol-independent declaration of services and servers.

Safe HaskellNone
LanguageHaskell2010

Mu.Rpc

Description

This module defines a type-level language to describe RPC-like microservices independently of the transport and protocol.

Synopsis

Documentation

type Service' = Service Symbol Symbol Source #

Services whose names are given by type-level strings.

data Service serviceName methodName Source #

A service is a set of methods.

Constructors

Service serviceName [ServiceAnnotation] [Method methodName] 

type ServiceAnnotation = Type Source #

Annotations for services. At this moment, such annotations can be of any type.

data Package (s :: Symbol) Source #

An annotation to define a package name. This is used by some handlers, like gRPC.

type family FindPackageName (anns :: [ServiceAnnotation]) :: Symbol where ... Source #

Find the Package for a service, to be found as part of the annotations.

Equations

FindPackageName '[] = TypeError (Text "Cannot find package name for the service") 
FindPackageName (Package s ': rest) = s 
FindPackageName (other ': rest) = FindPackageName rest 

data Method methodName Source #

A method is defined by its name, arguments, and return type.

Constructors

Method methodName [ServiceAnnotation] [Argument] Return 

type family (s :: Service snm mnm) :-->: (m :: mnm) :: Method mnm where ... Source #

Look up a method in a service definition using its name. Useful to declare handlers like HandlerIO (MyService :-->: MyMethod).

Equations

(Service sname anns methods) :-->: m = LookupMethod methods m 

data TypeRef where Source #

Defines how to handle the type

Constructors

ViaSchema :: Schema typeName fieldName -> typeName -> TypeRef 
ViaRegistry :: Registry -> Type -> Nat -> TypeRef

Registry subject, type to convert to, and preferred serialization version

ViaTH :: Type -> TypeRef

To be used only during TH generation!

data Argument where Source #

Defines the way in which arguments are handled.

Constructors

ArgSingle :: TypeRef -> Argument

Use a single value.

ArgStream :: TypeRef -> Argument

Consume a stream of values.

data Return where Source #

Defines the different possibilities for returning information from a method.

Constructors

RetNothing :: Return

Fire and forget.

RetSingle :: TypeRef -> Return

Return a single value.

RetThrows :: TypeRef -> TypeRef -> Return

Return a value or an error (this can be found in Avro IDL).

RetStream :: TypeRef -> Return

Return a stream of values (this can be found in gRPC).