pubsub

package
v0.0.0-...-0848a1d Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2016 License: Apache-2.0 Imports: 13 Imported by: 0

README

Auto-generated pubsub v1 clients

This package includes auto-generated clients for the pubsub v1 API.

Use the handwritten logging client (in the parent directory, cloud.google.com/go/pubsub) in preference to this.

This code is EXPERIMENTAL and subject to CHANGE AT ANY TIME.

Documentation

Overview

Package pubsub is an experimental, auto-generated package for the pubsub API.

Provides reliable, many-to-many, asynchronous messaging between applications.

Index

Examples

Constants

This section is empty.

Variables

View Source
var Done = errors.New("iterator done")

Done is returned by iterators on successful completion.

Functions

func PublisherProjectPath

func PublisherProjectPath(project string) string

ProjectPath returns the path for the project resource.

func PublisherTopicPath

func PublisherTopicPath(project string, topic string) string

TopicPath returns the path for the topic resource.

func SubscriberProjectPath

func SubscriberProjectPath(project string) string

ProjectPath returns the path for the project resource.

func SubscriberSubscriptionPath

func SubscriberSubscriptionPath(project string, subscription string) string

SubscriptionPath returns the path for the subscription resource.

func SubscriberTopicPath

func SubscriberTopicPath(project string, topic string) string

TopicPath returns the path for the topic resource.

Types

type PublisherCallOptions

type PublisherCallOptions struct {
	CreateTopic            []gax.CallOption
	Publish                []gax.CallOption
	GetTopic               []gax.CallOption
	ListTopics             []gax.CallOption
	ListTopicSubscriptions []gax.CallOption
	DeleteTopic            []gax.CallOption
}

PublisherCallOptions contains the retry settings for each method of this client.

type PublisherClient

type PublisherClient struct {

	// The call options for this service.
	CallOptions *PublisherCallOptions
	// contains filtered or unexported fields
}

PublisherClient is a client for interacting with Publisher.

func NewPublisherClient

func NewPublisherClient(ctx context.Context, opts ...option.ClientOption) (*PublisherClient, error)

NewPublisherClient creates a new publisher service client.

The service that an application uses to manipulate topics, and to send messages to a topic.

Example
ctx := context.Background()
c, err := pubsub.NewPublisherClient(ctx)
if err != nil {
	// TODO: Handle error.
}
// TODO: Use client.
_ = c
Output:

func (*PublisherClient) Close

func (c *PublisherClient) Close() error

Close closes the connection to the API service. The user should invoke this when the client is no longer required.

func (*PublisherClient) Connection

func (c *PublisherClient) Connection() *grpc.ClientConn

Connection returns the client's connection to the API service.

func (*PublisherClient) CreateTopic

func (c *PublisherClient) CreateTopic(ctx context.Context, req *pubsubpb.Topic) (*pubsubpb.Topic, error)

CreateTopic creates the given topic with the given name.

Example
ctx := context.Background()
c, err := pubsub.NewPublisherClient(ctx)
if err != nil {
	// TODO: Handle error.
}

