work towards decoupling api from router

This commit is contained in:
Joel Wetzell
2026-05-06 17:16:45 -05:00
parent 427d69d443
commit 984cb435d5
15 changed files with 336 additions and 267 deletions

26
internal/common/events.go Normal file
View File

@@ -0,0 +1,26 @@
package common
import (
"encoding/json"
)
type Event struct {
Type string `json:"type"`
Data any `json:"data,omitempty"`
Error string `json:"error,omitempty"`
}
func (e Event) ToJSON() ([]byte, error) {
return json.Marshal(e)
}
type EventDestination interface {
Send(event Event) error
Is(dest EventDestination) bool
}
type EventRouter interface {
HandleEvent(event Event, source EventDestination)
AddEventDestination(dest EventDestination)
RemoveEventDestination(dest EventDestination)
}