@google-cloud/pubsub 4.6.0 → 4.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/README.md +2 -1
- package/build/src/iam.d.ts +11 -2
- package/build/src/iam.js +12 -2
- package/build/src/iam.js.map +1 -1
- package/build/src/index.d.ts +2 -0
- package/build/src/index.js +5 -1
- package/build/src/index.js.map +1 -1
- package/build/src/lease-manager.d.ts +2 -2
- package/build/src/lease-manager.js +19 -3
- package/build/src/lease-manager.js.map +1 -1
- package/build/src/message-queues.d.ts +8 -3
- package/build/src/message-queues.js +17 -8
- package/build/src/message-queues.js.map +1 -1
- package/build/src/publisher/flow-publisher.js +5 -0
- package/build/src/publisher/flow-publisher.js.map +1 -1
- package/build/src/publisher/index.d.ts +3 -2
- package/build/src/publisher/index.js +24 -46
- package/build/src/publisher/index.js.map +1 -1
- package/build/src/publisher/message-batch.d.ts +13 -1
- package/build/src/publisher/message-batch.js +11 -1
- package/build/src/publisher/message-batch.js.map +1 -1
- package/build/src/publisher/message-queues.js +32 -6
- package/build/src/publisher/message-queues.js.map +1 -1
- package/build/src/publisher/pubsub-message.d.ts +43 -1
- package/build/src/publisher/pubsub-message.js +29 -0
- package/build/src/publisher/pubsub-message.js.map +1 -1
- package/build/src/pubsub.d.ts +5 -0
- package/build/src/pubsub.js +4 -14
- package/build/src/pubsub.js.map +1 -1
- package/build/src/subscriber.d.ts +72 -6
- package/build/src/subscriber.js +182 -51
- package/build/src/subscriber.js.map +1 -1
- package/build/src/subscription.d.ts +3 -2
- package/build/src/subscription.js +7 -4
- package/build/src/subscription.js.map +1 -1
- package/build/src/telemetry-tracing.d.ts +257 -0
- package/build/src/telemetry-tracing.js +648 -0
- package/build/src/telemetry-tracing.js.map +1 -0
- package/build/src/topic.d.ts +2 -1
- package/build/src/topic.js +8 -4
- package/build/src/topic.js.map +1 -1
- package/package.json +5 -4
- package/build/src/opentelemetry-tracing.d.ts +0 -23
- package/build/src/opentelemetry-tracing.js +0 -41
- package/build/src/opentelemetry-tracing.js.map +0 -1
|
@@ -13,7 +13,6 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { EventEmitter } from 'events';
|
|
17
16
|
import { CallOptions } from 'google-gax';
|
|
18
17
|
import { google } from '../protos/protos';
|
|
19
18
|
import { IAM } from './iam';
|
|
@@ -24,6 +23,7 @@ import { Message, SubscriberOptions } from './subscriber';
|
|
|
24
23
|
import { Topic } from './topic';
|
|
25
24
|
import { StatusError } from './message-stream';
|
|
26
25
|
import { DebugMessage } from './debug';
|
|
26
|
+
import { EventEmitter } from 'stream';
|
|
27
27
|
export { AckError, AckResponse, AckResponses } from './subscriber';
|
|
28
28
|
export type PushConfig = google.pubsub.v1.IPushConfig;
|
|
29
29
|
export type OidcToken = google.pubsub.v1.PushConfig.IOidcToken;
|
|
@@ -218,12 +218,13 @@ export declare interface Subscription {
|
|
|
218
218
|
export declare class Subscription extends EventEmitter {
|
|
219
219
|
pubsub: PubSub;
|
|
220
220
|
iam: IAM;
|
|
221
|
-
name: string;
|
|
222
221
|
topic?: Topic | string;
|
|
223
222
|
metadata?: google.pubsub.v1.ISubscription;
|
|
224
223
|
request: typeof PubSub.prototype.request;
|
|
225
224
|
private _subscriber;
|
|
226
225
|
constructor(pubsub: PubSub, name: string, options?: SubscriptionOptions);
|
|
226
|
+
private id_;
|
|
227
|
+
get name(): string;
|
|
227
228
|
/**
|
|
228
229
|
* Indicates if the Subscription is open and receiving messages.
|
|
229
230
|
*
|
|
@@ -16,13 +16,13 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.Subscription = exports.AckResponses = exports.AckError = void 0;
|
|
19
|
-
const events_1 = require("events");
|
|
20
19
|
const extend = require("extend");
|
|
21
20
|
const snakeCase = require("lodash.snakecase");
|
|
22
21
|
const iam_1 = require("./iam");
|
|
23
22
|
const snapshot_1 = require("./snapshot");
|
|
24
23
|
const subscriber_1 = require("./subscriber");
|
|
25
24
|
const util_1 = require("./util");
|
|
25
|
+
const stream_1 = require("stream");
|
|
26
26
|
var subscriber_2 = require("./subscriber");
|
|
27
27
|
Object.defineProperty(exports, "AckError", { enumerable: true, get: function () { return subscriber_2.AckError; } });
|
|
28
28
|
Object.defineProperty(exports, "AckResponses", { enumerable: true, get: function () { return subscriber_2.AckResponses; } });
|
|
@@ -175,13 +175,13 @@ Object.defineProperty(exports, "AckResponses", { enumerable: true, get: function
|
|
|
175
175
|
* });
|
|
176
176
|
* ```
|
|
177
177
|
*/
|
|
178
|
-
class Subscription extends
|
|
178
|
+
class Subscription extends stream_1.EventEmitter {
|
|
179
179
|
constructor(pubsub, name, options) {
|
|
180
180
|
super();
|
|
181
181
|
options = options || {};
|
|
182
182
|
this.pubsub = pubsub;
|
|
183
183
|
this.request = pubsub.request.bind(pubsub);
|
|
184
|
-
this.
|
|
184
|
+
this.id_ = name;
|
|
185
185
|
this.topic = options.topic;
|
|
186
186
|
/**
|
|
187
187
|
* [IAM (Identity and Access
|
|
@@ -221,7 +221,7 @@ class Subscription extends events_1.EventEmitter {
|
|
|
221
221
|
* });
|
|
222
222
|
* ```
|
|
223
223
|
*/
|
|
224
|
-
this.iam = new iam_1.IAM(pubsub, this
|
|
224
|
+
this.iam = new iam_1.IAM(pubsub, this);
|
|
225
225
|
this._subscriber = new subscriber_1.Subscriber(this, options);
|
|
226
226
|
this._subscriber
|
|
227
227
|
.on('error', err => this.emit('error', err))
|
|
@@ -230,6 +230,9 @@ class Subscription extends events_1.EventEmitter {
|
|
|
230
230
|
.on('close', () => this.emit('close'));
|
|
231
231
|
this._listen();
|
|
232
232
|
}
|
|
233
|
+
get name() {
|
|
234
|
+
return Subscription.formatName_(this.pubsub.projectId, this.id_);
|
|
235
|
+
}
|
|
233
236
|
/**
|
|
234
237
|
* Indicates if the Subscription is open and receiving messages.
|
|
235
238
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"subscription.js","sourceRoot":"","sources":["../../src/subscription.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,
|
|
1
|
+
{"version":3,"file":"subscription.js","sourceRoot":"","sources":["../../src/subscription.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,iCAAiC;AAEjC,8CAA+C;AAI/C,+BAA0B;AAc1B,yCAMoB;AACpB,6CAAoE;AAEpE,iCAAqC;AAGrC,mCAAoC;AAEpC,2CAAiE;AAAzD,sGAAA,QAAQ,OAAA;AAAe,0GAAA,YAAY,OAAA;AAmE3C;;;;;;;;;;;;;;GAcG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqIG;AACH,MAAa,YAAa,SAAQ,qBAAY;IAW5C,YAAY,MAAc,EAAE,IAAY,EAAE,OAA6B;QACrE,KAAK,EAAE,CAAC;QAER,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;QAExB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QAC3C,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC;QAChB,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAE3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;WAqCG;QACH,IAAI,CAAC,GAAG,GAAG,IAAI,SAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAEjC,IAAI,CAAC,WAAW,GAAG,IAAI,uBAAU,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACjD,IAAI,CAAC,WAA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SAAS,EAAE;IAClD,OAAO;IACP,QAAQ;IACR,gBAAgB;IAChB,QAAQ;IACR,UAAU;IACV,QAAQ;IACR,KAAK;IACL,aAAa;IACb,kBAAkB;IAClB,MAAM;IACN,aAAa;CACd,CAAC,CAAC"}
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright 2020-2024 Google LLC
|
|
3
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License.
|
|
5
|
+
* You may obtain a copy of the License at
|
|
6
|
+
*
|
|
7
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
*
|
|
9
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
* See the License for the specific language governing permissions and
|
|
13
|
+
* limitations under the License.
|
|
14
|
+
*/
|
|
15
|
+
import { SpanContext, Span, SpanKind, TextMapGetter, TextMapSetter, Context } from '@opentelemetry/api';
|
|
16
|
+
import { Attributes, PubsubMessage } from './publisher/pubsub-message';
|
|
17
|
+
import { PublishOptions } from './publisher/index';
|
|
18
|
+
import { Duration } from './temporal';
|
|
19
|
+
export { Span };
|
|
20
|
+
/**
|
|
21
|
+
* Determination of the level of OTel support we're providing.
|
|
22
|
+
*
|
|
23
|
+
* @private
|
|
24
|
+
* @internal
|
|
25
|
+
*/
|
|
26
|
+
export declare enum OpenTelemetryLevel {
|
|
27
|
+
/**
|
|
28
|
+
* None: OTel support is not enabled because we found no trace provider, or
|
|
29
|
+
* the user has not enabled it.
|
|
30
|
+
*/
|
|
31
|
+
None = 0,
|
|
32
|
+
/**
|
|
33
|
+
* Legacy: We found a trace provider, but the user also specified the old
|
|
34
|
+
* manual enable flag; this will trigger the legacy attribute being included.
|
|
35
|
+
* The modern propagation attribute will _also_ be included.
|
|
36
|
+
*/
|
|
37
|
+
Legacy = 1,
|
|
38
|
+
/**
|
|
39
|
+
* Modern: We will only inject/extract the modern propagation attribute.
|
|
40
|
+
*/
|
|
41
|
+
Modern = 2
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Manually set the OpenTelemetry enabledness.
|
|
45
|
+
*
|
|
46
|
+
* @param enabled The enabled flag to use, to override any automated methods.
|
|
47
|
+
* @private
|
|
48
|
+
* @internal
|
|
49
|
+
*/
|
|
50
|
+
export declare function setGloballyEnabled(enabled: boolean): void;
|
|
51
|
+
/**
|
|
52
|
+
* Tries to divine what sort of OpenTelemetry we're supporting. See the enum
|
|
53
|
+
* for the meaning of the values, and other notes.
|
|
54
|
+
*
|
|
55
|
+
* Legacy OTel is no longer officially supported, but we don't want to
|
|
56
|
+
* break anyone at a non-major.
|
|
57
|
+
*
|
|
58
|
+
* @private
|
|
59
|
+
* @internal
|
|
60
|
+
*/
|
|
61
|
+
export declare function isEnabled(publishSettings?: PublishOptions): OpenTelemetryLevel;
|
|
62
|
+
/**
|
|
63
|
+
* Our Carrier object for propagation is anything with an 'attributes'
|
|
64
|
+
* object, which is one of several possible Message classes. (They're
|
|
65
|
+
* different for publish and subscribe.)
|
|
66
|
+
*
|
|
67
|
+
* Also we add a parentSpan optional member for passing around the
|
|
68
|
+
* actual Span object within the client library. This can be a publish
|
|
69
|
+
* or subscriber span, depending on the context.
|
|
70
|
+
*
|
|
71
|
+
* @private
|
|
72
|
+
* @internal
|
|
73
|
+
*/
|
|
74
|
+
export interface MessageWithAttributes {
|
|
75
|
+
attributes?: Attributes | null | undefined;
|
|
76
|
+
parentSpan?: Span;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Implements common members for the TextMap getter and setter interfaces for Pub/Sub messages.
|
|
80
|
+
*
|
|
81
|
+
* @private
|
|
82
|
+
* @internal
|
|
83
|
+
*/
|
|
84
|
+
export declare class PubsubMessageGetSet {
|
|
85
|
+
static keyPrefix: string;
|
|
86
|
+
keys(carrier: MessageWithAttributes): string[];
|
|
87
|
+
protected attributeName(key: string): string;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Implements the TextMap getter interface for Pub/Sub messages.
|
|
91
|
+
*
|
|
92
|
+
* @private
|
|
93
|
+
* @internal
|
|
94
|
+
*/
|
|
95
|
+
export declare class PubsubMessageGet extends PubsubMessageGetSet implements TextMapGetter<MessageWithAttributes> {
|
|
96
|
+
get(carrier: MessageWithAttributes, key: string): string | string[] | undefined;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Implements the TextMap setter interface for Pub/Sub messages.
|
|
100
|
+
*
|
|
101
|
+
* @private
|
|
102
|
+
* @internal
|
|
103
|
+
*/
|
|
104
|
+
export declare class PubsubMessageSet extends PubsubMessageGetSet implements TextMapSetter<MessageWithAttributes> {
|
|
105
|
+
set(carrier: MessageWithAttributes, key: string, value: string): void;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* The getter to use when calling extract() on a Pub/Sub message.
|
|
109
|
+
*
|
|
110
|
+
* @private
|
|
111
|
+
* @internal
|
|
112
|
+
*/
|
|
113
|
+
export declare const pubsubGetter: PubsubMessageGet;
|
|
114
|
+
/**
|
|
115
|
+
* The setter to use when calling inject() on a Pub/Sub message.
|
|
116
|
+
*
|
|
117
|
+
* @private
|
|
118
|
+
* @internal
|
|
119
|
+
*/
|
|
120
|
+
export declare const pubsubSetter: PubsubMessageSet;
|
|
121
|
+
/**
|
|
122
|
+
* Description of the data structure passed for span attributes.
|
|
123
|
+
*
|
|
124
|
+
* @private
|
|
125
|
+
* @internal
|
|
126
|
+
*/
|
|
127
|
+
export interface SpanAttributes {
|
|
128
|
+
[x: string]: string | number | boolean;
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Converts a SpanContext to a full Context, as needed.
|
|
132
|
+
*
|
|
133
|
+
* @private
|
|
134
|
+
* @internal
|
|
135
|
+
*/
|
|
136
|
+
export declare function spanContextToContext(parent?: SpanContext): Context | undefined;
|
|
137
|
+
/**
|
|
138
|
+
* The modern propagation attribute name.
|
|
139
|
+
*
|
|
140
|
+
* Technically this is determined by the OpenTelemetry library, but
|
|
141
|
+
* in practice, it follows the W3C spec, so this should be the right
|
|
142
|
+
* one. The only thing we're using it for, anyway, is emptying user
|
|
143
|
+
* supplied attributes.
|
|
144
|
+
*
|
|
145
|
+
* @private
|
|
146
|
+
* @internal
|
|
147
|
+
*/
|
|
148
|
+
export declare const modernAttributeName = "googclient_traceparent";
|
|
149
|
+
/**
|
|
150
|
+
* The old legacy attribute name.
|
|
151
|
+
*
|
|
152
|
+
* @private
|
|
153
|
+
* @internal
|
|
154
|
+
*/
|
|
155
|
+
export declare const legacyAttributeName = "googclient_OpenTelemetrySpanContext";
|
|
156
|
+
export interface AttributeParams {
|
|
157
|
+
topicName?: string;
|
|
158
|
+
subName?: string;
|
|
159
|
+
projectId?: string;
|
|
160
|
+
topicId?: string;
|
|
161
|
+
subId?: string;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Break down the subscription's full name into its project and ID.
|
|
165
|
+
*
|
|
166
|
+
* @private
|
|
167
|
+
* @internal
|
|
168
|
+
*/
|
|
169
|
+
export declare function getSubscriptionInfo(fullName: string): AttributeParams;
|
|
170
|
+
/**
|
|
171
|
+
* Break down the subscription's full name into its project and ID.
|
|
172
|
+
*
|
|
173
|
+
* @private
|
|
174
|
+
* @internal
|
|
175
|
+
*/
|
|
176
|
+
export declare function getTopicInfo(fullName: string): AttributeParams;
|
|
177
|
+
/**
|
|
178
|
+
* Contains utility methods for creating spans.
|
|
179
|
+
*
|
|
180
|
+
* @private
|
|
181
|
+
* @internal
|
|
182
|
+
*/
|
|
183
|
+
export declare class PubsubSpans {
|
|
184
|
+
static createAttributes(params: AttributeParams, message?: PubsubMessage, caller?: string): SpanAttributes;
|
|
185
|
+
static createPublisherSpan(message: PubsubMessage, topicName: string, caller: string): Span | undefined;
|
|
186
|
+
static updatePublisherTopicName(span: Span, topicName: string): void;
|
|
187
|
+
static createReceiveSpan(message: PubsubMessage, subName: string, parent: Context | undefined, caller: string): Span | undefined;
|
|
188
|
+
static createChildSpan(name: string, message?: PubsubMessage, parentSpan?: Span, attributes?: SpanAttributes): Span | undefined;
|
|
189
|
+
static createPublishFlowSpan(message: PubsubMessage): Span | undefined;
|
|
190
|
+
static createPublishSchedulerSpan(message: PubsubMessage): Span | undefined;
|
|
191
|
+
static createPublishRpcSpan(messages: MessageWithAttributes[], topicName: string, caller: string): Span | undefined;
|
|
192
|
+
static createAckRpcSpan(messageSpans: (Span | undefined)[], subName: string, caller: string): Span | undefined;
|
|
193
|
+
static createModackRpcSpan(messageSpans: (Span | undefined)[], subName: string, type: 'modack' | 'nack', caller: string, deadline?: Duration, isInitial?: boolean): Span | undefined;
|
|
194
|
+
static createReceiveFlowSpan(message: MessageWithAttributes): Span | undefined;
|
|
195
|
+
static createReceiveSchedulerSpan(message: MessageWithAttributes): Span | undefined;
|
|
196
|
+
static createReceiveProcessSpan(message: MessageWithAttributes, subName: string): Span | undefined;
|
|
197
|
+
static setReceiveProcessResult(span: Span, isAck: boolean): void;
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Creates and manipulates Pub/Sub-related events on spans.
|
|
201
|
+
*
|
|
202
|
+
* @private
|
|
203
|
+
* @internal
|
|
204
|
+
*/
|
|
205
|
+
export declare class PubsubEvents {
|
|
206
|
+
static addEvent(text: string, message: MessageWithAttributes, attributes?: Attributes): void;
|
|
207
|
+
static publishStart(message: MessageWithAttributes): void;
|
|
208
|
+
static publishEnd(message: MessageWithAttributes): void;
|
|
209
|
+
static ackStart(message: MessageWithAttributes): void;
|
|
210
|
+
static ackEnd(message: MessageWithAttributes): void;
|
|
211
|
+
static modackStart(message: MessageWithAttributes): void;
|
|
212
|
+
static modackEnd(message: MessageWithAttributes): void;
|
|
213
|
+
static nackStart(message: MessageWithAttributes): void;
|
|
214
|
+
static nackEnd(message: MessageWithAttributes): void;
|
|
215
|
+
static ackCalled(span: Span): void;
|
|
216
|
+
static nackCalled(span: Span): void;
|
|
217
|
+
static modAckCalled(span: Span, deadline: Duration): void;
|
|
218
|
+
static modAckStart(message: MessageWithAttributes, deadline: Duration, isInitial: boolean): void;
|
|
219
|
+
static modAckEnd(message: MessageWithAttributes): void;
|
|
220
|
+
static shutdown(message: MessageWithAttributes): void;
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Injects the trace context into a Pub/Sub message (or other object with
|
|
224
|
+
* an 'attributes' object) for propagation.
|
|
225
|
+
*
|
|
226
|
+
* This is for the publish side.
|
|
227
|
+
*
|
|
228
|
+
* @private
|
|
229
|
+
* @internal
|
|
230
|
+
*/
|
|
231
|
+
export declare function injectSpan(span: Span, message: MessageWithAttributes, enabled: OpenTelemetryLevel): void;
|
|
232
|
+
/**
|
|
233
|
+
* Returns true if this message potentially contains a span context.
|
|
234
|
+
*
|
|
235
|
+
* @private
|
|
236
|
+
* @internal
|
|
237
|
+
*/
|
|
238
|
+
export declare function containsSpanContext(message: MessageWithAttributes): boolean;
|
|
239
|
+
/**
|
|
240
|
+
* Extracts the trace context from a Pub/Sub message (or other object with
|
|
241
|
+
* an 'attributes' object) from a propagation, for receive processing. If no
|
|
242
|
+
* context was present, create a new parent span.
|
|
243
|
+
*
|
|
244
|
+
* This is for the receive side.
|
|
245
|
+
*
|
|
246
|
+
* @private
|
|
247
|
+
* @internal
|
|
248
|
+
*/
|
|
249
|
+
export declare function extractSpan(message: MessageWithAttributes, subName: string, enabled: OpenTelemetryLevel): Span | undefined;
|
|
250
|
+
export declare const legacyExports: {
|
|
251
|
+
/**
|
|
252
|
+
* @deprecated
|
|
253
|
+
* Use the new telemetry functionality instead; see the updated OpenTelemetry
|
|
254
|
+
* sample for an example.
|
|
255
|
+
*/
|
|
256
|
+
createSpan: (spanName: string, kind: SpanKind, attributes?: SpanAttributes, parent?: SpanContext) => Span;
|
|
257
|
+
};
|