Version: v0.8.1 Latest Latest

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

Go to latest
Published: Aug 20, 2019 License: Apache-2.0 Imports: 16 Imported by: 2




This section is empty.


View Source
var (
	// LatencyMs measures the latency in milliseconds for the PullSubscription
	// adapter methods for Pub/Sub.
	LatencyMs = stats.Float64(
		"The latency in milliseconds for the PullSubscription adapter methods for Pub/Sub.",
View Source
var (
	// LatencyView is an OpenCensus view that shows http transport method latency.
	LatencyView = &view.View{
		Name:        "pubsub/pullsubscriptions/adapter/latency",
		Measure:     LatencyMs,
		Description: "The distribution of latency inside of PullSubscription adapter for Pub/Sub.",

		Aggregation: view.Distribution(10, 100, 1000, 10000, 30000, 60000),
		TagKeys:     observability.LatencyTags(),


func ConvertToPush

func ConvertToPush(ctx context.Context, event cloudevents.Event) cloudevents.Event

ConvertToPush convert an event to a Pub/Sub style Push payload.


type Adapter

type Adapter struct {
	// Environment variable containing project id.
	Project string `envconfig:"PROJECT_ID"`

	// Environment variable containing the sink URI.
	Sink string `envconfig:"SINK_URI" required:"true"`

	// Environment variable containing the transformer URI.
	Transformer string `envconfig:"TRANSFORMER_URI"`

	// Topic is the environment variable containing the PubSub Topic being
	// subscribed to's name. In the form that is unique within the project.
	// E.g. 'laconia', not 'projects/my-gcp-project/topics/laconia'.
	Topic string `envconfig:"PUBSUB_TOPIC_ID" required:"true"`

	// Subscription is the environment variable containing the name of the
	// subscription to use.
	Subscription string `envconfig:"PUBSUB_SUBSCRIPTION_ID" required:"true"`

	// ExtensionsBased64 is a based64 encoded json string of a map of
	// CloudEvents extensions (key-value pairs) override onto the outbound
	// event.
	ExtensionsBased64 string `envconfig:"K_CE_EXTENSIONS" required:"true"`

	// SendMode describes how the adapter sends events.
	// One of [binary, structured, push]. Default: binary
	SendMode converters.ModeType `envconfig:"SEND_MODE" default:"binary" required:"true"`

	// MetricsDomain holds the metrics domain to use for surfacing metrics.
	MetricsDomain string `envconfig:"METRICS_DOMAIN" required:"true"`
	// contains filtered or unexported fields

Adapter implements the Pub/Sub adapter to deliver Pub/Sub messages from a pre-existing topic/subscription to a Sink.

func (*Adapter) Start

func (a *Adapter) Start(ctx context.Context) error

Start starts the adapter. Note: Only call once, not thread safe.

type CodecObserved added in v0.8.1

type CodecObserved struct {
	// contains filtered or unexported fields

CodecObserved is a wrapper to append version to observed.

func (CodecObserved) LatencyMs added in v0.8.1

func (c CodecObserved) LatencyMs() *stats.Float64Measure

LatencyMs implements Observable.LatencyMs

func (CodecObserved) MethodName added in v0.8.1

func (c CodecObserved) MethodName() string

MethodName implements Observable.MethodName

func (CodecObserved) TraceName added in v0.8.1

func (c CodecObserved) TraceName() string

TraceName implements Observable.TraceName

type PubSubMessage

type PubSubMessage struct {
	// ID identifies this message. This ID is assigned by the server and is
	// populated for Messages obtained from a subscription.
	// This field is read-only.
	ID string `json:"id,omitempty"`

	// Data is the actual data in the message.
	Data interface{} `json:"data,omitempty"`

	// Attributes represents the key-value pairs the current message
	// is labelled with.
	Attributes map[string]string `json:"attributes,omitempty"`

	// The time at which the message was published. This is populated by the
	// server for Messages obtained from a subscription.
	// This field is read-only.
	PublishTime time.Time `json:"publish_time,omitempty"`

PubSubMessage matches the inner message format used by Push Subscriptions.

type PushMessage

type PushMessage struct {
	// Subscription is the subscription ID that received this Message.
	Subscription string `json:"subscription"`
	// Message holds the Pub/Sub message contents.
	Message *PubSubMessage `json:"message,omitempty"`

PushMessage represents the format Pub/Sub uses to push events.


Path Synopsis

Jump to

Keyboard shortcuts

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