New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@google-cloud/pubsub

Package Overview
Dependencies
Maintainers
1
Versions
171
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@google-cloud/pubsub - npm Package Compare versions

Comparing version 2.2.0 to 2.3.0

2

build/src/message-stream.js

@@ -171,2 +171,4 @@ "use strict";

streamAckDeadlineSeconds: this._subscriber.ackDeadline,
maxOutstandingMessages: this._subscriber.maxMessages,
maxOutstandingBytes: this._subscriber.maxBytes,
};

@@ -173,0 +175,0 @@ delete this._fillHandle;

@@ -20,3 +20,3 @@ /*!

import { Snapshot } from './snapshot';
import { Subscription, SubscriptionOptions, CreateSubscriptionOptions, CreateSubscriptionCallback, CreateSubscriptionResponse } from './subscription';
import { Subscription, SubscriptionOptions, CreateSubscriptionOptions, CreateSubscriptionCallback, CreateSubscriptionResponse, DetachSubscriptionCallback, DetachSubscriptionResponse } from './subscription';
import { Topic, GetTopicSubscriptionsCallback, GetTopicSubscriptionsResponse, CreateTopicCallback, CreateTopicResponse } from './topic';

@@ -55,2 +55,4 @@ import { PublishOptions } from './publisher';

export declare type ExistsResponse = [boolean];
export declare type DetachedCallback = RequestCallback<boolean>;
export declare type DetachedResponse = [boolean];
export interface GetClientConfig {

@@ -165,2 +167,5 @@ client: 'PublisherClient' | 'SubscriberClient';

createTopic(name: string, gaxOpts: CallOptions, callback: CreateTopicCallback): void;
detachSubscription(name: string, gaxOpts?: CallOptions): Promise<DetachSubscriptionResponse>;
detachSubscription(name: string, callback: DetachSubscriptionCallback): void;
detachSubscription(name: string, gaxOpts: CallOptions, callback: DetachSubscriptionCallback): void;
/**

@@ -167,0 +172,0 @@ * Determine the appropriate endpoint to use for API requests, first trying

@@ -335,2 +335,47 @@ "use strict";

/**
* Detach a subscription with the given name.
*
* @see [Admin: Pub/Sub administration API Documentation]{@link https://cloud.google.com/pubsub/docs/admin}
*
* @param {string} name Name of the subscription.
* @param {object} [gaxOpts] Request configuration options, outlined
* here: https://googleapis.github.io/gax-nodejs/interfaces/CallOptions.html.
* @param {DetachSubscriptionCallback} [callback] Callback function.
* @returns {Promise<DetachSubscriptionResponse>}
*
* @example
* const {PubSub} = require('@google-cloud/pubsub');
* const pubsub = new PubSub();
*
* pubsub.detachSubscription('my-sub', (err, topic, apiResponse) => {
* if (!err) {
* // The topic was created successfully.
* }
* });
*
* //-
* // If the callback is omitted, we'll return a Promise.
* //-
* pubsub.detachSubscription('my-sub').then(data => {
* const apiResponse = data[0];
* });
*/
detachSubscription(name, optsOrCallback, callback) {
if (typeof name !== 'string') {
throw new Error('A subscription name is required.');
}
const sub = this.subscription(name);
const reqOpts = {
subscription: sub.name,
};
const gaxOpts = typeof optsOrCallback === 'object' ? optsOrCallback : {};
callback = typeof optsOrCallback === 'function' ? optsOrCallback : callback;
this.request({
client: 'PublisherClient',
method: 'detachSubscription',
reqOpts,
gaxOpts: gaxOpts,
}, callback);
}
/**
* Determine the appropriate endpoint to use for API requests, first trying

@@ -337,0 +382,0 @@ * the local `apiEndpoint` parameter. If the `apiEndpoint` parameter is null

@@ -130,2 +130,4 @@ /*!

ackDeadline: number;
maxMessages: number;
maxBytes: number;
isOpen: boolean;

@@ -132,0 +134,0 @@ private _acks;

19

build/src/subscriber.js

@@ -201,2 +201,4 @@ "use strict";

this.ackDeadline = 10;
this.maxMessages = default_options_1.defaultOptions.subscription.maxOutstandingMessages;
this.maxBytes = default_options_1.defaultOptions.subscription.maxOutstandingBytes;
this.isOpen = false;

@@ -341,8 +343,13 @@ this._isUserSetDeadline = false;

}
// In the event that the user has specified the maxMessages option, we want
// to make sure that the maxStreams option isn't higher.
// It doesn't really make sense to open 5 streams if the user only wants
// 1 message at a time.
if (options.flowControl) {
const { maxMessages = default_options_1.defaultOptions.subscription.maxOutstandingMessages, } = options.flowControl;
this.maxMessages =
options.flowControl.maxMessages ||
default_options_1.defaultOptions.subscription.maxOutstandingMessages;
this.maxBytes =
options.flowControl.maxBytes ||
default_options_1.defaultOptions.subscription.maxOutstandingBytes;
// In the event that the user has specified the maxMessages option, we
// want to make sure that the maxStreams option isn't higher.
// It doesn't really make sense to open 5 streams if the user only wants
// 1 message at a time.
if (!options.streamingOptions) {

@@ -352,3 +359,3 @@ options.streamingOptions = {};

const { maxStreams = default_options_1.defaultOptions.subscription.maxStreams, } = options.streamingOptions;
options.streamingOptions.maxStreams = Math.min(maxStreams, maxMessages);
options.streamingOptions.maxStreams = Math.min(maxStreams, this.maxMessages);
}

@@ -355,0 +362,0 @@ }

@@ -22,3 +22,3 @@ /*!

import { FlowControlOptions } from './lease-manager';
import { EmptyCallback, EmptyResponse, ExistsCallback, ExistsResponse, Omit, PubSub, RequestCallback, ResourceCallback } from './pubsub';
import { DetachedCallback, DetachedResponse, EmptyCallback, EmptyResponse, ExistsCallback, ExistsResponse, Omit, PubSub, RequestCallback, ResourceCallback } from './pubsub';
import { CreateSnapshotCallback, CreateSnapshotResponse, SeekCallback, SeekResponse, Snapshot } from './snapshot';

@@ -57,2 +57,4 @@ import { SubscriberOptions } from './subscriber';

export declare type SetSubscriptionMetadataResponse = MetadataResponse;
export declare type DetachSubscriptionCallback = EmptyCallback;
export declare type DetachSubscriptionResponse = EmptyResponse;
/**

@@ -213,2 +215,4 @@ * @typedef {object} ExpirationPolicy

delete(gaxOpts: CallOptions, callback: EmptyCallback): void;
detached(): Promise<DetachedResponse>;
detached(callback: DetachedCallback): void;
exists(): Promise<ExistsResponse>;

@@ -215,0 +219,0 @@ exists(callback: ExistsCallback): void;

@@ -400,2 +400,43 @@ "use strict";

/**
* @typedef {array} SubscriptionDetachedResponse
* @property {boolean} 0 Whether the subscription is detached.
*/
/**
* @callback SubscriptionDetachedCallback
* @param {?Error} err Request error, if any.
* @param {boolean} exists Whether the subscription is detached.
*/
/**
* Check if a subscription is detached.
*
* @param {SubscriptionDetachedCallback} [callback] Callback function.
* @returns {Promise<SubscriptionDetachedResponse>}
*
* @example
* const {PubSub} = require('@google-cloud/pubsub');
* const pubsub = new PubSub();
*
* const topic = pubsub.topic('my-topic');
* const subscription = topic.subscription('my-subscription');
*
* subscription.detached((err, exists) => {});
*
* //-
* // If the callback is omitted, we'll return a Promise.
* //-
* subscription.detached().then((data) => {
* const detached = data[0];
* });
*/
detached(callback) {
this.getMetadata((err, metadata) => {
if (err) {
callback(err);
}
else {
callback(null, metadata.detached);
}
});
}
/**
* @typedef {array} SubscriptionExistsResponse

@@ -402,0 +443,0 @@ * @property {boolean} 0 Whether the subscription exists

@@ -7,2 +7,15 @@ # Changelog

## [2.3.0](https://www.github.com/googleapis/nodejs-pubsub/compare/v2.2.0...v2.3.0) (2020-07-20)
### Features
* Add support for server-side flow control ([#1041](https://www.github.com/googleapis/nodejs-pubsub/issues/1041)) ([a53f6c7](https://www.github.com/googleapis/nodejs-pubsub/commit/a53f6c755317f2fdcb107989321a78fa05e0c455))
* support for detaching subscriptions ([#1032](https://www.github.com/googleapis/nodejs-pubsub/issues/1032)) ([c5af3a9](https://www.github.com/googleapis/nodejs-pubsub/commit/c5af3a9988e318c3d884aed1777010faa8545ab1))
### Bug Fixes
* typeo in nodejs .gitattribute ([#1049](https://www.github.com/googleapis/nodejs-pubsub/issues/1049)) ([b4c6dc0](https://www.github.com/googleapis/nodejs-pubsub/commit/b4c6dc0264a4f62283ceb3b5e1e2ae58e06c56c1))
## [2.2.0](https://www.github.com/googleapis/nodejs-pubsub/compare/v2.1.0...v2.2.0) (2020-07-09)

@@ -9,0 +22,0 @@

{
"name": "@google-cloud/pubsub",
"description": "Cloud Pub/Sub Client Library for Node.js",
"version": "2.2.0",
"version": "2.3.0",
"license": "Apache-2.0",

@@ -70,3 +70,3 @@ "author": "Google Inc.",

"@types/lodash.snakecase": "^4.1.6",
"@types/mocha": "^7.0.0",
"@types/mocha": "^8.0.0",
"@types/mv": "^2.1.0",

@@ -94,3 +94,3 @@ "@types/ncp": "^2.0.1",

"tmp": "^0.2.0",
"ts-loader": "^7.0.0",
"ts-loader": "^8.0.0",
"typescript": "3.6.4",

@@ -97,0 +97,0 @@ "uuid": "^8.0.0",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc