federation

package
v0.1.2 Latest Latest
Warning

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

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

Documentation

Overview

Package federation implements Coggo's cross-peer messaging primitive. In v0.1 the transport is in-process function calls; the protocol shape is the same as the network transport that arrives in v0.4.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Router

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

Router is the in-process implementation of types.Router.

func New

func New() *Router

New returns an empty router.

func (*Router) ListPeers

func (r *Router) ListPeers() []string

ListPeers returns registered peer DIDs in deterministic order.

func (*Router) RegisterPeer

func (r *Router) RegisterPeer(did string, h types.PeerHandler) error

RegisterPeer wires a handler under the given DID. Returns an error if the DID is already registered.

func (*Router) Route

Route dispatches a federation message to its TargetDID's handler. On lookup failure or handler error, returns a FedMsgError reply (and the error).

type SchemaResolver

type SchemaResolver interface {
	EntityType(peerDID, name string) (*types.EntityTypeDefinition, error)
	RelationType(peerDID, name string) (*types.RelationshipTypeDefinition, error)
}

SchemaResolver is the minimum surface StoreHandler needs from a schema registry. internal/schema.Resolver satisfies it.

type StoreHandler

type StoreHandler struct {
	PeerDID  string
	Store    types.Store
	Resolver *schema.Resolver
}

StoreHandler implements types.PeerHandler by translating federation messages into Store operations.

Every write path appends an Event before mutating the projection so the event log is the durable source of truth and time travel can rebuild state from it.

func NewStoreHandler

func NewStoreHandler(peerDID string, store types.Store, resolver *schema.Resolver) *StoreHandler

NewStoreHandler returns a handler bound to a peer's DID and Store.

func (*StoreHandler) HandlePing

HandlePing returns a Response echo with a small status payload.

func (*StoreHandler) HandleQuery

HandleQuery dispatches read operations.

func (*StoreHandler) HandleWrite

HandleWrite dispatches mutation operations.

Jump to

Keyboard shortcuts

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