Documentation ¶
Overview ¶
Package pubsub provides cluster-wide publishing and subscribing of events
Index ¶
- Variables
- func WriteSSEEvent(w io.Writer, data []byte, event EventType, base64encode bool)
- type Broker
- func (b *Broker) Publish(event Event)
- func (r Broker) Register(table string, getter Getter)
- func (r Broker) RegisterFunc(table string, getter GetterFunc)
- func (b *Broker) Start(ctx context.Context) error
- func (b *Broker) Started() <-chan struct{}
- func (b *Broker) Subscribe(ctx context.Context, prefix string) (<-chan Event, error)
- type DBAction
- type Event
- type EventType
- type FakePublisher
- type Getter
- type GetterFunc
- type PubSubService
- type Publisher
- type Subscriber
- type Table
Constants ¶
This section is empty.
Variables ¶
var ErrSubscriptionTerminated = errors.New("broker terminated the subscription")
ErrSubscriptionTerminated is for use by subscribers to indicate that their subscription has been terminated by the broker.
Functions ¶
Types ¶
type Broker ¶
Broker is a pubsub Broker implemented using postgres' listen/notify
func (Broker) Register ¶
Register a table and getter with the pubsub broker, to enable the broker to convert a database event into an OTF event.
func (Broker) RegisterFunc ¶ added in v0.0.53
func (r Broker) RegisterFunc(table string, getter GetterFunc)
Register a table and getter function with the pubsub broker, to enable the broker to convert a database event into an OTF event.
type Event ¶
type Event struct { Type EventType Payload any Local bool // for local node only and not to be published to rest of cluster }
Event represents an event in the lifecycle of an otf resource
func NewCreatedEvent ¶
func NewDeletedEvent ¶
func NewUpdatedEvent ¶
type EventType ¶
type EventType string
EventType identifies the type of event
const ( EventError EventType = "error" EventInfo EventType = "info" EventLogChunk EventType = "log_update" EventLogFinished EventType = "log_finished" EventVCS EventType = "vcs_event" CreatedEvent EventType = "created" UpdatedEvent EventType = "updated" DeletedEvent EventType = "deleted" InsertDBAction = "INSERT" UpdateDBAction = "UPDATE" DeleteDBAction = "DELETE" )
type FakePublisher ¶
type FakePublisher struct{}
func (*FakePublisher) Publish ¶
func (f *FakePublisher) Publish(Event)
type GetterFunc ¶ added in v0.0.53
GetterFunc is a function wrapper for Getter.
type PubSubService ¶
type PubSubService interface { Publisher Subscriber }
PubSubService provides low-level access to pub-sub behaviours. Access is unauthenticated.