Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion handwritten/pubsub/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,14 @@
"clean": "gts clean",
"compile": "tsc -p . && cp -r protos build/",
"compile-protos": "compileProtos src",
"prepare": "npm run compile-protos && npm run compile",
"prepare": "npm run compile",
"pretest": "npm run compile",
"benchwrapper": "node bin/benchwrapper.js",
"prelint": "cd samples; npm link ../; npm install",
"precompile": "gts clean"
},
"dependencies": {
"@google-cloud/pubsub-api": "./tmp/google-cloud-pubsub-api-0.1.0.tgz",
"@google-cloud/paginator": "^6.0.0",
"@google-cloud/precise-date": "^5.0.0",
"@google-cloud/projectify": "^5.0.0",
Expand Down
5,842 changes: 3,647 additions & 2,195 deletions handwritten/pubsub/protos/protos.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion handwritten/pubsub/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
* @property {constructor} SubscriberClient
* Reference to {@link v1.SubscriberClient}.
*/
import * as v1 from './v1';
import * as v1 from '@google-cloud/pubsub-api';
export {v1};
export {ServiceError, CallOptions} from 'google-gax';
export {
Expand Down
5 changes: 3 additions & 2 deletions handwritten/pubsub/src/message-stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@ export const logs = {
const KEEP_ALIVE_INTERVAL = 30000;

/*!
* Deadline for the stream.
* Deadline for the stream. This will need to go away and be replaced with something
* more graceful for pulling the config out of the pubsub-api package.
*/
const PULL_TIMEOUT = require('./v1/subscriber_client_config.json').interfaces[
const PULL_TIMEOUT = require('./v1-old/subscriber_client_config.json').interfaces[
'google.pubsub.v1.Subscriber'
].methods.StreamingPull.timeout_millis;

Expand Down
12 changes: 6 additions & 6 deletions handwritten/pubsub/src/pubsub.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ import {replaceProjectIdToken} from '@google-cloud/projectify';
import * as extend from 'extend';
import {AuthClient, GoogleAuth, GoogleAuthOptions} from 'google-auth-library';
import * as gax from 'google-gax';
import {v1} from './';

// eslint-disable-next-line @typescript-eslint/no-var-requires
const PKG = require('../../package.json');
// eslint-disable-next-line @typescript-eslint/no-var-requires
const v1 = require('./v1');

import {promisifySome} from './util';
import {
Expand Down Expand Up @@ -57,9 +56,10 @@ import {PublishOptions} from './publisher';
import {CallOptions} from 'google-gax';
import {Transform} from 'stream';
import {google} from '../protos/protos';
import {SchemaServiceClient} from './v1';
import * as tracing from './telemetry-tracing';

type SchemaServiceClient = v1.SchemaServiceClient;

/**
* Project ID placeholder.
* @type {string}
Expand Down Expand Up @@ -1262,7 +1262,7 @@ export class PubSub {
*/
async getSchemaClient(): Promise<SchemaServiceClient> {
if (!this.schemaClient) {
const options = await this.getClientConfig();
const options = await this.getClientConfig() as gax.ClientOptions;
this.schemaClient = new v1.SchemaServiceClient(options);
}

Expand Down Expand Up @@ -1307,13 +1307,13 @@ export class PubSub {
*/
async getClientAsync_(config: GetClientConfig): Promise<gax.ClientStub> {
// Make sure we've got a fully created config with projectId and such.
const options = await this.getClientConfig();
const options = await this.getClientConfig() as gax.ClientOptions;

let gaxClient = this.api[config.client];

if (!gaxClient) {
// Lazily instantiate client.
gaxClient = new v1[config.client](options) as gax.ClientStub;
gaxClient = new v1[config.client](options) as unknown as gax.ClientStub;
this.api[config.client] = gaxClient;
}

Expand Down
6 changes: 4 additions & 2 deletions handwritten/pubsub/src/subscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import {DateStruct, PreciseDate} from '@google-cloud/precise-date';
import {replaceProjectIdToken} from '@google-cloud/projectify';
import {promisify} from '@google-cloud/promisify';
import defer = require('p-defer');
import * as defer from 'p-defer';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

p-defer exports its main functionality as a default export. Importing it using import * as defer binds defer to a namespace object (e.g., { default: [Function] }), which will cause a runtime TypeError: defer is not a function when called as defer(). Use a default import instead.

Suggested change
import * as defer from 'p-defer';
import defer from 'p-defer';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The default import version causes other issues. It might be simplest to just revert this to a require if we don't like the new * version.


import {google} from '../protos/protos';
import {Histogram} from './histogram';
Expand All @@ -26,7 +26,6 @@ import {AckQueue, BatchOptions, ModAckQueue} from './message-queues';
import {MessageStream, MessageStreamOptions} from './message-stream';
import {Subscription} from './subscription';
import {defaultOptions} from './default-options';
import {SubscriberClient} from './v1';
import * as tracing from './telemetry-tracing';
import {Duration, atMost as durationAtMost} from './temporal';
import {EventEmitter} from 'events';
Expand All @@ -36,6 +35,9 @@ import {logs as baseLogs, LoggingFunction} from './logs';

export {StatusError} from './message-stream';

import {v1} from '.';
type SubscriberClient = v1.SubscriberClient;

/**
* Loggers. Exported for unit tests.
*
Expand Down
21 changes: 0 additions & 21 deletions handwritten/pubsub/src/v1/index.ts

This file was deleted.

Loading
Loading