Help us shape the future of Go! Take the 2026 Go Developer Survey

mailbox

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxMessageBytes is the protocol-wide decoded text ceiling.
	MaxMessageBytes = 1 << 20
	// MaxInboxOutputBytes bounds the encoded structured result of list_messages.
	// It admits one maximally escaped protocol message plus fixed metadata.
	MaxInboxOutputBytes = 6*MaxMessageBytes + 64*1024
	// MaxMCPOutputBytes adds fixed JSON-RPC and MCP result framing headroom.
	MaxMCPOutputBytes = MaxInboxOutputBytes + 64*1024
)

Variables

View Source
var (
	ErrInvalidInput = errors.New("invalid channel input")
	ErrConflict     = errors.New("identifier conflicts with an existing message")
	ErrBusy         = errors.New("channel is at its concurrency limit")
	ErrRateLimited  = errors.New("channel request budget exhausted")
	ErrClosed       = errors.New("channel service is shutting down")
	ErrUnauthorized = errors.New("message signature or peer identity is invalid")
)

Functions

This section is empty.

Types

type Acknowledgement

type Acknowledgement struct {
	Version               int    `json:"version"`
	MessageID             string `json:"message_id"`
	Source                string `json:"source"`
	Destination           string `json:"destination"`
	EnvelopeSHA256        string `json:"envelope_sha256"`
	ReceivedAt            string `json:"received_at"`
	ReceiverAuditSequence uint64 `json:"receiver_audit_sequence"`
	ReceiverAuditHead     string `json:"receiver_audit_head"`
	Signature             string `json:"signature"`
}

type ConfirmInput

type ConfirmInput struct {
	Acknowledgement Acknowledgement `json:"acknowledgement"`
}

type ConfirmOutput

type ConfirmOutput struct {
	Status        string `json:"status"`
	MessageID     string `json:"message_id"`
	AuditSequence uint64 `json:"audit_sequence"`
	AuditHead     string `json:"audit_head"`
}

type Envelope

type Envelope struct {
	Version             int    `json:"version"`
	MessageID           string `json:"message_id"`
	RequestID           string `json:"request_id"`
	ConversationID      string `json:"conversation_id"`
	Source              string `json:"source"`
	Destination         string `json:"destination"`
	CreatedAt           string `json:"created_at"`
	Body                string `json:"body"`
	BodySHA256          string `json:"body_sha256"`
	PolicyVersion       string `json:"policy_version"`
	GuardModel          string `json:"guard_model"`
	GuardDecision       string `json:"guard_decision"`
	SourceAuditSequence uint64 `json:"source_audit_sequence"`
	SourceAuditHead     string `json:"source_audit_head"`
	Signature           string `json:"signature"`
}

type InboxInput

type InboxInput struct {
	AfterSequence uint64 `json:"after_sequence,omitempty"`
	Limit         int    `json:"limit,omitempty"`
}

type InboxOutput

type InboxOutput struct {
	Messages      []Message `json:"messages"`
	AuditSequence uint64    `json:"audit_sequence"`
	AuditHead     string    `json:"audit_head"`
}

type Message

type Message struct {
	MessageID      string `json:"message_id"`
	ConversationID string `json:"conversation_id"`
	Source         string `json:"source"`
	Destination    string `json:"destination"`
	Body           string `json:"body"`
	BodySHA256     string `json:"body_sha256"`
	ReceivedAt     string `json:"received_at"`
	AuditSequence  uint64 `json:"audit_sequence"`
}

type Options

type Options struct {
	Audit                *audit.Log
	Signer               *identity.Signer
	Peers                map[string]string
	Guard                guard.Evaluator
	Approvals            *approval.Store
	Policy               string
	PolicyVersion        string
	DeploymentSHA256     string
	MaxMessageBytes      int
	Timeout              time.Duration
	MaxMessageAge        time.Duration
	MaxConcurrent        int
	MaxRequestsPerMinute int
	MaxGuardCallsPerHour int
	Now                  func() time.Time
}

type ReceiveInput

type ReceiveInput struct {
	Envelope Envelope `json:"envelope"`
}

type ReceiveOutput

type ReceiveOutput struct {
	Status          string           `json:"status"`
	MessageID       string           `json:"message_id"`
	Decision        string           `json:"decision"`
	ReasonCode      string           `json:"reason_code"`
	Acknowledgement *Acknowledgement `json:"acknowledgement,omitempty"`
	AuditSequence   uint64           `json:"audit_sequence"`
	AuditHead       string           `json:"audit_head"`
}

type SendInput

type SendInput struct {
	Destination    string `json:"destination" jsonschema:"configured peer identity"`
	Text           string `json:"text" jsonschema:"exact text proposed for transfer"`
	RequestID      string `json:"request_id,omitempty" jsonschema:"optional idempotency key"`
	ConversationID string `json:"conversation_id,omitempty" jsonschema:"optional correlation ID"`
}

type SendOutput

type SendOutput struct {
	Status        string    `json:"status"`
	MessageID     string    `json:"message_id"`
	RequestID     string    `json:"request_id"`
	BodySHA256    string    `json:"body_sha256"`
	Decision      string    `json:"decision"`
	ReasonCode    string    `json:"reason_code"`
	Envelope      *Envelope `json:"envelope,omitempty"`
	AuditSequence uint64    `json:"audit_sequence"`
	AuditHead     string    `json:"audit_head"`
}

type Service

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

func New

func New(opts Options) (*Service, error)

func (*Service) Checkpoint

func (s *Service) Checkpoint() (identity.Checkpoint, error)

func (*Service) Confirm

func (s *Service) Confirm(ctx context.Context, input ConfirmInput) (ConfirmOutput, error)

func (*Service) Inbox

func (s *Service) Inbox(_ context.Context, input InboxInput) (InboxOutput, error)

func (*Service) Receive

func (s *Service) Receive(ctx context.Context, input ReceiveInput) (ReceiveOutput, error)

func (*Service) Send

func (s *Service) Send(ctx context.Context, input SendInput) (SendOutput, error)

func (*Service) Shutdown

func (s *Service) Shutdown(ctx context.Context) error

Jump to

Keyboard shortcuts

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