Documentation ¶
Index ¶
- func NewPubSubClient(projectID string) (*pubsub.Client, *context.Context, error)
- type EventHandler
- type GooglePubSub
- func (g *GooglePubSub) CreateSubscription(topicName string, subName string) error
- func (g *GooglePubSub) CreateSubscriptionWithConfig(topicName string, subName string, config pubsub.SubscriptionConfig) error
- func (g *GooglePubSub) CreateTopic(topicName string) error
- func (g *GooglePubSub) DeleteSubscription(subName string) error
- func (g *GooglePubSub) DeleteTopic(topicName string) error
- func (g *GooglePubSub) NumPublishersRunning() int
- func (g *GooglePubSub) NumSubscribersRunning() int
- func (g *GooglePubSub) Publish(msg *GooglePubSubMsg) error
- func (g *GooglePubSub) PublishersStarted() bool
- func (g *GooglePubSub) StartPublishers() error
- func (g *GooglePubSub) StartSubscribers(subscriptionName string) error
- func (g *GooglePubSub) StartSubscribersWithConfig(config SubscribeConfig) error
- func (g *GooglePubSub) StopPublishers() error
- func (g *GooglePubSub) StopSubscribers() error
- func (g *GooglePubSub) SubscribersStarted() bool
- func (g *GooglePubSub) SubscriptionExists(subName string) (bool, error)
- func (g *GooglePubSub) SubscriptionName() string
- func (g *GooglePubSub) TopicExists(topicName string) (bool, error)
- type GooglePubSubMsg
- type SubscribeConfig
- type Workers
- type WorkersConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type EventHandler ¶
type EventHandler interface { // Handle runs the logic to handle the event as appropriate for the event // Returns a bool whether the event was handled and an error if occurred Handle(event []byte) (bool, error) // Name returns a readable name for this particular event handler Name() string }
EventHandler is an interface to a governance event handler.
type GooglePubSub ¶
type GooglePubSub struct { SubscribeChan chan *pubsub.Message SubscribeErrChan chan error // contains filtered or unexported fields }
GooglePubSub is a wrapper around handling for Google Pub/Sub. Manages pooled goroutines of publishers and subscribers.
func NewGooglePubSub ¶
func NewGooglePubSub(projectID string) (*GooglePubSub, error)
NewGooglePubSub returns a new GooglePubSub struct
func (*GooglePubSub) CreateSubscription ¶
func (g *GooglePubSub) CreateSubscription(topicName string, subName string) error
CreateSubscription creates a new subscription with a default config
func (*GooglePubSub) CreateSubscriptionWithConfig ¶
func (g *GooglePubSub) CreateSubscriptionWithConfig(topicName string, subName string, config pubsub.SubscriptionConfig) error
CreateSubscriptionWithConfig creates a new subscription
func (*GooglePubSub) CreateTopic ¶
func (g *GooglePubSub) CreateTopic(topicName string) error
CreateTopic creates a new pubsub topic
func (*GooglePubSub) DeleteSubscription ¶
func (g *GooglePubSub) DeleteSubscription(subName string) error
DeleteSubscription deletes an existing subscription
func (*GooglePubSub) DeleteTopic ¶
func (g *GooglePubSub) DeleteTopic(topicName string) error
DeleteTopic deletes an existing pubsub topic
func (*GooglePubSub) NumPublishersRunning ¶
func (g *GooglePubSub) NumPublishersRunning() int
NumPublishersRunning return the number of publishers goroutines running.
func (*GooglePubSub) NumSubscribersRunning ¶
func (g *GooglePubSub) NumSubscribersRunning() int
NumSubscribersRunning return the number of subscriber goroutines running.
func (*GooglePubSub) Publish ¶
func (g *GooglePubSub) Publish(msg *GooglePubSubMsg) error
Publish publishes the given message to the pubsub.
func (*GooglePubSub) PublishersStarted ¶
func (g *GooglePubSub) PublishersStarted() bool
PublishersStarted returns true if the publishers are running, false if not.
func (*GooglePubSub) StartPublishers ¶
func (g *GooglePubSub) StartPublishers() error
StartPublishers starts up a pool of PubSub publishers.
func (*GooglePubSub) StartSubscribers ¶
func (g *GooglePubSub) StartSubscribers(subscriptionName string) error
StartSubscribers starts up a pool of PubSub publishers using a default config
func (*GooglePubSub) StartSubscribersWithConfig ¶
func (g *GooglePubSub) StartSubscribersWithConfig(config SubscribeConfig) error
StartSubscribersWithConfig starts up a pool of PubSub publishers.
func (*GooglePubSub) StopPublishers ¶
func (g *GooglePubSub) StopPublishers() error
StopPublishers will stop the publisher goroutines
func (*GooglePubSub) StopSubscribers ¶
func (g *GooglePubSub) StopSubscribers() error
StopSubscribers will stop the subscriber goroutines
func (*GooglePubSub) SubscribersStarted ¶
func (g *GooglePubSub) SubscribersStarted() bool
SubscribersStarted returns true if the subscribers are running, false if not.
func (*GooglePubSub) SubscriptionExists ¶
func (g *GooglePubSub) SubscriptionExists(subName string) (bool, error)
SubscriptionExists checks for existence of an existing subscription
func (*GooglePubSub) SubscriptionName ¶
func (g *GooglePubSub) SubscriptionName() string
SubscriptionName returns the name of the subscription to track.
func (*GooglePubSub) TopicExists ¶
func (g *GooglePubSub) TopicExists(topicName string) (bool, error)
TopicExists checks the existence of a topic
type GooglePubSubMsg ¶
GooglePubSubMsg represents a messages to be published
type SubscribeConfig ¶
SubscribeConfig is a config for the wrapper around a Google Pubsub Subscription
type Workers ¶
type Workers struct { Errors chan error // contains filtered or unexported fields }
Workers controls the events workers that handles incoming pubsub events. One instance of Workers normally points to one particular queue of events by event types. i.e. one Workers instance for gov events and a separate instance for token events. Meant to be generic framework where the pubsub queue and the set of event handlers are configured before use.
func NewWorkers ¶
func NewWorkers(config *WorkersConfig) (*Workers, error)
NewWorkers configures and returns a new Workers struct
func (*Workers) NumActiveWorkers ¶
NumActiveWorkers returns the number of active workers
type WorkersConfig ¶
type WorkersConfig struct { PubSubProjectID string PubSubTopicName string PubSubSubscriptionName string NumWorkers int QuitChan chan struct{} EventHandlers []EventHandler }
WorkersConfig configures the governance event pubsub workers