Documentation
¶
Overview ¶
Package decl is shared by the hook, activity and event packages: it resolves the service a Scope belongs to, derives payload schemas and encodes payloads.
Index ¶
- func Activity[Req, Res any](scope deps.Scope, name string, kind backplanev1.ActivityKind, ...) *env.Env
- func ActivitySchema(scope deps.Scope, name string, kind backplanev1.ActivityKind, ...) *env.Env
- func CheckName(kind, name string)
- func Decode(data []byte, v any) error
- func Encode(v any) ([]byte, error)
- func Env(scope any, what string) (*env.Env, *node.Node)
- func Schema[T any](scope deps.Scope, service, name string) *sp.Schema
- type ActivityOption
- type ActivityOptionFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Activity ¶
func Activity[Req, Res any]( scope deps.Scope, name string, kind backplanev1.ActivityKind, opts []ActivityOption, ) *env.Env
Activity records the activity in the manifest with the schemas of Req and Res.
func ActivitySchema ¶ added in v0.6.2
func ActivitySchema( scope deps.Scope, name string, kind backplanev1.ActivityKind, in, out *sp.Schema, opts []ActivityOption, ) *env.Env
ActivitySchema records the activity in the manifest with schemas known at run time; nil is no schema (plain JSON).
func CheckName ¶
func CheckName(kind, name string)
CheckName panics unless name is CamelCase — [A-Z][A-Za-z0-9]* — the form of hook, activity and workflow names: they are Temporal type and Nexus operation names and read as <service>.<Name> everywhere.
func Decode ¶
Decode is the inverse of Encode. Fields the payload has and v does not are ignored on both paths: a producer may add fields before its consumers know them (payloads evolve additively; a renamed field is a new field). v may point to a nil proto message pointer (a Ref[*pb.X]): the message is allocated.
func Encode ¶
Encode is protojson for proto messages, encoding/json otherwise. Proto fields keep their proto names, the names a binding reads in the .proto, and are written when unset too (a oneof's unset members aside), as a Go struct's are: a binding reads a zero count as 0, not as a missing key.
func Schema ¶
Schema is T's schema under <service>/<name>@1.0.0, as Encode writes T: a proto message's from its descriptor (protoSchema), any other type reflected by schemapb. A type that cannot be described (an unsupported field, a malformed schemapb tag) leaves the payload plain JSON: the console shows no form for it, so the author is told on scope's log.
Types ¶
type ActivityOption ¶
type ActivityOption interface {
// contains filtered or unexported methods
}
ActivityOption records transport-neutral operation metadata.
type ActivityOptionFunc ¶
type ActivityOptionFunc func(*backplanev1.Activity)
ActivityOptionFunc is the internal option constructor.