|
1 | 1 | import Debug from 'debug';
|
2 |
| -import assert from 'assert'; |
3 |
| -import { Client, claimedCredentials } from 'taskcluster-lib-pulse'; |
4 | 2 | import { slugid } from 'taskcluster-client';
|
5 | 3 | import { serialize } from 'async-decorators';
|
6 | 4 | import PulseIterator from './PulseIterator';
|
@@ -106,51 +104,18 @@ export default class PulseEngine {
|
106 | 104 | * connection recycles, and rely on the caller to re-subscribe on service
|
107 | 105 | * restart. */
|
108 | 106 |
|
109 |
| - constructor({ |
110 |
| - monitor, |
111 |
| - rootUrl, |
112 |
| - credentials, |
113 |
| - namespace, |
114 |
| - contact, |
115 |
| - expiresAfter, |
116 |
| - }) { |
| 107 | + constructor({ monitor, pulseClient }) { |
117 | 108 | this.monitor = monitor;
|
118 | 109 | this.subscriptions = new Map();
|
119 | 110 |
|
120 |
| - if (process.env.NODE_ENV === 'production') { |
121 |
| - assert(namespace, 'namespace is required'); |
122 |
| - assert( |
123 |
| - credentials && credentials.clientId && credentials.accessToken, |
124 |
| - 'credentials are required' |
125 |
| - ); |
126 |
| - } else if ( |
127 |
| - !namespace || |
128 |
| - !credentials || |
129 |
| - !credentials.clientId || |
130 |
| - !credentials.accessToken |
131 |
| - ) { |
132 |
| - debug( |
133 |
| - 'NOTE: pulse.namespace or taskcluster.credentials not set; no subscription messages will be recieved' |
134 |
| - ); |
| 111 | + this.client = pulseClient; |
135 | 112 |
|
136 |
| - // bail out of setup; this.connected will never be called, so no |
137 |
| - // subscriptions will ever return messages, but subscription requests |
138 |
| - // will succeed. |
| 113 | + if (this.client.isFakeClient) { |
| 114 | + // we are now set up to accept subscription requests, but won't do |
| 115 | + // anything with them. |
139 | 116 | return;
|
140 | 117 | }
|
141 | 118 |
|
142 |
| - this.client = new Client({ |
143 |
| - monitor, |
144 |
| - namespace, |
145 |
| - credentials: claimedCredentials({ |
146 |
| - rootUrl, |
147 |
| - credentials, |
148 |
| - namespace, |
149 |
| - contact, |
150 |
| - expiresAfter, |
151 |
| - }), |
152 |
| - }); |
153 |
| - |
154 | 119 | this.reset();
|
155 | 120 | this.client.onConnected(conn => this.connected(conn));
|
156 | 121 | }
|
|
0 commit comments