Send feedback
Class PubSub (2.13.0) Stay organized with collections
Save and categorize content based on your preferences.
Version 2.13.0 keyboard_arrow_down
Package
@google-cloud/pubsub!
Constructors
(constructor)(options)
constructor
(
options
?:
ClientConfig
);
Constructs a new instance of the PubSub
class
Parameter
Properties
api
api
:
{
[
key
:
string
]
:
gax
.
ClientStub
;
};
Property Value
auth
Property Value
getSnapshotsStream
getSnapshotsStream
:
()
=
>
ObjectStream<Snapshot>
;
Property Value
getSubscriptionsStream
getSubscriptionsStream
:
()
=
>
ObjectStream<Subscription>
;
Property Value
getTopicsStream
getTopicsStream
:
()
=
>
ObjectStream<Topic>
;
Property Value
isEmulator
Property Value
isIdResolved
get
isIdResolved
()
:
boolean
;
Returns true if we have actually resolved the full project name.
Property Value
isOpen
Property Value
name
Property Value
options
Property Value
projectId
Property Value
Promise
Promise
?:
PromiseConstructor
;
Property Value
Methods
close()
close
()
:
Promise<void>
;
Returns
close(callback)
close
(
callback
:
EmptyCallback
)
:
void
;
Parameter
Returns
closeAllClients_()
closeAllClients_
()
:
Promise<void>
;
Close all open client objects.
Returns
createSchema(schemaId, type, definition, gaxOpts)
createSchema
(
schemaId
:
string
,
type
:
SchemaType
,
definition
:
string
,
gaxOpts
?:
CallOptions
)
:
Promise<Schema>
;
Parameters Name
Description
schemaId
string
The name or ID of the subscription.
type
SchemaType
The type of the schema (Protobuf, Avro, etc).
definition
string
The text describing the schema in terms of the type.
gaxOpts
CallOptions
Returns
createSubscription(topic, name, options)
createSubscription
(
topic
:
Topic
|
string
,
name
:
string
,
options
?:
CreateSubscriptionOptions
)
:
Promise<CreateSubscriptionResponse>
;
Parameters Name
Description
topic
Topic
| string
name
string
options
CreateSubscriptionOptions
Returns
createSubscription(topic, name, callback)
createSubscription
(
topic
:
Topic
|
string
,
name
:
string
,
callback
:
CreateSubscriptionCallback
)
:
void
;
Parameters Name
Description
topic
Topic
| string
name
string
callback
CreateSubscriptionCallback
Returns
createSubscription(topic, name, options, callback)
createSubscription
(
topic
:
Topic
|
string
,
name
:
string
,
options
:
CreateSubscriptionOptions
,
callback
:
CreateSubscriptionCallback
)
:
void
;
Parameters Name
Description
topic
Topic
| string
name
string
options
CreateSubscriptionOptions
callback
CreateSubscriptionCallback
Returns
createTopic(name, gaxOpts)
createTopic
(
name
:
string
|
TopicMetadata
,
gaxOpts
?:
CallOptions
)
:
Promise<CreateTopicResponse>
;
Parameters Name
Description
name
string | TopicMetadata
gaxOpts
CallOptions
Returns
createTopic(name, callback)
createTopic
(
name
:
string
|
TopicMetadata
,
callback
:
CreateTopicCallback
)
:
void
;
Parameters Name
Description
name
string | TopicMetadata
callback
CreateTopicCallback
Returns
createTopic(name, gaxOpts, callback)
createTopic
(
name
:
string
|
TopicMetadata
,
gaxOpts
:
CallOptions
,
callback
:
CreateTopicCallback
)
:
void
;
Parameters Name
Description
name
string | TopicMetadata
gaxOpts
CallOptions
callback
CreateTopicCallback
Returns
detachSubscription(name, gaxOpts)
detachSubscription
(
name
:
string
,
gaxOpts
?:
CallOptions
)
:
Promise<DetachSubscriptionResponse>
;
Parameters
Returns
detachSubscription(name, callback)
detachSubscription
(
name
:
string
,
callback
:
DetachSubscriptionCallback
)
:
void
;
Parameters Name
Description
name
string
callback
DetachSubscriptionCallback
Returns
detachSubscription(name, gaxOpts, callback)
detachSubscription
(
name
:
string
,
gaxOpts
:
CallOptions
,
callback
:
DetachSubscriptionCallback
)
:
void
;
Parameters Name
Description
name
string
gaxOpts
CallOptions
callback
DetachSubscriptionCallback
Returns
determineBaseUrl_()
determineBaseUrl_
()
:
void
;
Determine the appropriate endpoint to use for API requests, first trying the apiEndpoint
parameter. If that isn't set, we try the Pub/Sub emulator environment variable (PUBSUB_EMULATOR_HOST). If that is also null, we try the standard gcloud alpha pubsub
environment variable (CLOUDSDK_API_ENDPOINT_OVERRIDES_PUBSUB). Otherwise the default production API is used.
Note that if the URL doesn't end in '.googleapis.com', we will assume that it's an emulator and disable strict SSL checks.
Returns
static
formatName_
(
name
:
string
)
:
string
;
Parameter
Returns
getClient_(config, callback)
getClient_
(
config
:
GetClientConfig
,
callback
:
GetClientCallback
)
:
void
;
Get the PubSub client object.
Parameters Name
Description
config
GetClientConfig
Configuration object.
callback
GetClientCallback
The callback function.
Returns
getClientAsync_(config)
getClientAsync_
(
config
:
GetClientConfig
)
:
Promise<gax
.
ClientStub
> ;
Get the PubSub client object.
Parameter Name
Description
config
GetClientConfig
Configuration object.
Returns
getClientConfig()
getClientConfig
()
:
Promise<ClientConfig>
;
Retrieve a client configuration, suitable for passing into a GAPIC 'v1' class constructor. This will fill out projectId, emulator URLs, and so forth.
Returns
getSchemaClient_()
getSchemaClient_
()
:
Promise<SchemaServiceClient>
;
Gets a schema client, creating one if needed.
Returns
getSnapshots(options)
getSnapshots
(
options
?:
PageOptions
)
:
Promise<GetSnapshotsResponse>
;
Parameter
Returns
getSnapshots(callback)
getSnapshots
(
callback
:
GetSnapshotsCallback
)
:
void
;
Parameter
Returns
getSnapshots(options, callback)
getSnapshots
(
options
:
PageOptions
,
callback
:
GetSnapshotsCallback
)
:
void
;
Parameters
Returns
getSubscriptions(options)
getSubscriptions
(
options
?:
GetSubscriptionsOptions
)
:
Promise<GetSubscriptionsResponse>
;
Parameter Name
Description
options
GetSubscriptionsOptions
Returns
getSubscriptions(callback)
getSubscriptions
(
callback
:
GetSubscriptionsCallback
)
:
void
;
Parameter Name
Description
callback
GetSubscriptionsCallback
Returns
getSubscriptions(options, callback)
getSubscriptions
(
options
:
GetSubscriptionsOptions
,
callback
:
GetSubscriptionsCallback
)
:
void
;
Parameters Name
Description
options
GetSubscriptionsOptions
callback
GetSubscriptionsCallback
Returns
getTopics(options)
getTopics
(
options
?:
PageOptions
)
:
Promise<GetTopicsResponse>
;
Parameter
Returns
getTopics(callback)
getTopics
(
callback
:
GetTopicsCallback
)
:
void
;
Parameter
Returns
getTopics(options, callback)
getTopics
(
options
:
PageOptions
,
callback
:
GetTopicsCallback
)
:
void
;
Parameters
Returns
listSchemas(view, options)
listSchemas
(
view
?:
SchemaView
,
options
?:
CallOptions
)
:
AsyncIterable<google
.
pubsub
.
v1
.
ISchema
> ;
Parameters
Returns
request(config, callback)
request<T
,
R
=
void
> (
config
:
RequestConfig
,
callback
:
RequestCallback<T
,
R
> )
:
void
;
Funnel all API requests through this method, to be sure we have a project ID.
Parameters Name
Description
config
RequestConfig
Configuration object.
callback
RequestCallback
<T, R>
The callback function.
Returns
Type Parameters
schema(idOrName)
schema
(
idOrName
:
string
)
:
Schema
;
Create a Schema object, representing a schema within the project. See or to create a schema.
Parameter
Returns
snapshot(name)
snapshot
(
name
:
string
)
:
Snapshot
;
Create a Snapshot object. See to create a snapshot.
Parameter Name
Description
name
string
The name of the snapshot.
Returns
subscription(name, options)
subscription
(
name
:
string
,
options
?:
SubscriptionOptions
)
:
Subscription
;
Create a Subscription object. This command by itself will not run any API requests. You will receive a Subscription
object, which will allow you to interact with a subscription.
Parameters Name
Description
name
string
Name of the subscription.
options
SubscriptionOptions
Configuration object.
Returns
topic(name, options)
topic
(
name
:
string
,
options
?:
PublishOptions
)
:
Topic
;
Create a Topic object. See to create a topic.
Parameters Name
Description
name
string
The name of the topic.
options
PublishOptions
Publisher configuration object.
Returns
validateSchema(schema, gaxOpts)
validateSchema
(
schema
:
ISchema
,
gaxOpts
?:
CallOptions
)
:
Promise<void>
;
Parameters Name
Description
schema
ISchema
The schema definition you wish to validate.
gaxOpts
CallOptions
Returns
Send feedback
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License
, and code samples are licensed under the Apache 2.0 License
. For details, see the Google Developers Site Policies
. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-09-04 UTC.
Need to tell us more?
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,[]]