1
0
mirror of https://github.com/MontFerret/ferret.git synced 2025-09-16 09:06:36 +02:00
Files
ferret/pkg/runtime/events/observable.go
Tim Voronov d201b50c20 Updated dependencies (#769)
* Updated dependencies

* Dropped pre-generics versions of Go

* Updated ANTRL

* Added staticcheck and goimports tools

* Updated build steps

* Fixed unit tests for http funcs
2023-02-07 12:58:43 -05:00

36 lines
842 B
Go

package events
import (
"context"
"github.com/MontFerret/ferret/pkg/runtime/core"
"github.com/MontFerret/ferret/pkg/runtime/values"
)
type (
// Subscription represents an event subscription object that contains target event name
// and optional event options.
Subscription struct {
EventName string
Options *values.Object
}
// Message represents an event message that an Observable can emit.
Message interface {
Value() core.Value
Err() error
}
// Stream represents an event stream that produces target event objects.
Stream interface {
Close(ctx context.Context) error
Read(ctx context.Context) <-chan Message
}
// Observable represents an interface of
// complex types that returns stream of events.
Observable interface {
Subscribe(ctx context.Context, subscription Subscription) (Stream, error)
}
)