Constructor
new SubscriberClient(optionsopt)
Construct an instance of SubscriberClient.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
<optional> |
The configuration object. See the subsequent parameters for more details. Properties
|
- Source:
Members
(static) apiEndpoint
The DNS address for this API service - same as servicePath(), exists for compatibility reasons.
- Source:
(static) port
The port for this API service.
- Source:
(static) scopes
The scopes needed to make gRPC calls for every method defined in this service.
- Source:
(static) servicePath
The DNS address for this API service.
- Source:
Methods
acknowledge(request, optionsopt, callbackopt) → {Promise}
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.
Parameters:
Name | Type | Attributes | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
||||||||||
options |
Object |
<optional> |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
|||||||||
callback |
function |
<optional> |
The function which will be called with the result of the API call. |
- Source:
Example
const pubsub = require('@google-cloud/pubsub');
const client = new pubsub.v1.SubscriberClient({
// optional auth parameters.
});
const formattedSubscription = client.subscriptionPath('[PROJECT]', '[SUBSCRIPTION]');
const ackIds = [];
const request = {
subscription: formattedSubscription,
ackIds: ackIds,
};
client.acknowledge(request).catch(err => {
console.error(err);
});
createSnapshot(request, optionsopt, callbackopt) → {Promise}
Creates a snapshot from the requested subscription. Snapshots are used in
Seek
operations, which allow
you to manage message acknowledgments in bulk. That is, you can set the
acknowledgment state of messages in an existing subscription to the state
captured by a snapshot.
If the snapshot already exists, returns ALREADY_EXISTS
.
If the requested subscription doesn't exist, returns NOT_FOUND
.
If the backlog in the subscription is too old -- and the resulting snapshot
would expire in less than 1 hour -- then FAILED_PRECONDITION
is returned.
See also the Snapshot.expire_time
field. 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. The
generated name is populated in the returned Snapshot object. Note that for
REST API requests, you must specify a name in the request.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
|||||||||||||||||
options |
Object |
<optional> |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||||||||||||
callback |
function |
<optional> |
The function which will be called with the result of the API call. The second parameter to the callback is an object representing Snapshot. |
- Source:
Example
const pubsub = require('@google-cloud/pubsub');
const client = new pubsub.v1.SubscriberClient({
// optional auth parameters.
});
const formattedName = client.snapshotPath('[PROJECT]', '[SNAPSHOT]');
const formattedSubscription = client.subscriptionPath('[PROJECT]', '[SUBSCRIPTION]');
const request = {
name: formattedName,
subscription: formattedSubscription,
};
client.createSnapshot(request)
.then(responses => {
const response = responses[0];
// doThingsWith(response)
})
.catch(err => {
console.error(err);
});
createSubscription(request, optionsopt, callbackopt) → {Promise}
Creates a subscription to a given topic. See the
resource name rules.
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. The generated name is populated in the returned Subscription object. Note that for REST API requests, you must specify a name in the request.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
|||||||||||||||||||||||||||||||||||||||||||||
options |
Object |
<optional> |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||||||||||||||||||||||||||||||||||||||||
callback |
function |
<optional> |
The function which will be called with the result of the API call. The second parameter to the callback is an object representing Subscription. |
- Source:
Example
const pubsub = require('@google-cloud/pubsub');
const client = new pubsub.v1.SubscriberClient({
// optional auth parameters.
});
const formattedName = client.subscriptionPath('[PROJECT]', '[SUBSCRIPTION]');
const formattedTopic = client.topicPath('[PROJECT]', '[TOPIC]');
const request = {
name: formattedName,
topic: formattedTopic,
};
client.createSubscription(request)
.then(responses => {
const response = responses[0];
// doThingsWith(response)
})
.catch(err => {
console.error(err);
});
deleteSnapshot(request, optionsopt, callbackopt) → {Promise}
Removes an existing snapshot. Snapshots are used in
Seek
operations, which allow
you to manage message acknowledgments in bulk. That is, you can set the
acknowledgment state of messages in an existing subscription to the state
captured by a snapshot.
When the snapshot is deleted, 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.
Parameters:
Name | Type | Attributes | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
|||||||
options |
Object |
<optional> |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||
callback |
function |
<optional> |
The function which will be called with the result of the API call. |
- Source:
Example
const pubsub = require('@google-cloud/pubsub');
const client = new pubsub.v1.SubscriberClient({
// optional auth parameters.
});
const formattedSnapshot = client.snapshotPath('[PROJECT]', '[SNAPSHOT]');
client.deleteSnapshot({snapshot: formattedSnapshot}).catch(err => {
console.error(err);
});
deleteSubscription(request, optionsopt, callbackopt) → {Promise}
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.
Parameters:
Name | Type | Attributes | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
|||||||
options |
Object |
<optional> |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||
callback |
function |
<optional> |
The function which will be called with the result of the API call. |
- Source:
Example
const pubsub = require('@google-cloud/pubsub');
const client = new pubsub.v1.SubscriberClient({
// optional auth parameters.
});
const formattedSubscription = client.subscriptionPath('[PROJECT]', '[SUBSCRIPTION]');
client.deleteSubscription({subscription: formattedSubscription}).catch(err => {
console.error(err);
});
getIamPolicy(request, optionsopt, callbackopt) → {Promise}
Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
Parameters:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
|||||||||||||
options |
Object |
<optional> |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||||||||
callback |
function |
<optional> |
The function which will be called with the result of the API call. The second parameter to the callback is an object representing Policy. |
- Source:
Example
const pubsub = require('@google-cloud/pubsub');
const client = new pubsub.v1.SubscriberClient({
// optional auth parameters.
});
const formattedResource = client.subscriptionPath('[PROJECT]', '[SUBSCRIPTION]');
client.getIamPolicy({resource: formattedResource})
.then(responses => {
const response = responses[0];
// doThingsWith(response)
})
.catch(err => {
console.error(err);
});
getProjectId(callback)
Return the project ID used by this class.
Parameters:
Name | Type | Description |
---|---|---|
callback |
function |
the callback to be called with the current project Id. |
- Source:
getSubscription(request, optionsopt, callbackopt) → {Promise}
Gets the configuration details of a subscription.
Parameters:
Name | Type | Attributes | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
|||||||
options |
Object |
<optional> |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||
callback |
function |
<optional> |
The function which will be called with the result of the API call. The second parameter to the callback is an object representing Subscription. |
- Source:
Example
const pubsub = require('@google-cloud/pubsub');
const client = new pubsub.v1.SubscriberClient({
// optional auth parameters.
});
const formattedSubscription = client.subscriptionPath('[PROJECT]', '[SUBSCRIPTION]');
client.getSubscription({subscription: formattedSubscription})
.then(responses => {
const response = responses[0];
// doThingsWith(response)
})
.catch(err => {
console.error(err);
});
listSnapshots(request, optionsopt, callbackopt) → {Promise}
Lists the existing snapshots. Snapshots are used in Seek operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot.
Parameters:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
|||||||||||||
options |
Object |
<optional> |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||||||||
callback |
function |
<optional> |
The function which will be called with the result of the API call. The second parameter to the callback is Array of Snapshot. When autoPaginate: false is specified through options, it contains the result in a single response. If the response indicates the next page exists, the third parameter is set to be used for the next request object. The fourth parameter keeps the raw response object of an object representing ListSnapshotsResponse. |
- Source:
Example
const pubsub = require('@google-cloud/pubsub');
const client = new pubsub.v1.SubscriberClient({
// optional auth parameters.
});
// Iterate over all elements.
const formattedProject = client.projectPath('[PROJECT]');
client.listSnapshots({project: formattedProject})
.then(responses => {
const resources = responses[0];
for (const resource of resources) {
// doThingsWith(resource)
}
})
.catch(err => {
console.error(err);
});
// Or obtain the paged response.
const formattedProject = client.projectPath('[PROJECT]');
const options = {autoPaginate: false};
const callback = responses => {
// The actual resources in a response.
const resources = responses[0];
// The next request if the response shows that there are more responses.
const nextRequest = responses[1];
// The actual response object, if necessary.
// const rawResponse = responses[2];
for (const resource of resources) {
// doThingsWith(resource);
}
if (nextRequest) {
// Fetch the next page.
return client.listSnapshots(nextRequest, options).then(callback);
}
}
client.listSnapshots({project: formattedProject}, options)
.then(callback)
.catch(err => {
console.error(err);
});
listSnapshotsStream(request, optionsopt) → {Stream}
Equivalent to listSnapshots, but returns a NodeJS Stream object.
This fetches the paged responses for listSnapshots continuously and invokes the callback registered for 'data' event for each element in the responses.
The returned object has 'end' method when no more elements are required.
autoPaginate option will be ignored.
Parameters:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
|||||||||||||
options |
Object |
<optional> |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
Example
const pubsub = require('@google-cloud/pubsub');
const client = new pubsub.v1.SubscriberClient({
// optional auth parameters.
});
const formattedProject = client.projectPath('[PROJECT]');
client.listSnapshotsStream({project: formattedProject})
.on('data', element => {
// doThingsWith(element)
}).on('error', err => {
console.log(err);
});
listSubscriptions(request, optionsopt, callbackopt) → {Promise}
Lists matching subscriptions.
Parameters:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
|||||||||||||
options |
Object |
<optional> |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||||||||
callback |
function |
<optional> |
The function which will be called with the result of the API call. The second parameter to the callback is Array of Subscription. When autoPaginate: false is specified through options, it contains the result in a single response. If the response indicates the next page exists, the third parameter is set to be used for the next request object. The fourth parameter keeps the raw response object of an object representing ListSubscriptionsResponse. |
- Source:
Example
const pubsub = require('@google-cloud/pubsub');
const client = new pubsub.v1.SubscriberClient({
// optional auth parameters.
});
// Iterate over all elements.
const formattedProject = client.projectPath('[PROJECT]');
client.listSubscriptions({project: formattedProject})
.then(responses => {
const resources = responses[0];
for (const resource of resources) {
// doThingsWith(resource)
}
})
.catch(err => {
console.error(err);
});
// Or obtain the paged response.
const formattedProject = client.projectPath('[PROJECT]');
const options = {autoPaginate: false};
const callback = responses => {
// The actual resources in a response.
const resources = responses[0];
// The next request if the response shows that there are more responses.
const nextRequest = responses[1];
// The actual response object, if necessary.
// const rawResponse = responses[2];
for (const resource of resources) {
// doThingsWith(resource);
}
if (nextRequest) {
// Fetch the next page.
return client.listSubscriptions(nextRequest, options).then(callback);
}
}
client.listSubscriptions({project: formattedProject}, options)
.then(callback)
.catch(err => {
console.error(err);
});
listSubscriptionsStream(request, optionsopt) → {Stream}
Equivalent to listSubscriptions, but returns a NodeJS Stream object.
This fetches the paged responses for listSubscriptions continuously and invokes the callback registered for 'data' event for each element in the responses.
The returned object has 'end' method when no more elements are required.
autoPaginate option will be ignored.
Parameters:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
|||||||||||||
options |
Object |
<optional> |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
Example
const pubsub = require('@google-cloud/pubsub');
const client = new pubsub.v1.SubscriberClient({
// optional auth parameters.
});
const formattedProject = client.projectPath('[PROJECT]');
client.listSubscriptionsStream({project: formattedProject})
.on('data', element => {
// doThingsWith(element)
}).on('error', err => {
console.log(err);
});
matchProjectFromProjectName(projectName) → {String}
Parse the projectName from a project resource.
Parameters:
Name | Type | Description |
---|---|---|
projectName |
String |
A fully-qualified path representing a project resources. |
- Source:
matchProjectFromSnapshotName(snapshotName) → {String}
Parse the snapshotName from a snapshot resource.
Parameters:
Name | Type | Description |
---|---|---|
snapshotName |
String |
A fully-qualified path representing a snapshot resources. |
- Source:
matchProjectFromSubscriptionName(subscriptionName) → {String}
Parse the subscriptionName from a subscription resource.
Parameters:
Name | Type | Description |
---|---|---|
subscriptionName |
String |
A fully-qualified path representing a subscription resources. |
- Source:
matchProjectFromTopicName(topicName) → {String}
Parse the topicName from a topic resource.
Parameters:
Name | Type | Description |
---|---|---|
topicName |
String |
A fully-qualified path representing a topic resources. |
- Source:
matchSnapshotFromSnapshotName(snapshotName) → {String}
Parse the snapshotName from a snapshot resource.
Parameters:
Name | Type | Description |
---|---|---|
snapshotName |
String |
A fully-qualified path representing a snapshot resources. |
- Source:
matchSubscriptionFromSubscriptionName(subscriptionName) → {String}
Parse the subscriptionName from a subscription resource.
Parameters:
Name | Type | Description |
---|---|---|
subscriptionName |
String |
A fully-qualified path representing a subscription resources. |
- Source:
matchTopicFromTopicName(topicName) → {String}
Parse the topicName from a topic resource.
Parameters:
Name | Type | Description |
---|---|---|
topicName |
String |
A fully-qualified path representing a topic resources. |
- Source:
modifyAckDeadline(request, optionsopt, callbackopt) → {Promise}
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.
Parameters:
Name | Type | Attributes | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
|||||||||||||
options |
Object |
<optional> |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||||||||
callback |
function |
<optional> |
The function which will be called with the result of the API call. |
- Source:
Example
const pubsub = require('@google-cloud/pubsub');
const client = new pubsub.v1.SubscriberClient({
// optional auth parameters.
});
const formattedSubscription = client.subscriptionPath('[PROJECT]', '[SUBSCRIPTION]');
const ackIds = [];
const ackDeadlineSeconds = 0;
const request = {
subscription: formattedSubscription,
ackIds: ackIds,
ackDeadlineSeconds: ackDeadlineSeconds,
};
client.modifyAckDeadline(request).catch(err => {
console.error(err);
});
modifyPushConfig(request, optionsopt, callbackopt) → {Promise}
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
.
Parameters:
Name | Type | Attributes | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
||||||||||
options |
Object |
<optional> |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
|||||||||
callback |
function |
<optional> |
The function which will be called with the result of the API call. |
- Source:
Example
const pubsub = require('@google-cloud/pubsub');
const client = new pubsub.v1.SubscriberClient({
// optional auth parameters.
});
const formattedSubscription = client.subscriptionPath('[PROJECT]', '[SUBSCRIPTION]');
const pushConfig = {};
const request = {
subscription: formattedSubscription,
pushConfig: pushConfig,
};
client.modifyPushConfig(request).catch(err => {
console.error(err);
});
projectPath(project) → {String}
Return a fully-qualified project resource name string.
Parameters:
Name | Type | Description |
---|---|---|
project |
String |
- Source:
pull(request, optionsopt, callbackopt) → {Promise}
Pulls messages from the server. The server may return UNAVAILABLE
if
there are too many concurrent pull requests pending for the given
subscription.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
|||||||||||||||||
options |
Object |
<optional> |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||||||||||||
callback |
function |
<optional> |
The function which will be called with the result of the API call. The second parameter to the callback is an object representing PullResponse. |
- Source:
Example
const pubsub = require('@google-cloud/pubsub');
const client = new pubsub.v1.SubscriberClient({
// optional auth parameters.
});
const formattedSubscription = client.subscriptionPath('[PROJECT]', '[SUBSCRIPTION]');
const maxMessages = 0;
const request = {
subscription: formattedSubscription,
maxMessages: maxMessages,
};
client.pull(request)
.then(responses => {
const response = responses[0];
// doThingsWith(response)
})
.catch(err => {
console.error(err);
});
seek(request, optionsopt, callbackopt) → {Promise}
Seeks an existing subscription to a point in time or to a given snapshot, whichever is provided in the request. Snapshots are used in Seek operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot. Note that both the subscription and the snapshot must be on the same topic.
Parameters:
Name | Type | Attributes | Description | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
|||||||||||||||||
options |
Object |
<optional> |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
||||||||||||||||
callback |
function |
<optional> |
The function which will be called with the result of the API call. The second parameter to the callback is an object representing SeekResponse. |
- Source:
Example
const pubsub = require('@google-cloud/pubsub');
const client = new pubsub.v1.SubscriberClient({
// optional auth parameters.
});
const formattedSubscription = client.subscriptionPath('[PROJECT]', '[SUBSCRIPTION]');
client.seek({subscription: formattedSubscription})
.then(responses => {
const response = responses[0];
// doThingsWith(response)
})
.catch(err => {
console.error(err);
});
setIamPolicy(request, optionsopt, callbackopt) → {Promise}
Sets the access control policy on the specified resource. Replaces any existing policy.
Parameters:
Name | Type | Attributes | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
||||||||||
options |
Object |
<optional> |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
|||||||||
callback |
function |
<optional> |
The function which will be called with the result of the API call. The second parameter to the callback is an object representing Policy. |
- Source:
Example
const pubsub = require('@google-cloud/pubsub');
const client = new pubsub.v1.SubscriberClient({
// optional auth parameters.
});
const formattedResource = client.subscriptionPath('[PROJECT]', '[SUBSCRIPTION]');
const policy = {};
const request = {
resource: formattedResource,
policy: policy,
};
client.setIamPolicy(request)
.then(responses => {
const response = responses[0];
// doThingsWith(response)
})
.catch(err => {
console.error(err);
});
snapshotPath(project, snapshot) → {String}
Return a fully-qualified snapshot resource name string.
Parameters:
Name | Type | Description |
---|---|---|
project |
String | |
snapshot |
String |
- Source:
streamingPull(optionsopt) → {Stream}
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 UNAVAILABLE
to
reassign server-side resources, in which case, the client should
re-establish the stream. Flow control can be achieved by configuring the
underlying RPC channel.
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
options |
Object |
<optional> |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
- Source:
Example
const pubsub = require('@google-cloud/pubsub');
const client = new pubsub.v1.SubscriberClient({
// optional auth parameters.
});
const stream = client.streamingPull().on('data', response => {
// doThingsWith(response)
});
const formattedSubscription = client.subscriptionPath('[PROJECT]', '[SUBSCRIPTION]');
const streamAckDeadlineSeconds = 0;
const request = {
subscription: formattedSubscription,
streamAckDeadlineSeconds: streamAckDeadlineSeconds,
};
// Write request objects.
stream.write(request);
subscriptionPath(project, subscription) → {String}
Return a fully-qualified subscription resource name string.
Parameters:
Name | Type | Description |
---|---|---|
project |
String | |
subscription |
String |
- Source:
testIamPermissions(request, optionsopt, callbackopt) → {Promise}
Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a NOT_FOUND error.
Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
Parameters:
Name | Type | Attributes | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
||||||||||
options |
Object |
<optional> |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
|||||||||
callback |
function |
<optional> |
The function which will be called with the result of the API call. The second parameter to the callback is an object representing TestIamPermissionsResponse. |
- Source:
Example
const pubsub = require('@google-cloud/pubsub');
const client = new pubsub.v1.SubscriberClient({
// optional auth parameters.
});
const formattedResource = client.subscriptionPath('[PROJECT]', '[SUBSCRIPTION]');
const permissions = [];
const request = {
resource: formattedResource,
permissions: permissions,
};
client.testIamPermissions(request)
.then(responses => {
const response = responses[0];
// doThingsWith(response)
})
.catch(err => {
console.error(err);
});
topicPath(project, topic) → {String}
Return a fully-qualified topic resource name string.
Parameters:
Name | Type | Description |
---|---|---|
project |
String | |
topic |
String |
- Source:
updateSnapshot(request, optionsopt, callbackopt) → {Promise}
Updates an existing snapshot. Snapshots are used in Seek operations, which allow you to manage message acknowledgments in bulk. That is, you can set the acknowledgment state of messages in an existing subscription to the state captured by a snapshot.
Parameters:
Name | Type | Attributes | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
||||||||||
options |
Object |
<optional> |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
|||||||||
callback |
function |
<optional> |
The function which will be called with the result of the API call. The second parameter to the callback is an object representing Snapshot. |
- Source:
Example
const pubsub = require('@google-cloud/pubsub');
const client = new pubsub.v1.SubscriberClient({
// optional auth parameters.
});
const seconds = 123456;
const expireTime = {
seconds: seconds,
};
const snapshot = {
expireTime: expireTime,
};
const pathsElement = 'expire_time';
const paths = [pathsElement];
const updateMask = {
paths: paths,
};
const request = {
snapshot: snapshot,
updateMask: updateMask,
};
client.updateSnapshot(request)
.then(responses => {
const response = responses[0];
// doThingsWith(response)
})
.catch(err => {
console.error(err);
});
updateSubscription(request, optionsopt, callbackopt) → {Promise}
Updates an existing subscription. Note that certain properties of a subscription, such as its topic, are not modifiable.
Parameters:
Name | Type | Attributes | Description | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
request |
Object |
The request object that will be sent. Properties
|
||||||||||
options |
Object |
<optional> |
Optional parameters. You can override the default settings for this call, e.g, timeout, retries, paginations, etc. See gax.CallOptions for the details. |
|||||||||
callback |
function |
<optional> |
The function which will be called with the result of the API call. The second parameter to the callback is an object representing Subscription. |
- Source:
Example
const pubsub = require('@google-cloud/pubsub');
const client = new pubsub.v1.SubscriberClient({
// optional auth parameters.
});
const ackDeadlineSeconds = 42;
const subscription = {
ackDeadlineSeconds: ackDeadlineSeconds,
};
const pathsElement = 'ack_deadline_seconds';
const paths = [pathsElement];
const updateMask = {
paths: paths,
};
const request = {
subscription: subscription,
updateMask: updateMask,
};
client.updateSubscription(request)
.then(responses => {
const response = responses[0];
// doThingsWith(response)
})
.catch(err => {
console.error(err);
});