req := &pubsubpb.Topic{
	// TODO: Fill request struct fields.
}
resp, err := c.CreateTopic(ctx, req)
if err != nil {
	// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
Output:

func (*PublisherClient) DeleteTopic

func (c *PublisherClient) DeleteTopic(ctx context.Context, req *pubsubpb.DeleteTopicRequest) error

DeleteTopic deletes the topic with the given name. Returns `NOT_FOUND` if the topic does not exist. After a topic is deleted, a new topic may be created with the same name; this is an entirely new topic with none of the old configuration or subscriptions. Existing subscriptions to this topic are not deleted, but their `topic` field is set to `_deleted-topic_`.

Example
ctx := context.Background()
c, err := pubsub.NewPublisherClient(ctx)
if err != nil {
	// TODO: Handle error.
}

req := &pubsubpb.DeleteTopicRequest{
	// TODO: Fill request struct fields.
}
err = c.DeleteTopic(ctx, req)
if err != nil {
	// TODO: Handle error.
}
Output:

func (*PublisherClient) GetTopic

GetTopic gets the configuration of a topic.

Example
ctx := context.Background()
c, err := pubsub.NewPublisherClient(ctx)
if err != nil {
	// TODO: Handle error.
}

req := &pubsubpb.GetTopicRequest{
	// TODO: Fill request struct fields.
}
resp, err := c.GetTopic(ctx, req)
if err != nil {
	// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
Output:

func (*PublisherClient) ListTopicSubscriptions

ListTopicSubscriptions lists the name of the subscriptions for this topic.

Example
ctx := context.Background()
c, err := pubsub.NewPublisherClient(ctx)
if err != nil {
	// TODO: Handle error.
}

req := &pubsubpb.ListTopicSubscriptionsRequest{
	// TODO: Fill request struct fields.
}
it := c.ListTopicSubscriptions(ctx, req)
for {
	resp, err := it.Next()
	if err != nil {
		// TODO: Handle error.
		break
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*PublisherClient) ListTopics

ListTopics lists matching topics.

Example
ctx := context.Background()
c, err := pubsub.NewPublisherClient(ctx)
if err != nil {
	// TODO: Handle error.
}

req := &pubsubpb.ListTopicsRequest{
	// TODO: Fill request struct fields.
}
it := c.ListTopics(ctx, req)
for {
	resp, err := it.Next()
	if err != nil {
		// TODO: Handle error.
		break
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*PublisherClient) Publish

Publish adds one or more messages to the topic. Returns `NOT_FOUND` if the topic does not exist. The message payload must not be empty; it must contain

either a non-empty data field, or at least one attribute.
Example
ctx := context.Background()
c, err := pubsub.NewPublisherClient(ctx)
if err != nil {
	// TODO: Handle error.
}

req := &pubsubpb.PublishRequest{
	// TODO: Fill request struct fields.
}
resp, err := c.Publish(ctx, req)
if err != nil {
	// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
Output:

func (*PublisherClient) SetGoogleClientInfo

func (c *PublisherClient) SetGoogleClientInfo(name, version string)

SetGoogleClientInfo sets the name and version of the application in the `x-goog-api-client` header passed on each request. Intended for use by Google-written clients.

type StringIterator

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

StringIterator manages a stream of string.

func (*StringIterator) Next

func (it *StringIterator) Next() (string, error)

Next returns the next result. Its second return value is Done if there are no more results. Once next returns Done, all subsequent calls will return Done.

Internally, Next retrieves results in bulk. You can call SetPageSize as a performance hint to affect how many results are retrieved in a single RPC.

SetPageToken should not be called when using Next.

Next and NextPage should not be used with the same iterator.

func (*StringIterator) NextPage

func (it *StringIterator) NextPage() ([]string, error)

NextPage returns the next page of results. It will return at most the number of results specified by the last call to SetPageSize. If SetPageSize was never called or was called with a value less than 1, the page size is determined by the underlying service.

NextPage may return a second return value of Done along with the last page of results. After NextPage returns Done, all subsequent calls to NextPage will return (nil, Done).

Next and NextPage should not be used with the same iterator.

func (*StringIterator) NextPageToken

func (it *StringIterator) NextPageToken() string

NextPageToken returns a page token that can be used with SetPageToken to resume iteration from the next page. It returns the empty string if there are no more pages.

func (*StringIterator) PageSize

func (it *StringIterator) PageSize() int

PageSize returns the page size for all subsequent calls to NextPage.

func (*StringIterator) SetPageSize

func (it *StringIterator) SetPageSize(pageSize int)

SetPageSize sets the page size for all subsequent calls to NextPage.

func (*StringIterator) SetPageToken

func (it *StringIterator) SetPageToken(token string)

SetPageToken sets the page token for the next call to NextPage, to resume the iteration from a previous point.

type SubscriberCallOptions

type SubscriberCallOptions struct {
	CreateSubscription []gax.CallOption
	GetSubscription    []gax.CallOption
	ListSubscriptions  []gax.CallOption
	DeleteSubscription []gax.CallOption
	ModifyAckDeadline  []gax.CallOption
	Acknowledge        []gax.CallOption
	Pull               []gax.CallOption
	ModifyPushConfig   []gax.CallOption
}

SubscriberCallOptions contains the retry settings for each method of this client.

type SubscriberClient

type SubscriberClient struct {

	// The call options for this service.
	CallOptions *SubscriberCallOptions
	// contains filtered or unexported fields
}

SubscriberClient is a client for interacting with Subscriber.

func NewSubscriberClient

func NewSubscriberClient(ctx context.Context, opts ...option.ClientOption) (*SubscriberClient, error)

NewSubscriberClient creates a new subscriber service client.

The service that an application uses to manipulate subscriptions and to consume messages from a subscription via the `Pull` method.

Example
ctx := context.Background()
c, err := pubsub.NewSubscriberClient(ctx)
if err != nil {
	// TODO: Handle error.
}
// TODO: Use client.
_ = c
Output:

func (*SubscriberClient) Acknowledge

Acknowledge acknowledges the messages associated with the `ack_ids` in the `AcknowledgeRequest`. The Pub/Sub system can remove the relevant messages from the subscription.

Acknowledging a message whose ack deadline has expired may succeed, but such a message may be redelivered later. Acknowledging a message more than once will not result in an error.

Example
ctx := context.Background()
c, err := pubsub.NewSubscriberClient(ctx)
if err != nil {
	// TODO: Handle error.
}

req := &pubsubpb.AcknowledgeRequest{
	// TODO: Fill request struct fields.
}
err = c.Acknowledge(ctx, req)
if err != nil {
	// TODO: Handle error.
}
Output:

func (*SubscriberClient) Close

func (c *SubscriberClient) Close() error

Close closes the connection to the API service. The user should invoke this when the client is no longer required.

func (*SubscriberClient) Connection

func (c *SubscriberClient) Connection() *grpc.ClientConn

Connection returns the client's connection to the API service.

func (*SubscriberClient) CreateSubscription

func (c *SubscriberClient) CreateSubscription(ctx context.Context, req *pubsubpb.Subscription) (*pubsubpb.Subscription, error)

CreateSubscription creates a subscription to a given topic for a given subscriber. If the subscription already exists, returns `ALREADY_EXISTS`. If the corresponding topic doesn't exist, returns `NOT_FOUND`.

If the name is not provided in the request, the server will assign a random name for this subscription on the same project as the topic.

Example
ctx := context.Background()
c, err := pubsub.NewSubscriberClient(ctx)
if err != nil {
	// TODO: Handle error.
}

req := &pubsubpb.Subscription{
	// TODO: Fill request struct fields.
}
resp, err := c.CreateSubscription(ctx, req)
if err != nil {
	// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
Output:

func (*SubscriberClient) DeleteSubscription

func (c *SubscriberClient) DeleteSubscription(ctx context.Context, req *pubsubpb.DeleteSubscriptionRequest) error

DeleteSubscription deletes an existing subscription. All pending messages in the subscription are immediately dropped. Calls to `Pull` after deletion will return `NOT_FOUND`. After a subscription is deleted, a new one may be created with the same name, but the new one has no association with the old subscription, or its topic unless the same topic is specified.

Example
ctx := context.Background()
c, err := pubsub.NewSubscriberClient(ctx)
if err != nil {
	// TODO: Handle error.
}

req := &pubsubpb.DeleteSubscriptionRequest{
	// TODO: Fill request struct fields.
}
err = c.DeleteSubscription(ctx, req)
if err != nil {
	// TODO: Handle error.
}
Output:

func (*SubscriberClient) GetSubscription

GetSubscription gets the configuration details of a subscription.

Example
ctx := context.Background()
c, err := pubsub.NewSubscriberClient(ctx)
if err != nil {
	// TODO: Handle error.
}

req := &pubsubpb.GetSubscriptionRequest{
	// TODO: Fill request struct fields.
}
resp, err := c.GetSubscription(ctx, req)
if err != nil {
	// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
Output:

func (*SubscriberClient) ListSubscriptions

ListSubscriptions lists matching subscriptions.

Example
ctx := context.Background()
c, err := pubsub.NewSubscriberClient(ctx)
if err != nil {
	// TODO: Handle error.
}

req := &pubsubpb.ListSubscriptionsRequest{
	// TODO: Fill request struct fields.
}
it := c.ListSubscriptions(ctx, req)
for {
	resp, err := it.Next()
	if err != nil {
		// TODO: Handle error.
		break
	}
	// TODO: Use resp.
	_ = resp
}
Output:

func (*SubscriberClient) ModifyAckDeadline

func (c *SubscriberClient) ModifyAckDeadline(ctx context.Context, req *pubsubpb.ModifyAckDeadlineRequest) error

ModifyAckDeadline modifies the ack deadline for a specific message. This method is useful to indicate that more time is needed to process a message by the subscriber, or to make the message available for redelivery if the processing was interrupted.

Example
ctx := context.Background()
c, err := pubsub.NewSubscriberClient(ctx)
if err != nil {
	// TODO: Handle error.
}

req := &pubsubpb.ModifyAckDeadlineRequest{
	// TODO: Fill request struct fields.
}
err = c.ModifyAckDeadline(ctx, req)
if err != nil {
	// TODO: Handle error.
}
Output:

func (*SubscriberClient) ModifyPushConfig

func (c *SubscriberClient) ModifyPushConfig(ctx context.Context, req *pubsubpb.ModifyPushConfigRequest) error

ModifyPushConfig modifies the `PushConfig` for a specified subscription.

This may be used to change a push subscription to a pull one (signified by an empty `PushConfig`) or vice versa, or change the endpoint URL and other attributes of a push subscription. Messages will accumulate for delivery continuously through the call regardless of changes to the `PushConfig`.

Example
ctx := context.Background()
c, err := pubsub.NewSubscriberClient(ctx)
if err != nil {
	// TODO: Handle error.
}

req := &pubsubpb.ModifyPushConfigRequest{
	// TODO: Fill request struct fields.
}
err = c.ModifyPushConfig(ctx, req)
if err != nil {
	// TODO: Handle error.
}
Output:

func (*SubscriberClient) Pull

Pull pulls messages from the server. Returns an empty list if there are no messages available in the backlog. The server may return `UNAVAILABLE` if there are too many concurrent pull requests pending for the given subscription.

Example
ctx := context.Background()
c, err := pubsub.NewSubscriberClient(ctx)
if err != nil {
	// TODO: Handle error.
}

req := &pubsubpb.PullRequest{
	// TODO: Fill request struct fields.
}
resp, err := c.Pull(ctx, req)
if err != nil {
	// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
Output:

func (*SubscriberClient) SetGoogleClientInfo

func (c *SubscriberClient) SetGoogleClientInfo(name, version string)

SetGoogleClientInfo sets the name and version of the application in the `x-goog-api-client` header passed on each request. Intended for use by Google-written clients.

type SubscriptionIterator

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

SubscriptionIterator manages a stream of *pubsubpb.Subscription.

func (*SubscriptionIterator) Next

Next returns the next result. Its second return value is Done if there are no more results. Once next returns Done, all subsequent calls will return Done.

Internally, Next retrieves results in bulk. You can call SetPageSize as a performance hint to affect how many results are retrieved in a single RPC.

SetPageToken should not be called when using Next.

Next and NextPage should not be used with the same iterator.

func (*SubscriptionIterator) NextPage

func (it *SubscriptionIterator) NextPage() ([]*pubsubpb.Subscription, error)

NextPage returns the next page of results. It will return at most the number of results specified by the last call to SetPageSize. If SetPageSize was never called or was called with a value less than 1, the page size is determined by the underlying service.

NextPage may return a second return value of Done along with the last page of results. After NextPage returns Done, all subsequent calls to NextPage will return (nil, Done).

Next and NextPage should not be used with the same iterator.

func (*SubscriptionIterator) NextPageToken

func (it *SubscriptionIterator) NextPageToken() string

NextPageToken returns a page token that can be used with SetPageToken to resume iteration from the next page. It returns the empty string if there are no more pages.

func (*SubscriptionIterator) PageSize

func (it *SubscriptionIterator) PageSize() int

PageSize returns the page size for all subsequent calls to NextPage.

func (*SubscriptionIterator) SetPageSize

func (it *SubscriptionIterator) SetPageSize(pageSize int)

SetPageSize sets the page size for all subsequent calls to NextPage.

func (*SubscriptionIterator) SetPageToken

func (it *SubscriptionIterator) SetPageToken(token string)

SetPageToken sets the page token for the next call to NextPage, to resume the iteration from a previous point.

type TopicIterator

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

TopicIterator manages a stream of *pubsubpb.Topic.

func (*TopicIterator) Next

func (it *TopicIterator) Next() (*pubsubpb.Topic, error)

Next returns the next result. Its second return value is Done if there are no more results. Once next returns Done, all subsequent calls will return Done.

Internally, Next retrieves results in bulk. You can call SetPageSize as a performance hint to affect how many results are retrieved in a single RPC.

SetPageToken should not be called when using Next.

Next and NextPage should not be used with the same iterator.

func (*TopicIterator) NextPage

func (it *TopicIterator) NextPage() ([]*pubsubpb.Topic, error)

NextPage returns the next page of results. It will return at most the number of results specified by the last call to SetPageSize. If SetPageSize was never called or was called with a value less than 1, the page size is determined by the underlying service.

NextPage may return a second return value of Done along with the last page of results. After NextPage returns Done, all subsequent calls to NextPage will return (nil, Done).

Next and NextPage should not be used with the same iterator.

func (*TopicIterator) NextPageToken

func (it *TopicIterator) NextPageToken() string

NextPageToken returns a page token that can be used with SetPageToken to resume iteration from the next page. It returns the empty string if there are no more pages.

func (*TopicIterator) PageSize

func (it *TopicIterator) PageSize() int

PageSize returns the page size for all subsequent calls to NextPage.

func (*TopicIterator) SetPageSize

func (it *TopicIterator) SetPageSize(pageSize int)

SetPageSize sets the page size for all subsequent calls to NextPage.

func (*TopicIterator) SetPageToken

func (it *TopicIterator) SetPageToken(token string)

SetPageToken sets the page token for the next call to NextPage, to resume the iteration from a previous point.

Jump to

Keyboard shortcuts

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