pubsub

package
v1.86.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const Domain = "pubsub.googleapis.com"

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(options ...pubsub_config.Option) *Client

func (*Client) Acknowledge added in v1.49.0

func (c *Client) Acknowledge(
	ctx context.Context,
	project string,
	subscription string,
	ackIds []string,
	options ...fetch_config.Option,
) error

Acknowledge tells the server that the given messages have been dealt with, so that they are not delivered again. Acknowledging nothing is not a request.

func (*Client) Publish

func (c *Client) Publish(
	ctx context.Context,
	project string,
	topic string,
	request *publish_request.Request,
	options ...fetch_config.Option,
) (*publish_response.Response, error)

Publish publishes the messages in the request to the given topic and returns the server-assigned message ids. The runtime identity must have the pubsub.publisher role on the topic.

func (*Client) Pull added in v1.49.0

func (c *Client) Pull(
	ctx context.Context,
	project string,
	subscription string,
	maxMessages int,
	options ...fetch_config.Option,
) (*pull_response.Response, error)

Pull asks for whatever is waiting on a subscription. The runtime identity must have the pubsub.subscriber role on it.

Nothing is acknowledged. That is the caller's to decide and it is the decision that matters: a message stays outstanding until acknowledged and is delivered again if the deadline passes, so acknowledging before the work is done trades duplicates for loss. Which way to trade depends on what the message carries. A signal that something should be refreshed can be acknowledged at once, because whoever wanted the refresh will ask again; a log line cannot, because nothing will ever ask for it again. Consumers of the second kind acknowledge after the message is somewhere durable, and rely on being able to recognise a duplicate.

An empty response is the ordinary idle case, not a failure: the server waits a short while for messages and then answers with none.

Jump to

Keyboard shortcuts

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