Documentation ¶
Index ¶
- Constants
- func CheckEmpty(source, newValue string) string
- func GetTopicIDFromHeader(envelope *events.Envelope) (string, bool)
- type Config
- type PubSubBroker
- func (b *PubSubBroker) BuildEnvelope(event events.Event) (*events.Envelope, error)
- func (b *PubSubBroker) SendMessage(envelope *events.Envelope) error
- func (b *PubSubBroker) SetEnvelopeHeader(event events.Event, envelope *events.Envelope)
- func (b *PubSubBroker) TopicFor(ctx context.Context, topicID string) (*pubsub.Topic, error)
Constants ¶
const ( PROJECTID_HEADER_KEY = "pubsub_project_id" TOPIC_ID_HEADER_KEY = "pubsub_topic_id" EVENT_TYPE_HEADER_KEY = "pubsub_event_type" DEFAULT_TOPIC_ID = "gameserver.events" )
Variables ¶
This section is empty.
Functions ¶
func CheckEmpty ¶
CheckEmpty is a helper function that will check if source is empty and assign newValue if so
Types ¶
type Config ¶
type Config struct { ProjectID string GenericTopicID string OnAddTopicID string OnUpdateTopicID string OnDeleteTopicID string }
Config is the data structure that holds the configuration passed to the Google Pub/Sub Broker. GenericTopicID is used when specific events topics are not present and all the events should be published to a single topic. Defaults to "gameserver.events"
func (*Config) ApplyDefaults ¶
func (c *Config) ApplyDefaults()
ApplyDefaults sets default values for the Config used by the PubSubBroker
type PubSubBroker ¶
PubSubBroker is a implementation of the Broker interface that uses Google Cloud PubSub for publishing messages
func NewPubSubBroker ¶
func NewPubSubBroker(config *Config, opts ...option.ClientOption) (*PubSubBroker, error)
func (*PubSubBroker) BuildEnvelope ¶
BuildEnvelope builds the envelope for a particular event. It will set the enveloper header and message content
func (*PubSubBroker) SendMessage ¶
func (b *PubSubBroker) SendMessage(envelope *events.Envelope) error
SendMessage publishes a particular envelope to a Google Pub/Sub topic.
func (*PubSubBroker) SetEnvelopeHeader ¶
func (b *PubSubBroker) SetEnvelopeHeader(event events.Event, envelope *events.Envelope)
SetEnvelopeHeader sets the envelope header for a particular event. Those specific headers will be used by the broker when publishing the message to the Google Pub/Sub topic