opencode/internal/pubsub/events.go
2025-03-23 19:19:08 +01:00

28 lines
482 B
Go

package pubsub
import "context"
const (
CreatedEvent EventType = "created"
UpdatedEvent EventType = "updated"
DeletedEvent EventType = "deleted"
)
type Suscriber[T any] interface {
Subscribe(context.Context) <-chan Event[T]
}
type (
// EventType identifies the type of event
EventType string
// Event represents an event in the lifecycle of a resource
Event[T any] struct {
Type EventType
Payload T
}
Publisher[T any] interface {
Publish(EventType, T)
}
)