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 ¶
- type Router
- type SchemaResolver
- type StoreHandler
- func (h *StoreHandler) HandlePing(ctx context.Context, msg types.FederationMessage) (types.FederationMessage, error)
- func (h *StoreHandler) HandleQuery(ctx context.Context, msg types.FederationMessage) (types.FederationMessage, error)
- func (h *StoreHandler) HandleWrite(ctx context.Context, msg types.FederationMessage) (types.FederationMessage, error)
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 (*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 ¶
func (r *Router) Route(ctx context.Context, msg types.FederationMessage) (types.FederationMessage, error)
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 ¶
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 ¶
NewStoreHandler returns a handler bound to a peer's DID and Store.
func (*StoreHandler) HandlePing ¶
func (h *StoreHandler) HandlePing(ctx context.Context, msg types.FederationMessage) (types.FederationMessage, error)
HandlePing returns a Response echo with a small status payload.
func (*StoreHandler) HandleQuery ¶
func (h *StoreHandler) HandleQuery(ctx context.Context, msg types.FederationMessage) (types.FederationMessage, error)
HandleQuery dispatches read operations.
func (*StoreHandler) HandleWrite ¶
func (h *StoreHandler) HandleWrite(ctx context.Context, msg types.FederationMessage) (types.FederationMessage, error)
HandleWrite dispatches mutation operations.