Versions in this module Expand all Collapse all v2 v2.0.1 Mar 22, 2026 v2.0.0 Mar 22, 2026 Changes in this version + const NatsDefaultURL + const NoBackLog + const PatternAll + var ErrDecode = errors.New("decode error") + var ErrEncode = errors.New("encode error") + var ErrInternal = errors.New("internal error") + var ErrOperation = errors.New("operation error") + var ErrTransport = errors.New("transport error") + var ErrValidation = errors.New("validation error") + func Decode(rawResp *Message, into any) error + func EncodeMimetype(payload any, mimeType string) ([]byte, error) + func NatsConnect(url string, options ...NatsOption) (*nats.Conn, error) + func NatsDefaultServerOptions() *server.Options + func NatsEmbeddedServer(opts *server.Options, startTimeout time.Duration) (*server.Server, error) + func NewInbox() string + type AnyServerHandler interface + HandleMessage func(ctx context.Context, msg *Message) error + type Bus interface + Publish func(msg *Message) error + QueueSubscribe func(subject string, queue string, backlog int) (Subscription, error) + Request func(ctx context.Context, msg *Message) (*Message, error) + Subscribe func(subject string, backlog int) (Subscription, error) + type Header = http.Header + type LatticeRequest struct + Bus Bus + PostRequest func(context.Context, *Y, *Message) error + PreRequest func(context.Context, T, *Message) error + Request T + Response Y + Subject string + func NewLatticeRequest[T any, Y any](bus Bus, subject string, in T, out Y) *LatticeRequest[T, Y] + func (l *LatticeRequest[T, Y]) Execute(ctx context.Context) (*Y, error) + type Message struct + Data []byte + Header Header + Reply string + Subject string + func Encode(subject string, payload any) (*Message, error) + func NewMessage(subject string) *Message + func (m *Message) Bus() Bus + func (m *Message) LastSubjectPart() string + func (m *Message) SubjectParts() []string + type NatsBus struct + func NewNatsBus(nc *nats.Conn) *NatsBus + func (c *NatsBus) Publish(msg *Message) error + func (c *NatsBus) QueueSubscribe(subject string, queue string, backlog int) (Subscription, error) + func (c *NatsBus) Request(ctx context.Context, msg *Message) (*Message, error) + func (c *NatsBus) Subscribe(subject string, backlog int) (Subscription, error) + type NatsOption = nats.Option + type NatsSubscription struct + func (s *NatsSubscription) Drain() error + func (s *NatsSubscription) Handle(callback SubscriptionCallback) + type RequestHandler struct + Handler func(context.Context, *T) (*Y, error) + PostRequest func(context.Context, *Y, *Message) error + PreRequest func(context.Context, *T, *Message) error + Request T + Response Y + func NewRequestHandler[T any, Y any](req T, resp Y, handler func(context.Context, *T) (*Y, error)) *RequestHandler[T, Y] + func (s *RequestHandler[T, Y]) HandleMessage(ctx context.Context, msg *Message) error + type Server struct + ContextFunc func() context.Context + Lattice string + func NewServer(bus Bus, lattice string) *Server + func (s *Server) Drain() error + func (s *Server) ErrorStream() <-chan *ServerError + func (s *Server) RegisterHandler(subject string, handler AnyServerHandler) error + type ServerError struct + Context context.Context + Err error + Request *Message + type ServerHandlerFunc func(context.Context, *Message) error + func (f ServerHandlerFunc) HandleMessage(ctx context.Context, msg *Message) error + type Subscription interface + Drain func() error + Handle func(callback SubscriptionCallback) + type SubscriptionCallback func(msg *Message) Other modules containing this package go.wasmcloud.dev/runtime-operator