mirror of
https://github.com/sst/opencode.git
synced 2025-07-07 16:14:59 +00:00
24 lines
411 B
Go
24 lines
411 B
Go
package pubsub
|
|
|
|
import "context"
|
|
|
|
type EventType string
|
|
|
|
const (
|
|
EventTypeCreated EventType = "created"
|
|
EventTypeUpdated EventType = "updated"
|
|
EventTypeDeleted EventType = "deleted"
|
|
)
|
|
|
|
type Event[T any] struct {
|
|
Type EventType
|
|
Payload T
|
|
}
|
|
|
|
type Subscriber[T any] interface {
|
|
Subscribe(ctx context.Context) <-chan Event[T]
|
|
}
|
|
|
|
type Publisher[T any] interface {
|
|
Publish(eventType EventType, payload T)
|
|
}
|