package pubsub
import "cloud.google.com/go/pubsub/apiv1"
Package pubsub is an experimental, auto-generated package for the Google Cloud Pub/Sub API.
Provides reliable, many-to-many, asynchronous messaging between applications.
Use the client at cloud.google.com/go/pubsub in preference to this.
Index ¶
- func DefaultAuthScopes() []string
- func PublisherProjectPath(project string) string
- func PublisherTopicPath(project, topic string) string
- func SubscriberProjectPath(project string) string
- func SubscriberSnapshotPath(project, snapshot string) string
- func SubscriberSubscriptionPath(project, subscription string) string
- func SubscriberTopicPath(project, topic string) string
- type PublisherCallOptions
- type PublisherClient
- func NewPublisherClient(ctx context.Context, opts ...option.ClientOption) (*PublisherClient, error)
- func (c *PublisherClient) Close() error
- func (c *PublisherClient) Connection() *grpc.ClientConn
- func (c *PublisherClient) CreateTopic(ctx context.Context, req *pubsubpb.Topic, opts ...gax.CallOption) (*pubsubpb.Topic, error)
- func (c *PublisherClient) DeleteTopic(ctx context.Context, req *pubsubpb.DeleteTopicRequest, opts ...gax.CallOption) error
- func (c *PublisherClient) GetTopic(ctx context.Context, req *pubsubpb.GetTopicRequest, opts ...gax.CallOption) (*pubsubpb.Topic, error)
- func (c *PublisherClient) ListTopicSubscriptions(ctx context.Context, req *pubsubpb.ListTopicSubscriptionsRequest, opts ...gax.CallOption) *StringIterator
- func (c *PublisherClient) ListTopics(ctx context.Context, req *pubsubpb.ListTopicsRequest, opts ...gax.CallOption) *TopicIterator
- func (c *PublisherClient) Publish(ctx context.Context, req *pubsubpb.PublishRequest, opts ...gax.CallOption) (*pubsubpb.PublishResponse, error)
- func (c *PublisherClient) SetGoogleClientInfo(keyval ...string)
- func (c *PublisherClient) SubscriptionIAM(subscription *pubsubpb.Subscription) *iam.Handle
- func (c *PublisherClient) TopicIAM(topic *pubsubpb.Topic) *iam.Handle
- func (c *PublisherClient) UpdateTopic(ctx context.Context, req *pubsubpb.UpdateTopicRequest, opts ...gax.CallOption) (*pubsubpb.Topic, error)
- type SnapshotIterator
- func (it *SnapshotIterator) Next() (*pubsubpb.Snapshot, error)
- func (it *SnapshotIterator) PageInfo() *iterator.PageInfo
- type StringIterator
- func (it *StringIterator) Next() (string, error)
- func (it *StringIterator) PageInfo() *iterator.PageInfo
- type SubscriberCallOptions
- type SubscriberClient
- func NewSubscriberClient(ctx context.Context, opts ...option.ClientOption) (*SubscriberClient, error)
- func (c *SubscriberClient) Acknowledge(ctx context.Context, req *pubsubpb.AcknowledgeRequest, opts ...gax.CallOption) error
- func (c *SubscriberClient) Close() error
- func (c *SubscriberClient) Connection() *grpc.ClientConn
- func (c *SubscriberClient) CreateSnapshot(ctx context.Context, req *pubsubpb.CreateSnapshotRequest, opts ...gax.CallOption) (*pubsubpb.Snapshot, error)
- func (c *SubscriberClient) CreateSubscription(ctx context.Context, req *pubsubpb.Subscription, opts ...gax.CallOption) (*pubsubpb.Subscription, error)
- func (c *SubscriberClient) DeleteSnapshot(ctx context.Context, req *pubsubpb.DeleteSnapshotRequest, opts ...gax.CallOption) error
- func (c *SubscriberClient) DeleteSubscription(ctx context.Context, req *pubsubpb.DeleteSubscriptionRequest, opts ...gax.CallOption) error
- func (c *SubscriberClient) GetSubscription(ctx context.Context, req *pubsubpb.GetSubscriptionRequest, opts ...gax.CallOption) (*pubsubpb.Subscription, error)
- func (c *SubscriberClient) ListSnapshots(ctx context.Context, req *pubsubpb.ListSnapshotsRequest, opts ...gax.CallOption) *SnapshotIterator
- func (c *SubscriberClient) ListSubscriptions(ctx context.Context, req *pubsubpb.ListSubscriptionsRequest, opts ...gax.CallOption) *SubscriptionIterator
- func (c *SubscriberClient) ModifyAckDeadline(ctx context.Context, req *pubsubpb.ModifyAckDeadlineRequest, opts ...gax.CallOption) error
- func (c *SubscriberClient) ModifyPushConfig(ctx context.Context, req *pubsubpb.ModifyPushConfigRequest, opts ...gax.CallOption) error
- func (c *SubscriberClient) Pull(ctx context.Context, req *pubsubpb.PullRequest, opts ...gax.CallOption) (*pubsubpb.PullResponse, error)
- func (c *SubscriberClient) Seek(ctx context.Context, req *pubsubpb.SeekRequest, opts ...gax.CallOption) (*pubsubpb.SeekResponse, error)
- func (c *SubscriberClient) SetGoogleClientInfo(keyval ...string)
- func (c *SubscriberClient) StreamingPull(ctx context.Context, opts ...gax.CallOption) (pubsubpb.Subscriber_StreamingPullClient, error)
- func (c *SubscriberClient) SubscriptionIAM(subscription *pubsubpb.Subscription) *iam.Handle
- func (c *SubscriberClient) TopicIAM(topic *pubsubpb.Topic) *iam.Handle
- func (c *SubscriberClient) UpdateSnapshot(ctx context.Context, req *pubsubpb.UpdateSnapshotRequest, opts ...gax.CallOption) (*pubsubpb.Snapshot, error)
- func (c *SubscriberClient) UpdateSubscription(ctx context.Context, req *pubsubpb.UpdateSubscriptionRequest, opts ...gax.CallOption) (*pubsubpb.Subscription, error)
- type SubscriptionIterator
- func (it *SubscriptionIterator) Next() (*pubsubpb.Subscription, error)
- func (it *SubscriptionIterator) PageInfo() *iterator.PageInfo
- type TopicIterator
Examples ¶
- NewPublisherClient
- NewSubscriberClient
- PublisherClient.CreateTopic
- PublisherClient.DeleteTopic
- PublisherClient.GetTopic
- PublisherClient.ListTopicSubscriptions
- PublisherClient.ListTopics
- PublisherClient.Publish
- PublisherClient.SubscriptionIAM
- PublisherClient.TopicIAM
- PublisherClient.UpdateTopic
- SubscriberClient.Acknowledge
- SubscriberClient.CreateSnapshot
- SubscriberClient.CreateSubscription
- SubscriberClient.DeleteSnapshot
- SubscriberClient.DeleteSubscription
- SubscriberClient.GetSubscription
- SubscriberClient.ListSnapshots
- SubscriberClient.ListSubscriptions
- SubscriberClient.ModifyAckDeadline
- SubscriberClient.ModifyPushConfig
- SubscriberClient.Pull
- SubscriberClient.Seek
- SubscriberClient.StreamingPull
- SubscriberClient.SubscriptionIAM
- SubscriberClient.TopicIAM
- SubscriberClient.UpdateSnapshot
- SubscriberClient.UpdateSubscription
Functions ¶
func DefaultAuthScopes ¶
func DefaultAuthScopes() []string
DefaultAuthScopes reports the default set of authentication scopes to use with this package.
func PublisherProjectPath ¶
PublisherProjectPath returns the path for the project resource.
func PublisherTopicPath ¶
PublisherTopicPath returns the path for the topic resource.
func SubscriberProjectPath ¶
SubscriberProjectPath returns the path for the project resource.
func SubscriberSnapshotPath ¶
SubscriberSnapshotPath returns the path for the snapshot resource.
func SubscriberSubscriptionPath ¶
SubscriberSubscriptionPath returns the path for the subscription resource.
func SubscriberTopicPath ¶
SubscriberTopicPath returns the path for the topic resource.
Types ¶
type PublisherCallOptions ¶
type PublisherCallOptions struct { CreateTopic []gax.CallOption UpdateTopic []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 PublisherClient.
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 Google Cloud Pub/Sub API.
func NewPublisherClient ¶
func NewPublisherClient(ctx context.Context, opts ...option.ClientOption) (*PublisherClient, error)
NewPublisherClient creates a new publisher client.
The service that an application uses to manipulate topics, and to send
messages to a topic.
Code:
Example¶
{
ctx := context.Background()
c, err := pubsub.NewPublisherClient(ctx)
if err != nil {
// TODO: Handle error.
}
// TODO: Use client.
_ = c
}
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, opts ...gax.CallOption) (*pubsubpb.Topic, error)
CreateTopic creates the given topic with the given name.
Code:
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
}
func (*PublisherClient) DeleteTopic ¶
func (c *PublisherClient) DeleteTopic(ctx context.Context, req *pubsubpb.DeleteTopicRequest, opts ...gax.CallOption) 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_.
Code:
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.
}
}
func (*PublisherClient) GetTopic ¶
func (c *PublisherClient) GetTopic(ctx context.Context, req *pubsubpb.GetTopicRequest, opts ...gax.CallOption) (*pubsubpb.Topic, error)
GetTopic gets the configuration of a topic.
Code:
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
}
func (*PublisherClient) ListTopicSubscriptions ¶
func (c *PublisherClient) ListTopicSubscriptions(ctx context.Context, req *pubsubpb.ListTopicSubscriptionsRequest, opts ...gax.CallOption) *StringIterator
ListTopicSubscriptions lists the name of the subscriptions for this topic.
Code:
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 == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
}
func (*PublisherClient) ListTopics ¶
func (c *PublisherClient) ListTopics(ctx context.Context, req *pubsubpb.ListTopicsRequest, opts ...gax.CallOption) *TopicIterator
ListTopics lists matching topics.
Code:
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 == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
}
func (*PublisherClient) Publish ¶
func (c *PublisherClient) Publish(ctx context.Context, req *pubsubpb.PublishRequest, opts ...gax.CallOption) (*pubsubpb.PublishResponse, error)
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.
Code:
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
}
func (*PublisherClient) SetGoogleClientInfo ¶
func (c *PublisherClient) SetGoogleClientInfo(keyval ...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.
func (*PublisherClient) SubscriptionIAM ¶
func (c *PublisherClient) SubscriptionIAM(subscription *pubsubpb.Subscription) *iam.Handle
Example¶
Code:
{ ctx := context.Background() c, err := pubsub.NewPublisherClient(ctx) if err != nil { // TODO: Handle error. } subscription := &pubsubpb.Subscription{} h := c.SubscriptionIAM(subscription) policy, err := h.Policy(ctx) if err != nil { // TODO: Handle error. } //TODO: Use the IAM policy _ = policy }
func (*PublisherClient) TopicIAM ¶
func (c *PublisherClient) TopicIAM(topic *pubsubpb.Topic) *iam.Handle
Example¶
Code:
{ ctx := context.Background() c, err := pubsub.NewPublisherClient(ctx) if err != nil { // TODO: Handle error. } topic := &pubsubpb.Topic{} h := c.TopicIAM(topic) policy, err := h.Policy(ctx) if err != nil { // TODO: Handle error. } //TODO: Use the IAM policy _ = policy }
func (*PublisherClient) UpdateTopic ¶
func (c *PublisherClient) UpdateTopic(ctx context.Context, req *pubsubpb.UpdateTopicRequest, opts ...gax.CallOption) (*pubsubpb.Topic, error)
UpdateTopic updates an existing topic. Note that certain properties of a topic are not
modifiable. Options settings follow the style guide:
NOTE: The style guide requires body: "topic" instead of body: "*".
Keeping the latter for internal consistency in V1, however it should be
corrected in V2. See
https://cloud.google.com/apis/design/standard_methods#update for details.
Code:
Example¶
{
ctx := context.Background()
c, err := pubsub.NewPublisherClient(ctx)
if err != nil {
// TODO: Handle error.
}
req := &pubsubpb.UpdateTopicRequest{
// TODO: Fill request struct fields.
}
resp, err := c.UpdateTopic(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
type SnapshotIterator ¶
type SnapshotIterator struct { // InternalFetch is for use by the Google Cloud Libraries only. // It is not part of the stable interface of this package. // // InternalFetch returns results from a single call to the underlying RPC. // The number of results is no greater than pageSize. // If there are no more results, nextPageToken is empty and err is nil. InternalFetch func(pageSize int, pageToken string) (results []*pubsubpb.Snapshot, nextPageToken string, err error) // contains filtered or unexported fields }
SnapshotIterator manages a stream of *pubsubpb.Snapshot.
func (*SnapshotIterator) Next ¶
func (it *SnapshotIterator) Next() (*pubsubpb.Snapshot, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*SnapshotIterator) PageInfo ¶
func (it *SnapshotIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
type StringIterator ¶
type StringIterator struct { // InternalFetch is for use by the Google Cloud Libraries only. // It is not part of the stable interface of this package. // // InternalFetch returns results from a single call to the underlying RPC. // The number of results is no greater than pageSize. // If there are no more results, nextPageToken is empty and err is nil. InternalFetch func(pageSize int, pageToken string) (results []string, nextPageToken string, err error) // 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 iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*StringIterator) PageInfo ¶
func (it *StringIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
type SubscriberCallOptions ¶
type SubscriberCallOptions struct { CreateSubscription []gax.CallOption GetSubscription []gax.CallOption UpdateSubscription []gax.CallOption ListSubscriptions []gax.CallOption DeleteSubscription []gax.CallOption ModifyAckDeadline []gax.CallOption Acknowledge []gax.CallOption Pull []gax.CallOption StreamingPull []gax.CallOption ModifyPushConfig []gax.CallOption ListSnapshots []gax.CallOption CreateSnapshot []gax.CallOption UpdateSnapshot []gax.CallOption DeleteSnapshot []gax.CallOption Seek []gax.CallOption }
SubscriberCallOptions contains the retry settings for each method of SubscriberClient.
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 Google Cloud Pub/Sub API.
func NewSubscriberClient ¶
func NewSubscriberClient(ctx context.Context, opts ...option.ClientOption) (*SubscriberClient, error)
NewSubscriberClient creates a new subscriber client.
The service that an application uses to manipulate subscriptions and to
consume messages from a subscription via the Pull method.
Code:
Example¶
{
ctx := context.Background()
c, err := pubsub.NewSubscriberClient(ctx)
if err != nil {
// TODO: Handle error.
}
// TODO: Use client.
_ = c
}
func (*SubscriberClient) Acknowledge ¶
func (c *SubscriberClient) Acknowledge(ctx context.Context, req *pubsubpb.AcknowledgeRequest, opts ...gax.CallOption) error
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.
Code:
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.
}
}
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) CreateSnapshot ¶
func (c *SubscriberClient) CreateSnapshot(ctx context.Context, req *pubsubpb.CreateSnapshotRequest, opts ...gax.CallOption) (*pubsubpb.Snapshot, error)
CreateSnapshot creates a snapshot from the requested subscription. If the snapshot already exists, returns ALREADY_EXISTS. If the requested subscription doesn't exist, returns NOT_FOUND.
If the name is not provided in the request, the server will assign a random
name for this snapshot on the same project as the subscription, conforming
to the
resource name format (at https://cloud.google.com/pubsub/docs/overview#names).
The generated name is populated in the returned Snapshot object.
Note that for REST API requests, you must specify a name in the request.
Code:
Example¶
{
ctx := context.Background()
c, err := pubsub.NewSubscriberClient(ctx)
if err != nil {
// TODO: Handle error.
}
req := &pubsubpb.CreateSnapshotRequest{
// TODO: Fill request struct fields.
}
resp, err := c.CreateSnapshot(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SubscriberClient) CreateSubscription ¶
func (c *SubscriberClient) CreateSubscription(ctx context.Context, req *pubsubpb.Subscription, opts ...gax.CallOption) (*pubsubpb.Subscription, error)
CreateSubscription creates a subscription to a given topic. 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, conforming
to the
resource name format (at https://cloud.google.com/pubsub/docs/overview#names).
The generated name is populated in the returned Subscription object.
Note that for REST API requests, you must specify a name in the request.
Code:
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
}
func (*SubscriberClient) DeleteSnapshot ¶
func (c *SubscriberClient) DeleteSnapshot(ctx context.Context, req *pubsubpb.DeleteSnapshotRequest, opts ...gax.CallOption) error
DeleteSnapshot removes an existing snapshot. All messages retained in the snapshot
are immediately dropped. After a snapshot is deleted, a new one may be
created with the same name, but the new one has no association with the old
snapshot or its subscription, unless the same subscription is specified.
Code:
Example¶
{
ctx := context.Background()
c, err := pubsub.NewSubscriberClient(ctx)
if err != nil {
// TODO: Handle error.
}
req := &pubsubpb.DeleteSnapshotRequest{
// TODO: Fill request struct fields.
}
err = c.DeleteSnapshot(ctx, req)
if err != nil {
// TODO: Handle error.
}
}
func (*SubscriberClient) DeleteSubscription ¶
func (c *SubscriberClient) DeleteSubscription(ctx context.Context, req *pubsubpb.DeleteSubscriptionRequest, opts ...gax.CallOption) error
DeleteSubscription deletes an existing subscription. All messages retained 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.
Code:
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.
}
}
func (*SubscriberClient) GetSubscription ¶
func (c *SubscriberClient) GetSubscription(ctx context.Context, req *pubsubpb.GetSubscriptionRequest, opts ...gax.CallOption) (*pubsubpb.Subscription, error)
GetSubscription gets the configuration details of a subscription.
Code:
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
}
func (*SubscriberClient) ListSnapshots ¶
func (c *SubscriberClient) ListSnapshots(ctx context.Context, req *pubsubpb.ListSnapshotsRequest, opts ...gax.CallOption) *SnapshotIterator
ListSnapshots lists the existing snapshots.
Code:
Example¶
{
ctx := context.Background()
c, err := pubsub.NewSubscriberClient(ctx)
if err != nil {
// TODO: Handle error.
}
req := &pubsubpb.ListSnapshotsRequest{
// TODO: Fill request struct fields.
}
it := c.ListSnapshots(ctx, req)
for {
resp, err := it.Next()
if err == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
}
func (*SubscriberClient) ListSubscriptions ¶
func (c *SubscriberClient) ListSubscriptions(ctx context.Context, req *pubsubpb.ListSubscriptionsRequest, opts ...gax.CallOption) *SubscriptionIterator
ListSubscriptions lists matching subscriptions.
Code:
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 == iterator.Done {
break
}
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
}
func (*SubscriberClient) ModifyAckDeadline ¶
func (c *SubscriberClient) ModifyAckDeadline(ctx context.Context, req *pubsubpb.ModifyAckDeadlineRequest, opts ...gax.CallOption) 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. Note that this does not modify the
subscription-level ackDeadlineSeconds used for subsequent messages.
Code:
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.
}
}
func (*SubscriberClient) ModifyPushConfig ¶
func (c *SubscriberClient) ModifyPushConfig(ctx context.Context, req *pubsubpb.ModifyPushConfigRequest, opts ...gax.CallOption) 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.
Code:
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.
}
}
func (*SubscriberClient) Pull ¶
func (c *SubscriberClient) Pull(ctx context.Context, req *pubsubpb.PullRequest, opts ...gax.CallOption) (*pubsubpb.PullResponse, error)
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.
Code:
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
}
func (*SubscriberClient) Seek ¶
func (c *SubscriberClient) Seek(ctx context.Context, req *pubsubpb.SeekRequest, opts ...gax.CallOption) (*pubsubpb.SeekResponse, error)
Seek seeks an existing subscription to a point in time or to a given snapshot,
whichever is provided in the request.
Code:
Example¶
{
ctx := context.Background()
c, err := pubsub.NewSubscriberClient(ctx)
if err != nil {
// TODO: Handle error.
}
req := &pubsubpb.SeekRequest{
// TODO: Fill request struct fields.
}
resp, err := c.Seek(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SubscriberClient) SetGoogleClientInfo ¶
func (c *SubscriberClient) SetGoogleClientInfo(keyval ...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.
func (*SubscriberClient) StreamingPull ¶
func (c *SubscriberClient) StreamingPull(ctx context.Context, opts ...gax.CallOption) (pubsubpb.Subscriber_StreamingPullClient, error)
StreamingPull (EXPERIMENTAL) StreamingPull is an experimental feature. This RPC will respond with UNIMPLEMENTED errors unless you have been invited to test this feature. Contact cloud-pubsub@google.com with any questions.
Establishes a stream with the server, which sends messages down to the
client. The client streams acknowledgements and ack deadline modifications
back to the server. The server will close the stream and return the status
on any error. The server may close the stream with status OK to reassign
server-side resources, in which case, the client should re-establish the
stream. UNAVAILABLE may also be returned in the case of a transient error
(e.g., a server restart). These should also be retried by the client. Flow
control can be achieved by configuring the underlying RPC channel.
Code:
Example¶
{
ctx := context.Background()
c, err := pubsub.NewSubscriberClient(ctx)
if err != nil {
// TODO: Handle error.
}
stream, err := c.StreamingPull(ctx)
if err != nil {
// TODO: Handle error.
}
go func() {
reqs := []*pubsubpb.StreamingPullRequest{
// TODO: Create requests.
}
for _, req := range reqs {
if err := stream.Send(req); err != nil {
// TODO: Handle error.
}
}
stream.CloseSend()
}()
for {
resp, err := stream.Recv()
if err == io.EOF {
break
}
if err != nil {
// TODO: handle error.
}
// TODO: Use resp.
_ = resp
}
}
func (*SubscriberClient) SubscriptionIAM ¶
func (c *SubscriberClient) SubscriptionIAM(subscription *pubsubpb.Subscription) *iam.Handle
Example¶
Code:
{ ctx := context.Background() c, err := pubsub.NewSubscriberClient(ctx) if err != nil { // TODO: Handle error. } subscription := &pubsubpb.Subscription{} h := c.SubscriptionIAM(subscription) policy, err := h.Policy(ctx) if err != nil { // TODO: Handle error. } //TODO: Use the IAM policy _ = policy }
func (*SubscriberClient) TopicIAM ¶
func (c *SubscriberClient) TopicIAM(topic *pubsubpb.Topic) *iam.Handle
Example¶
Code:
{ ctx := context.Background() c, err := pubsub.NewSubscriberClient(ctx) if err != nil { // TODO: Handle error. } topic := &pubsubpb.Topic{} h := c.TopicIAM(topic) policy, err := h.Policy(ctx) if err != nil { // TODO: Handle error. } //TODO: Use the IAM policy _ = policy }
func (*SubscriberClient) UpdateSnapshot ¶
func (c *SubscriberClient) UpdateSnapshot(ctx context.Context, req *pubsubpb.UpdateSnapshotRequest, opts ...gax.CallOption) (*pubsubpb.Snapshot, error)
UpdateSnapshot updates an existing snapshot. Note that certain properties of a snapshot
are not modifiable.
NOTE: The style guide requires body: "snapshot" instead of body: "*".
Keeping the latter for internal consistency in V1, however it should be
corrected in V2. See
https://cloud.google.com/apis/design/standard_methods#update for details.
Code:
Example¶
{
ctx := context.Background()
c, err := pubsub.NewSubscriberClient(ctx)
if err != nil {
// TODO: Handle error.
}
req := &pubsubpb.UpdateSnapshotRequest{
// TODO: Fill request struct fields.
}
resp, err := c.UpdateSnapshot(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
func (*SubscriberClient) UpdateSubscription ¶
func (c *SubscriberClient) UpdateSubscription(ctx context.Context, req *pubsubpb.UpdateSubscriptionRequest, opts ...gax.CallOption) (*pubsubpb.Subscription, error)
UpdateSubscription updates an existing subscription. Note that certain properties of a
subscription, such as its topic, are not modifiable.
NOTE: The style guide requires body: "subscription" instead of body: "*".
Keeping the latter for internal consistency in V1, however it should be
corrected in V2. See
https://cloud.google.com/apis/design/standard_methods#update for details.
Code:
Example¶
{
ctx := context.Background()
c, err := pubsub.NewSubscriberClient(ctx)
if err != nil {
// TODO: Handle error.
}
req := &pubsubpb.UpdateSubscriptionRequest{
// TODO: Fill request struct fields.
}
resp, err := c.UpdateSubscription(ctx, req)
if err != nil {
// TODO: Handle error.
}
// TODO: Use resp.
_ = resp
}
type SubscriptionIterator ¶
type SubscriptionIterator struct { // InternalFetch is for use by the Google Cloud Libraries only. // It is not part of the stable interface of this package. // // InternalFetch returns results from a single call to the underlying RPC. // The number of results is no greater than pageSize. // If there are no more results, nextPageToken is empty and err is nil. InternalFetch func(pageSize int, pageToken string) (results []*pubsubpb.Subscription, nextPageToken string, err error) // contains filtered or unexported fields }
SubscriptionIterator manages a stream of *pubsubpb.Subscription.
func (*SubscriptionIterator) Next ¶
func (it *SubscriptionIterator) Next() (*pubsubpb.Subscription, error)
Next returns the next result. Its second return value is iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*SubscriptionIterator) PageInfo ¶
func (it *SubscriptionIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
type TopicIterator ¶
type TopicIterator struct { // InternalFetch is for use by the Google Cloud Libraries only. // It is not part of the stable interface of this package. // // InternalFetch returns results from a single call to the underlying RPC. // The number of results is no greater than pageSize. // If there are no more results, nextPageToken is empty and err is nil. InternalFetch func(pageSize int, pageToken string) (results []*pubsubpb.Topic, nextPageToken string, err error) // 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 iterator.Done if there are no more results. Once Next returns Done, all subsequent calls will return Done.
func (*TopicIterator) PageInfo ¶
func (it *TopicIterator) PageInfo() *iterator.PageInfo
PageInfo supports pagination. See the google.golang.org/api/iterator package for details.
Source Files ¶
doc.go publisher_client.go subscriber_client.go
- Version
- v0.13.0
- Published
- Sep 11, 2017
- Platform
- windows/amd64
- Imports
- 13 packages
- Last checked
- 34 minutes ago –
Tools for package owners.