pubsub

package
v0.0.0-...-1b86ce5 Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Auth scope required to use this package.
	AUTH_SCOPE = pubsub.ScopePubSub

	// Template used for building pubsub topic names.
	TOPIC_TMPL = "gitstore-%s-%s-%d"
)

Variables

This section is empty.

Functions

func NewSubscriber

func NewSubscriber(ctx context.Context, btConf *bt_gitstore.BTConfig, subscriberID string, repoID int64, ts oauth2.TokenSource, callback func(*pubsub.Message, map[string]string)) error

NewSubscriber creates a pubsub subscription associated with the given GitStore and calls the given function whenever a message is received. The parameters to the callback function are the message itself and the branch heads as of the time that the message was sent, with names as keys and commit hashes as values. The callback function is responsible for calling Ack() or Nack() on the message.

Types

type AutoUpdateCallback

type AutoUpdateCallback func(ctx context.Context, g *repograph.Graph, ack, nack func()) error

AutoUpdateCallback is a callback function used in UpdateUsingPubSub which is called after the Graph is updated but before the changes are committed. If the callback returns an error, the changes are not committed. In addition to the Graph itself, the callback accepts two functions as parameters, ack and nack, which in turn call the Ack() or Nack() functions on the pubsub message(s) which triggered the update. The callback function should call one of them to ensure that the message(s) get redelivered or not, as desired.

type AutoUpdateMap

type AutoUpdateMap struct {
	Map repograph.Map
	// contains filtered or unexported fields
}

AutoUpdateMap is a wrapper around repograph.Map which provides a convenience method for auto-updating the Graphs in the Map.

func NewAutoUpdateMap

func NewAutoUpdateMap(ctx context.Context, repoUrls []string, btConf *bt_gitstore.BTConfig) (*AutoUpdateMap, error)

NewBTGitStoreMap is a wrapper around bt_gitstore.NewBTGitStoreMap which provides a convenience method for auto-updating the Graphs in the Map.

func (*AutoUpdateMap) Start

func (m *AutoUpdateMap) Start(ctx context.Context, subscriberID string, ts oauth2.TokenSource, fallbackInterval time.Duration, callback AutoUpdateMapCallback) error

Start initializes auto-updating of the AutoUpdateMap.

type AutoUpdateMapCallback

type AutoUpdateMapCallback func(ctx context.Context, repoUrl string, g *repograph.Graph, ack, nack func()) error

AutoUpdateMapCallback is like AutoUpdateCallback, except that it's handed to NewAutoUpdateMap.Start() and also includes the repo URL.

type Publisher

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

Publisher is a struct used for publishing pubsub messages for a GitStore.

func NewPublisher

func NewPublisher(ctx context.Context, btConf *bt_gitstore.BTConfig, repoID int64, ts oauth2.TokenSource) (*Publisher, error)

NewPublisher returns a Publisher instance associated with the given GitStore.

func (*Publisher) Publish

func (p *Publisher) Publish(ctx context.Context, branches map[string]string)

Publish a pubsub message with the given updated branch heads. Typically, only the branch heads which have changed should be included. The message is sent asynchronously.

func (*Publisher) Wait

func (p *Publisher) Wait()

Wait for all pubsub messages to be sent.

Jump to

Keyboard shortcuts

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