mirror of
https://github.com/sst/opencode.git
synced 2025-08-04 13:30:52 +00:00
28 lines
482 B
Go
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)
|
|
}
|
|
)
|