pubsub

package
v0.0.130 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package pubsub exports messages for interacting with pubsub.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SendGCS

func SendGCS(ctx context.Context, log logrus.FieldLogger, client Subscriber, projectID, subID string, settings *pubsub.ReceiveSettings, receivers chan<- *Notification) error

SendGCS converts GCS pubsub messages into Notification structs and sends them to receivers.

Connects to the specified subscription with optionally specified settings. Receives pubsub messages from this subscription and converts it into a Notification struct.

  • Nacks any message it cannot parse.

Sends the notification to the receivers channel.

  • Nacks messages associated with any unsent Notifications.
  • Acks as soon as the Notification is sent.

More info: https://cloud.google.com/storage/docs/pubsub-notifications#overview

Types

type Client

type Client pubsub.Client

Client wraps a pubsub client into a Subscriber that creates Senders for pubsub subscriptions.

func NewClient

func NewClient(client *pubsub.Client) *Client

NewClient converts a raw pubsub client into a Subscriber.

func (*Client) Subscribe

func (c *Client) Subscribe(projID, subID string, settings *pubsub.ReceiveSettings) Sender

Subscribe to the specified id in the project using optional receive settings.

type Event

type Event string

Event specifies what happened to the GCS object.

See https://cloud.google.com/storage/docs/pubsub-notifications#events

const (
	Finalize Event = "OBJECT_FINALIZE"
	Delete   Event = "OBJECT_DELETE"
)

Well-known event types.

type Notification

type Notification struct {
	Path       gcs.Path
	Event      Event
	Time       time.Time
	Generation int64
}

Notification captures information about a change to a GCS object.

func (Notification) String

func (n Notification) String() string

type Sender

type Sender func(sendCtx context.Context, receive func(context.Context, *pubsub.Message)) error

Sender forwards pubsub messages to the receive function until the send context expires.

type Subscriber

type Subscriber interface {
	Subscribe(projID, subID string, setttings *pubsub.ReceiveSettings) Sender
}

Subscriber creates Senders that attach to subscriptions with the specified settings.

Jump to

Keyboard shortcuts

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