contract

package
v1.3.2 Latest Latest
Warning

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

Go to latest
Published: May 22, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package contract defines Hookr host-side primitives for schema-driven plugin contracts.

This package is intended for generated code and runtime validation metadata for schema-driven FlatBuffers contracts.

Index

Constants

View Source
const (
	ABIVersionMajor = shared.ABIVersionMajor
	ABIVersionMinor = shared.ABIVersionMinor
	SchemaHashLen   = shared.SchemaHashLen
)

Variables

View Source
var (
	ErrIncompatibleABIMajor = shared.ErrIncompatibleABIMajor
	ErrIncompatibleABIMinor = shared.ErrIncompatibleABIMinor
	ErrSchemaHashMismatch   = shared.ErrSchemaHashMismatch
	ErrCapabilityMismatch   = shared.ErrCapabilityMismatch
)
View Source
var (
	ErrMethodHandlerMissing = errors.New("method handler cannot be nil")
	ErrMethodNotFound       = errors.New("method not found")
)
View Source
var (
	ErrContractNameEmpty    = shared.ErrContractNameEmpty
	ErrContractHashEmpty    = shared.ErrContractHashEmpty
	ErrMethodIDDuplicate    = shared.ErrMethodIDDuplicate
	ErrMethodNameDuplicate  = shared.ErrMethodNameDuplicate
	ErrMethodNameEmpty      = shared.ErrMethodNameEmpty
	ErrMethodRequestMissing = shared.ErrMethodRequestMissing
	ErrMethodReplyMissing   = shared.ErrMethodReplyMissing
)

Functions

func ParseSchemaHashHex

func ParseSchemaHashHex(s string) ([SchemaHashLen]byte, error)

func ValidateHandshake

func ValidateHandshake(host, plugin Handshake) error

Types

type Handler

type Handler func(ctx context.Context, payload []byte) ([]byte, error)

Handler is the low-level runtime call shape used by generated wrappers.

type Handshake

type Handshake = shared.Handshake

func NewHandshake

func NewHandshake(schemaHash [SchemaHashLen]byte) Handshake

type HostMethod

type HostMethod struct {
	ID      MethodID
	Name    string
	Handler Handler
}

HostMethod maps a generated method ID/name to an implementation.

type HostRegistry

type HostRegistry struct {
	// contains filtered or unexported fields
}

HostRegistry dispatches host callbacks by method ID.

func NewHostRegistry

func NewHostRegistry(methods ...HostMethod) (*HostRegistry, error)

func (*HostRegistry) Call

func (r *HostRegistry) Call(ctx context.Context, id MethodID, payload []byte) ([]byte, error)

func (*HostRegistry) MethodID

func (r *HostRegistry) MethodID(name string) (MethodID, bool)

type Method

type Method = shared.Method

type MethodID

type MethodID = shared.MethodID

type Schema

type Schema = shared.Schema

Jump to

Keyboard shortcuts

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