wip: refactoring

This commit is contained in:
adamdottv
2025-05-12 08:43:34 -05:00
parent f100777199
commit ed9fba99c9
13 changed files with 1342 additions and 931 deletions

View File

@@ -2,27 +2,23 @@ package pubsub
import "context"
type EventType string
const (
CreatedEvent EventType = "created"
UpdatedEvent EventType = "updated"
DeletedEvent EventType = "deleted"
EventTypeCreated EventType = "created"
EventTypeUpdated EventType = "updated"
EventTypeDeleted EventType = "deleted"
)
type Suscriber[T any] interface {
Subscribe(context.Context) <-chan Event[T]
type Event[T any] struct {
Type EventType
Payload T
}
type (
// EventType identifies the type of event
EventType string
type Subscriber[T any] interface {
Subscribe(ctx context.Context) <-chan Event[T]
}
// 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)
}
)
type Publisher[T any] interface {
Publish(eventType EventType, payload T)
}