pubsub

package
v0.0.0-...-c49be44 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Publish(ctx context.Context, event RolloutEvent) error
}

Client represents a client to Google Cloud Pub/Sub.

type PubSub

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

PubSub is a Google Cloud Pub/Sub client to publish messages.

func New

func New(ctx context.Context, projectID string, topicName string) (ps PubSub, err error)

New initializes a PubSub client to a topic in a project.

func (PubSub) Publish

func (ps PubSub) Publish(ctx context.Context, event RolloutEvent) error

Publish publishes message to the topic.

func (PubSub) Stop

func (ps PubSub) Stop()

Stop is a wrapper around Cloud Run Pub/Sub package's Stop method on Topic.

It sends all remaining published messages and stop goroutines created for handling publishing. Returns once all outstanding messages have been sent or have failed to be sent.

type RolloutEvent

type RolloutEvent struct {
	Event                        string       `json:"event"`
	CandidateRevisionName        string       `json:"candidateRevisionName"`
	CandidateRevisionPercent     int          `json:"candidateRevisionPercent"`
	CandidateRevisionURL         string       `json:"candidateRevisionURL"`
	CandidateWasPromotedToStable bool         `json:"candidateWasPromotedToStable"`
	Service                      *run.Service `json:"service"`
}

RolloutEvent is the format of an event published to Pub/Sub.

func NewRolloutEvent

func NewRolloutEvent(svc *run.Service, diagnosis health.DiagnosisResult, candidateWasPromoted bool) (RolloutEvent, error)

NewRolloutEvent initializes an event to publish to PubSub.

svc must be the updated Service instance as the result of the rollout.

Jump to

Keyboard shortcuts

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