pubsub

package
v0.0.0-...-534e604 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2024 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 AckMessage

type AckMessage struct {
	AckIDs []string `json:"ackIds"`
}

type Client

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

func NewClient

func NewClient() (*Client, error)

NewClient creates a new authenticated http client using Google's Application Default Credentials.

func (*Client) Ack

func (c *Client) Ack(ctx context.Context, subscription, ackID string) error

func (*Client) Publish

func (c *Client) Publish(ctx context.Context, topic string, messages []*Message) error

Publish pushes new messages onto the provided topic, returning any errors that occur.

func (*Client) PublishOne

func (c *Client) PublishOne(ctx context.Context, topic string, message *Message) error

PublishOne pushes a new message onto the provided topic, returning any errors that occur.

func (*Client) Pull

func (c *Client) Pull(ctx context.Context, subscription string) (*ReceivedMessage, error)

Pull gets a message of the given subscription. Use a timeout on the context to cancel the pull. The returned message will be nil if there's nothing on the subscription.

func (*Client) PullAndAck

func (c *Client) PullAndAck(ctx context.Context, subscription string) (*Message, error)

PullAndAck pulls the message and immediately acks it.

type Message

type Message struct {
	// Data is the message data.
	Data []byte `json:"data"`

	// Attributes are any message attributes.
	Attributes map[string]string `json:"attributes"`

	// MessageID is assigned by the server.
	MessageID string `json:"messageId"`

	// PublishTime is the server timestamp for when the message was published.
	PublishTime *time.Time `json:"publishTime"`
}

Message represents a message on the PubSub topic/subscription.

type Messages

type Messages struct {
	Messages []*Message `json:"messages"`
}

type ReceivedMessage

type ReceivedMessage struct {
	AckID   string   `json:"ackId"`
	Message *Message `json:"message"`
}

ReceivedMessage is a message received back from PubSub.

type ReceivedMessages

type ReceivedMessages struct {
	ReceivedMessages []*ReceivedMessage `json:"receivedMessages"`
}

Jump to

Keyboard shortcuts

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