Documentation
¶
Overview ¶
Package routing provides event routing services for the ORLY relay. It dispatches events to specialized handlers based on event kind.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsDeleteKind ¶
IsDeleteKind returns true if the kind is a delete event (kind 5).
Types ¶
type DefaultRouter ¶
type DefaultRouter struct {
// contains filtered or unexported fields
}
DefaultRouter implements Router with a handler registry.
func (*DefaultRouter) HasHandler ¶
func (r *DefaultRouter) HasHandler(kind uint16) bool
HasHandler returns true if a handler is registered for the given kind.
func (*DefaultRouter) Register ¶
func (r *DefaultRouter) Register(kind uint16, handler Handler)
Register adds a handler for a specific kind.
type DeleteProcessor ¶
type DeleteProcessor interface {
// SaveDeleteEvent saves the delete event itself.
SaveDeleteEvent(ctx context.Context, ev *event.E) error
// ProcessDeletion removes the target events.
ProcessDeletion(ctx context.Context, ev *event.E) error
// DeliverEvent sends the delete event to subscribers.
DeliverEvent(ev *event.E)
}
DeleteProcessor handles event deletion operations.
type Handler ¶
Handler processes a specific event kind. authedPubkey is the authenticated pubkey of the connection (may be nil).
func MakeDeleteHandler ¶
func MakeDeleteHandler(processor DeleteProcessor) Handler
MakeDeleteHandler creates a handler for delete events (kind 5). Delete events: - Save the delete event itself first - Process target event deletions - Deliver the delete event to subscribers
type KindCheck ¶
KindCheck tests whether an event kind matches a category (e.g., ephemeral).
type Publisher ¶
type Publisher interface {
// Deliver sends an event to all matching subscribers.
Deliver(ev *event.E)
}
Publisher abstracts event delivery to subscribers.
type Result ¶
type Result struct {
Action Action
Message string // Success or error message
Error error // Error if Action == Error
}
Result contains the routing decision.
func ContinueResult ¶
func ContinueResult() Result
ContinueResult returns a result indicating normal processing should continue.
func ErrorResult ¶
ErrorResult returns a result indicating an error occurred.
type Router ¶
type Router interface {
// Route checks if event should be handled specially.
Route(ev *event.E, authedPubkey []byte) Result
// Register adds a handler for a specific kind.
Register(kind uint16, handler Handler)
// RegisterKindCheck adds a handler for a kind category.
RegisterKindCheck(name string, check func(uint16) bool, handler Handler)
}
Router dispatches events to specialized handlers.
Source Files
¶
- delete.go
- ephemeral.go
- routing.go