events

package module
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 22, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

README

Events

This package makes publishing events super simple. 😎

Documentation

Overview

Package events provides a lightweight set of methods which Builders could use to publish events.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client added in v0.2.0

type Client struct {
	// contains filtered or unexported fields
}

Client object to manage Publishing to a Pub/Sub topic.

func New

func New(project string, opts *Options) (*Client, error)

New creates a new instance of the Client object.

Example
ctx := context.Background()

// Create a new pubsubClient
client, _ := New("your-google-project", &Options{Topic: "my-topic"})

// Publish a message as the event.
var message proto.Message // The message would typically be one of the autogenerated messages, say pb.Portfolio{}
_ = client.Publish(ctx, message, &PublishOptions{})
Output:

func (*Client) BatchPublish added in v0.3.0

func (c *Client) BatchPublish(ctx context.Context, events []proto.Message, opts *PublishOptions) error

func (*Client) Publish added in v0.2.0

func (c *Client) Publish(ctx context.Context, event proto.Message, opts *PublishOptions) error

Publish the event

type Options

type Options struct {
	// The Pub/Sub Topic
	// For example: 'events'
	//
	// Defaults to 'events' if not specified.
	Topic string
}

Options for the New method.

type PublishOptions

type PublishOptions struct {
	// OrderingKey identifies related messages for which publish order should be respected. If empty string is used,
	// message will be sent unordered.
	OrderingKey string
}

PublishOptions used when publishing using the Client.Publish method.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL