decl

package
v0.6.125 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 24, 2026 License: MIT Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

View Source
var ServiceName = regexp.MustCompile(`^[a-z][a-z0-9-]*$`)

ServiceName is the form of a service name (§17): it becomes a DNS label, a NATS subject token and a Temporal task queue.

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 CheckService added in v0.6.65

func CheckService(kind, service string)

CheckService panics unless service matches ServiceName.

func Decode

func Decode(data []byte, v any) error

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 DecodeActivity added in v0.6.124

func DecodeActivity(ctx context.Context, e *env.Env, name string, raw []byte, out any) error

DecodeActivity checks raw input before a typed handler can lose fields. Only an actual decoding failure is marked final here.

func Encode

func Encode(v any) ([]byte, error)

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 Env

func Env(scope any, what string) (*env.Env, *node.Node)

Env returns the service env and node of scope; a zero scope panics.

func Schema

func Schema[T any](scope deps.Scope, service, name string) *sp.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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL