Documentation ¶
Overview ¶
Package pubsub implements a Pub/Sub binding using google.cloud.com/go/pubsub module
Index ¶
- Constants
- func WritePubSubMessage(ctx context.Context, m binding.Message, pubsubMessage *pubsub.Message, ...) error
- type Message
- func (m *Message) Finish(err error) error
- func (m *Message) GetAttribute(k spec.Kind) (spec.Attribute, interface{})
- func (m *Message) GetExtension(name string) interface{}
- func (m *Message) ReadBinary(ctx context.Context, encoder binding.BinaryWriter) (err error)
- func (m *Message) ReadEncoding() binding.Encoding
- func (m *Message) ReadStructured(ctx context.Context, encoder binding.StructuredWriter) error
- type Option
- func AllowCreateSubscription(allow bool) Option
- func AllowCreateTopic(allow bool) Option
- func WithClient(client *pubsub.Client) Option
- func WithProjectID(projectID string) Option
- func WithProjectIDFromDefaultEnv() Option
- func WithProjectIDFromEnv(key string) Option
- func WithReceiveSettings(rs *pubsub.ReceiveSettings) Option
- func WithSubscriptionAndTopicID(subscriptionID, topicID string) Option
- func WithSubscriptionID(subscriptionID string) Option
- func WithSubscriptionIDFromDefaultEnv() Option
- func WithSubscriptionIDFromEnv(key string) Option
- func WithTopicID(topicID string) Option
- func WithTopicIDFromDefaultEnv() Option
- func WithTopicIDFromEnv(key string) Option
- type Protocol
Constants ¶
const ( DefaultProjectEnvKey = "GOOGLE_CLOUD_PROJECT" DefaultTopicEnvKey = "PUBSUB_TOPIC" DefaultSubscriptionEnvKey = "PUBSUB_SUBSCRIPTION" )
const (
ProtocolName = "Pub/Sub"
)
Variables ¶
This section is empty.
Functions ¶
func WritePubSubMessage ¶
func WritePubSubMessage(ctx context.Context, m binding.Message, pubsubMessage *pubsub.Message, transformers ...binding.Transformer) error
WritePubSubMessage fills the provided pubsubMessage with the message m. Using context you can tweak the encoding processing (more details on binding.Write documentation).
Types ¶
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
Message represents a Pub/Sub message. This message *can* be read several times safely
func NewMessage ¶
NewMessage returns a binding.Message with data and attributes. This message *can* be read several times safely
func (*Message) Finish ¶
Finish marks the message to be forgotten. If err is nil, the underlying Psubsub message will be acked; otherwise nacked.
func (*Message) GetAttribute ¶
func (*Message) GetExtension ¶
func (*Message) ReadBinary ¶
func (*Message) ReadEncoding ¶
func (*Message) ReadStructured ¶
type Option ¶
Option is the function signature required to be considered an pubsub.Option.
func AllowCreateSubscription ¶
AllowCreateSubscription sets if the transport can create a subscription if it does not exist.
func AllowCreateTopic ¶
AllowCreateTopic sets if the transport can create a topic if it does not exist.
func WithClient ¶
WithClient sets the pubsub client for pubsub transport. Use this for explicit auth setup. Otherwise the env var 'GOOGLE_APPLICATION_CREDENTIALS' is used. See https://cloud.google.com/docs/authentication/production for more details.
func WithProjectID ¶
WithProjectID sets the project ID for pubsub transport.
func WithProjectIDFromDefaultEnv ¶
func WithProjectIDFromDefaultEnv() Option
WithProjectIDFromDefaultEnv sets the project ID for pubsub transport from the environment variable named 'GOOGLE_CLOUD_PROJECT'.
func WithProjectIDFromEnv ¶
WithProjectIDFromEnv sets the project ID for pubsub transport from a given environment variable name.
func WithReceiveSettings ¶
func WithReceiveSettings(rs *pubsub.ReceiveSettings) Option
WithReceiveSettings sets the Pubsub ReceiveSettings for pull subscriptions.
func WithSubscriptionAndTopicID ¶
WithSubscriptionAndTopicID sets the subscription and topic IDs for pubsub transport. This option can be used multiple times.
func WithSubscriptionID ¶
WithSubscriptionID sets the subscription ID for pubsub transport. This option can be used multiple times.
func WithSubscriptionIDFromDefaultEnv ¶
func WithSubscriptionIDFromDefaultEnv() Option
WithSubscriptionIDFromDefaultEnv sets the subscription ID for pubsub transport from the environment variable named 'PUBSUB_SUBSCRIPTION'.
func WithSubscriptionIDFromEnv ¶
WithSubscriptionIDFromEnv sets the subscription ID for pubsub transport from a given environment variable name.
func WithTopicID ¶
WithTopicID sets the topic ID for pubsub transport.
func WithTopicIDFromDefaultEnv ¶
func WithTopicIDFromDefaultEnv() Option
WithTopicIDFromDefaultEnv sets the topic ID for pubsub transport from the environment variable named 'PUBSUB_TOPIC'.
func WithTopicIDFromEnv ¶
WithTopicIDFromEnv sets the topic ID for pubsub transport from a given environment variable name.
type Protocol ¶
type Protocol struct { // ReceiveSettings is used to configure Pubsub pull subscription. ReceiveSettings *pubsub.ReceiveSettings // AllowCreateTopic controls if the transport can create a topic if it does // not exist. AllowCreateTopic bool // AllowCreateSubscription controls if the transport can create a // subscription if it does not exist. AllowCreateSubscription bool // contains filtered or unexported fields }
Protocol acts as both a pubsub topic and a pubsub subscription .