Refactored the scheduler and source interfaces to accommondate both polling (e.g., HTTP) sources and streaming (e.g., message queue) sources.
This commit is contained in:
@@ -6,6 +6,12 @@ import (
|
||||
"gitea.maximumdirect.net/ejr/feedkit/event"
|
||||
)
|
||||
|
||||
// Input is the common surface shared by all source types.
|
||||
type Input interface {
|
||||
Name() string
|
||||
Kind() event.Kind
|
||||
}
|
||||
|
||||
// Source is a configured polling job that emits 0..N events per poll.
|
||||
//
|
||||
// Source implementations live in domain modules (weatherfeeder/newsfeeder/...)
|
||||
@@ -28,3 +34,12 @@ type Source interface {
|
||||
// Implementations should honor ctx.Done() for network calls and other I/O.
|
||||
Poll(ctx context.Context) ([]event.Event, error)
|
||||
}
|
||||
|
||||
// StreamSource is an event-driven source (NATS/RabbitMQ/MQTT/etc).
|
||||
//
|
||||
// Run should block, producing events into `out` until ctx is cancelled or a fatal error occurs.
|
||||
// It MUST NOT close out (the scheduler/daemon owns the bus).
|
||||
type StreamSource interface {
|
||||
Input
|
||||
Run(ctx context.Context, out chan<- event.Event) error
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user