InterfaceCodecsMacros

zio.temporal.internal.InterfaceCodecsMacros

Compile-time helpers for auto-registering zio-json codecs from a workflow or activity interface's method signatures.

The macro walks a type I — expected to be a @workflowInterface or @activityInterface — and for every method annotated with @workflowMethod, @signalMethod, @queryMethod, or @activityMethod, summons a ZTemporalCodec[T] for each parameter type and for the return type. If any required codec cannot be summoned, compilation fails with a message pointing at the type that needs one.

The summoned codecs are emitted as runtime registrations into the supplied CodecRegistry. This is what makes CodecRegistry#addInterface[I] work end-to-end: compile-time evidence of codec existence + runtime registration in one call.

The same machinery is used by the ''auto-registration'' path (autoRegisterInterfaceImpl, autoRegisterActivityImplImpl), which is invoked from ZWorker.addWorkflow[I], ZWorker.addActivityImplementation, ZWorkflowClient.newWorkflowStub[A], etc. to remove the need for users to call .addInterface[...] by hand.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def addInterfaceImpl[I : Type](registry: Expr[CodecRegistry])(implicit evidence$1: Type[I], q: Quotes): Expr[CodecRegistry]

Implementation of CodecRegistry#addInterface[I]. Walks I, summons codecs, emits a chained registry.register(...) for each, and returns the (same) registry expression.

Implementation of CodecRegistry#addInterface[I]. Walks I, summons codecs, emits a chained registry.register(...) for each, and returns the (same) registry expression.

Attributes

def autoRegisterActivityImplImpl[A : Type](registryOpt: Expr[Option[CodecRegistry]])(implicit evidence$1: Type[A], q: Quotes): Expr[Unit]

Implementation of the auto-registration call site for an activity ''implementation''. The type parameter A is the concrete implementation class (e.g. MyActivityImpl) — we walk its supertype chain for @activityInterface-annotated interfaces and register each one's codecs.

Implementation of the auto-registration call site for an activity ''implementation''. The type parameter A is the concrete implementation class (e.g. MyActivityImpl) — we walk its supertype chain for @activityInterface-annotated interfaces and register each one's codecs.

Users occasionally declare one impl that implements two activity interfaces; each is walked.

Attributes

def autoRegisterInterfaceImpl[I : Type](registryOpt: Expr[Option[CodecRegistry]])(implicit evidence$1: Type[I], q: Quotes): Expr[Unit]

Implementation of the auto-registration call site for an interface. Emits registryOpt.foreach { r => r.register(codec1); r.register(codec2); ... } at compile time. Opt-out (codecRegistry = None) is a silent no-op because the foreach body is empty.

Implementation of the auto-registration call site for an interface. Emits registryOpt.foreach { r => r.register(codec1); r.register(codec2); ... } at compile time. Opt-out (codecRegistry = None) is a silent no-op because the foreach body is empty.

Accepts either a @workflowInterface-annotated type (common case) ''or'' a workflow ''implementation'' class whose supertypes include a @workflowInterface. Impl classes show up at ZWorker.addWorkflow[Impl].fromClass call sites — the user's Impl satisfies ExtendsWorkflow via ancestry but doesn't carry @workflowMethod annotations directly. We walk its base classes for @workflowInterface- or @activityInterface-annotated ancestors and register each interface's codecs.

Attributes