@jayesol/jayeson.lib.sports 2.2.6-beta2 → 2.2.7-beta

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/lib/receive.d.ts DELETED
@@ -1,88 +0,0 @@
1
- import * as D from '@jayesol/jayeson.lib.delivery';
2
- import { RuleCombination } from "@jayesol/jayeson.model";
3
- import { FSRepo, Mergeable, RecycleBin } from "./core";
4
- import { SportsFeedMessageGroup, StartSubscribeFeed } from "./message_class";
5
- import { Incoming, IndexedSnapshot, Outgoing, MergeableWrapper } from "./data_structure";
6
- import 'reflect-metadata';
7
- import { FilterRequest } from './codec';
8
- export declare class InEndPointEventHandler {
9
- private _streamSources;
10
- private _exclude;
11
- private _wireFormat;
12
- private _filterData;
13
- private _startMessage;
14
- private _sportsMsgGrp;
15
- private _streamNameCode;
16
- constructor(startMessage: StartSubscribeFeed, sportsMsgGrp: SportsFeedMessageGroup, streamNameCode: D.StreamNameCode);
17
- setfilterData(rule: RuleCombination): void;
18
- streamSources(): any;
19
- exclude(): string[];
20
- wireFormat(): string;
21
- startMessage(): StartSubscribeFeed;
22
- sportsMsgGrp(): SportsFeedMessageGroup;
23
- streamNameCode(): any;
24
- filterData(): RuleCombination;
25
- onEvent(event: D.EPEvent): void;
26
- sendMessage(streamId: string, mw: D.MessageWrapper): void;
27
- updateFilter(filterRequest: FilterRequest): void;
28
- /**
29
- * Sends filter to server
30
- * @param streamId - sends filter for a particular streamId
31
- * if null, sends filter for all stream ids
32
- */
33
- private sendFilter;
34
- private _sendFilter;
35
- }
36
- export declare class StreamCommandProcessor {
37
- private _fsRepo;
38
- private _sportsGrp;
39
- constructor(_fsRepo: FSRepo, _sportsGrp: SportsFeedMessageGroup);
40
- process(stream: string, input: Mergeable, overwrite?: Outgoing): void;
41
- fsRepo(): FSRepo;
42
- sportsGrp(): SportsFeedMessageGroup;
43
- messageClassName: {
44
- 0: string;
45
- 1: string;
46
- 2: string;
47
- 3: string;
48
- 4: string;
49
- 5: string;
50
- 6: string;
51
- 7: string;
52
- 8: string;
53
- 9: string;
54
- 10: string;
55
- 11: string;
56
- 13: string;
57
- 14: string;
58
- 16: string;
59
- 17: string;
60
- };
61
- private printMessage;
62
- private getClassName;
63
- private printMatch;
64
- private printRecord;
65
- private printPartitionKeys;
66
- }
67
- export declare class SportsFeedInProcessor extends D.IMessageGroupProcessor {
68
- private scp;
69
- private sportsFeedMsgGroup;
70
- private snCode;
71
- private recycleBin;
72
- constructor(scp: StreamCommandProcessor, sportsFeedMsgGroup: SportsFeedMessageGroup, snCode: D.StreamNameCode, recycleBin: RecycleBin);
73
- process(mw: D.MessageWrapper): void;
74
- private processIndicatorMessage;
75
- private triggerTtlRestoreIfApplicable;
76
- triggerTtlRemove(): void;
77
- startTtlVerification(): void;
78
- isFeedMessage(mw: D.MessageWrapper): boolean;
79
- getScp(): StreamCommandProcessor;
80
- getRecycleBin(): RecycleBin;
81
- }
82
- export declare class MergeableIncoming extends Incoming implements Mergeable {
83
- private sportsGrp;
84
- private beforeSnap;
85
- private bin;
86
- constructor(sportsGrp: SportsFeedMessageGroup, snapshotType: D.IMessageClass, streamName: string, data: IndexedSnapshot, bin: RecycleBin);
87
- apply(before: IndexedSnapshot): MergeableWrapper;
88
- }
package/lib/receive.js DELETED
@@ -1,484 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
19
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
20
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
22
- return c > 3 && r && Object.defineProperty(target, key, r), r;
23
- };
24
- var __importStar = (this && this.__importStar) || function (mod) {
25
- if (mod && mod.__esModule) return mod;
26
- var result = {};
27
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
28
- __setModuleDefault(result, mod);
29
- return result;
30
- };
31
- var __metadata = (this && this.__metadata) || function (k, v) {
32
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
33
- };
34
- var __param = (this && this.__param) || function (paramIndex, decorator) {
35
- return function (target, key) { decorator(target, key, paramIndex); }
36
- };
37
- Object.defineProperty(exports, "__esModule", { value: true });
38
- exports.MergeableIncoming = exports.SportsFeedInProcessor = exports.StreamCommandProcessor = exports.InEndPointEventHandler = void 0;
39
- const D = __importStar(require("@jayesol/jayeson.lib.delivery"));
40
- const Collections = __importStar(require("typescript-collections"));
41
- const core_1 = require("./core");
42
- const message_class_1 = require("./message_class");
43
- const merge_1 = require("./merge");
44
- const data_structure_1 = require("./data_structure");
45
- let circular = require("circular-json");
46
- //imports required for dependency injection
47
- require("reflect-metadata");
48
- const injection_js_1 = require("injection-js");
49
- const codec_1 = require("./codec");
50
- let InEndPointEventHandler = class InEndPointEventHandler {
51
- constructor(startMessage, sportsMsgGrp, streamNameCode) {
52
- this._streamSources = {};
53
- this._filterData = null;
54
- //to be injected
55
- this._startMessage = startMessage;
56
- this._sportsMsgGrp = sportsMsgGrp;
57
- this._streamNameCode = streamNameCode;
58
- this._exclude = startMessage.exclude;
59
- this._wireFormat = startMessage.wireFormat;
60
- }
61
- setfilterData(rule) {
62
- this._filterData = rule;
63
- }
64
- streamSources() {
65
- return this._streamSources;
66
- }
67
- exclude() {
68
- return this._exclude;
69
- }
70
- wireFormat() {
71
- return this._wireFormat;
72
- }
73
- startMessage() {
74
- return this._startMessage;
75
- }
76
- sportsMsgGrp() {
77
- return this._sportsMsgGrp;
78
- }
79
- streamNameCode() {
80
- return this._streamNameCode;
81
- }
82
- filterData() {
83
- return this._filterData;
84
- }
85
- onEvent(event) {
86
- if (event instanceof D.Subscriber.Event.ConsumptionStart) {
87
- for (let property in event.streams) {
88
- if (event.streams.hasOwnProperty(property)) {
89
- for (let i = 0; i < event.streams[property].length; i++) {
90
- let grpId = parseInt(property);
91
- //only connect to sports streams
92
- if (grpId == this.sportsMsgGrp().id()) {
93
- //set end point mapping.
94
- let streamId = event.streams[property][i];
95
- this._streamSources[streamId] = event.endPoint;
96
- //send filter
97
- let filterRequest = new codec_1.FilterRequest(codec_1.FilterRequest.IGNORED_REQUEST_ID, this.filterData());
98
- this.sendFilter(filterRequest, streamId);
99
- //send start message
100
- console.log("Sending Start Message to stream : '" + streamId + "'");
101
- let mw = new D.MessageWrapper(this._startMessage, this._sportsMsgGrp.ADMIN_START_SUBSCRIBE_FEED());
102
- this.sendMessage(streamId, mw);
103
- }
104
- }
105
- }
106
- }
107
- }
108
- else if (event instanceof D.Subscriber.Event.ConsumptionError) {
109
- let logMessage = event.client.config.url + " has errors on consumption: ";
110
- for (let property in event.streams) {
111
- if (event.streams.hasOwnProperty(property)) {
112
- logMessage += "\n" + property + ":[";
113
- for (let i = 0; i < event.streams[property].length; i++) {
114
- logMessage += event.streams[property][i] + ",";
115
- }
116
- logMessage = logMessage.substring(1, logMessage.length - 1);
117
- logMessage += "]";
118
- }
119
- }
120
- console.log(logMessage);
121
- }
122
- else {
123
- console.log("Unidentified event received by onEvent: " + circular.stringify(event));
124
- }
125
- }
126
- sendMessage(streamId, mw) {
127
- //Append Stream name as meta info
128
- mw.addMetaInfo(this._streamNameCode.code(), streamId);
129
- //Get EndPoint to corresponding to this stream
130
- let ep = this._streamSources[streamId];
131
- //If EndPoint is not present, no action
132
- if (ep == null) {
133
- console.log("No Endpoint present corresponding to stream '" + streamId + "'. Unable to send message");
134
- }
135
- else {
136
- ep.send(mw);
137
- }
138
- }
139
- updateFilter(filterRequest) {
140
- this._filterData = filterRequest.getFilterData();
141
- this.sendFilter(filterRequest);
142
- }
143
- /**
144
- * Sends filter to server
145
- * @param streamId - sends filter for a particular streamId
146
- * if null, sends filter for all stream ids
147
- */
148
- sendFilter(filterRequest, streamId = null) {
149
- if (streamId !== null) {
150
- this._sendFilter(filterRequest, streamId);
151
- }
152
- else {
153
- for (let streamId in this._streamSources) {
154
- if (this._streamSources.hasOwnProperty(streamId)) {
155
- this._sendFilter(filterRequest, streamId);
156
- }
157
- }
158
- }
159
- }
160
- _sendFilter(filterRequest, streamId) {
161
- let filterData = filterRequest.getFilterData();
162
- let mw = null;
163
- if (filterData != null) {
164
- mw = new D.MessageWrapper(filterRequest, this._sportsMsgGrp.FILTER_SET());
165
- console.log("Sending FILTER_SET to stream: '" + streamId + "' with filter data: " + JSON.stringify(filterData));
166
- }
167
- else {
168
- mw = new D.MessageWrapper(filterRequest.getRequestId().toString(), this._sportsMsgGrp.FILTER_REMOVE());
169
- console.log("Sending FILTER_REMOVE to stream: '" + streamId + "'");
170
- }
171
- this.sendMessage(streamId, mw);
172
- }
173
- };
174
- InEndPointEventHandler = __decorate([
175
- (0, injection_js_1.Injectable)(),
176
- __metadata("design:paramtypes", [message_class_1.StartSubscribeFeed, message_class_1.SportsFeedMessageGroup, D.StreamNameCode])
177
- ], InEndPointEventHandler);
178
- exports.InEndPointEventHandler = InEndPointEventHandler;
179
- let StreamCommandProcessor = class StreamCommandProcessor {
180
- constructor(_fsRepo, _sportsGrp) {
181
- this._fsRepo = _fsRepo;
182
- this._sportsGrp = _sportsGrp;
183
- this.messageClassName = {
184
- 0: 'DATA_RESET',
185
- 1: 'DATA_INSERT_ODD',
186
- 2: 'DATA_UPDATE_ODD',
187
- 3: 'DATA_DELETE_ODD',
188
- 4: 'DATA_INSERT_EVENT',
189
- 5: 'DATA_UPDATE_EVENT',
190
- 6: 'DATA_DELETE_EVENT',
191
- 7: 'DATA_INSERT_MATCH',
192
- 8: 'DATA_UPDATE_MATCH',
193
- 9: 'DATA_DELETE_MATCH',
194
- 10: 'TTL_REMOVE',
195
- 11: 'TTL_RESTORE',
196
- 13: 'FILTER_REMOVE',
197
- 14: 'FILTER_SET',
198
- 16: 'ADMIN_START_SUBSCRIBE_FEED',
199
- 17: 'ADMIN_REFRESH'
200
- };
201
- }
202
- //bypass the append snapshot call if overwrite is provided
203
- process(stream, input, overwrite = null) {
204
- //see what message
205
- if (input != null && input instanceof data_structure_1.Incoming) {
206
- let ss = input;
207
- let className = this.messageClassName[ss.msgType().id()];
208
- console.debug("SCP processing: " + className);
209
- }
210
- if (overwrite == null) {
211
- let outgoing = this._fsRepo.appendSnapshot(stream, input);
212
- for (let o of outgoing) {
213
- //this.printMessage(o);
214
- this._fsRepo.push(o);
215
- }
216
- }
217
- else {
218
- //bypass appending to snapshot
219
- this._fsRepo.push(overwrite);
220
- }
221
- }
222
- fsRepo() {
223
- return this._fsRepo;
224
- }
225
- sportsGrp() {
226
- return this._sportsGrp;
227
- }
228
- printMessage(outgoing) {
229
- //print partition keys
230
- let className = this.getClassName(outgoing);
231
- let snapshot = outgoing.delta();
232
- this.printPartitionKeys(className, snapshot);
233
- //print contents
234
- let id = outgoing.msgType().id();
235
- switch (id) {
236
- case this._sportsGrp.DATA_INSERT_MATCH().id():
237
- case this._sportsGrp.DATA_UPDATE_MATCH().id():
238
- case this._sportsGrp.DATA_DELETE_MATCH().id():
239
- this.printMatch(className, snapshot);
240
- break;
241
- case this._sportsGrp.DATA_INSERT_ODD().id():
242
- case this._sportsGrp.DATA_UPDATE_ODD().id():
243
- case this._sportsGrp.DATA_DELETE_ODD().id():
244
- this.printRecord(className, snapshot);
245
- break;
246
- }
247
- }
248
- getClassName(outgoing) {
249
- if (!(outgoing instanceof core_1.TTLOutgoing)) {
250
- return this.messageClassName[outgoing.msgType().id()];
251
- }
252
- else {
253
- let TTLOutgoing = outgoing;
254
- if (TTLOutgoing.getTtlType() == core_1.TTLType.REMOVE) {
255
- return "TTL_REM";
256
- }
257
- else {
258
- return "TTL_RES";
259
- }
260
- }
261
- }
262
- printMatch(identifier, snapshot) {
263
- let matches = snapshot.matches();
264
- for (let i = 0; i < matches.length; i++) {
265
- console.log(`[${identifier}] ${matches[i].id()}`);
266
- }
267
- }
268
- printRecord(identifier, snapshot) {
269
- let matches = snapshot.matches();
270
- for (let i = 0; i < matches.length; i++) {
271
- let events = matches[i].events();
272
- for (let j = 0; j < events.length; j++) {
273
- let records = events[j].records();
274
- for (let k = 0; k < records.length; k++) {
275
- let rec = records[k];
276
- console.log(`[${identifier}] ${rec.matchId()}_${rec.eventId()}_${rec.id()}_${rec.source()}_${rec.oddType()}_${rec.oddFormat()}`);
277
- }
278
- }
279
- }
280
- }
281
- printPartitionKeys(identifier, snapshot) {
282
- let partitionsString = snapshot.getPartitions().toString();
283
- console.log(`[${identifier}][PK]${partitionsString}`);
284
- }
285
- };
286
- StreamCommandProcessor = __decorate([
287
- (0, injection_js_1.Injectable)(),
288
- __param(0, (0, injection_js_1.Inject)(core_1.FSREPO_IMPL)),
289
- __metadata("design:paramtypes", [Object, message_class_1.SportsFeedMessageGroup])
290
- ], StreamCommandProcessor);
291
- exports.StreamCommandProcessor = StreamCommandProcessor;
292
- let SportsFeedInProcessor = class SportsFeedInProcessor extends D.IMessageGroupProcessor {
293
- constructor(scp, sportsFeedMsgGroup, snCode, recycleBin) {
294
- super(sportsFeedMsgGroup);
295
- this.scp = scp;
296
- this.sportsFeedMsgGroup = sportsFeedMsgGroup;
297
- this.snCode = snCode;
298
- this.recycleBin = recycleBin;
299
- }
300
- process(mw) {
301
- //validate stream name
302
- let streamName = mw.getMetaInfo(this.snCode.code());
303
- if (streamName == null || streamName === "") {
304
- console.log("SportsFeedInProcessor received messagewrapper with no StreamName. Ignoring.");
305
- return;
306
- }
307
- if (!this.isFeedMessage(mw)) {
308
- console.log("SportsFeedInProcessor received unknown messageclass: " + circular.stringify(mw.messageClass) + ". Ignoring");
309
- return;
310
- }
311
- if (this.sportsFeedMsgGroup.isIndicatorMessage(mw.messageClass)) {
312
- let outgoing = this.processIndicatorMessage(mw);
313
- this.scp.process(streamName, null, outgoing);
314
- }
315
- else {
316
- let incoming = new MergeableIncoming(this.sportsFeedMsgGroup, mw.messageClass, streamName, mw.message, this.recycleBin);
317
- this.triggerTtlRestoreIfApplicable(incoming);
318
- this.scp.process(incoming.stream(), incoming);
319
- }
320
- }
321
- processIndicatorMessage(mw) {
322
- //clear RecycleBin for TTL_RESTORE_START
323
- if (mw.messageClass == this.sportsFeedMsgGroup.TTL_RESTORE_START()) {
324
- mw.message.getPartitions().forEach(partitionKey => {
325
- this.recycleBin.clearBin(partitionKey);
326
- });
327
- }
328
- //generate outgoing message
329
- let outgoing = new data_structure_1.OutgoingImpl(mw.messageClass, mw.message);
330
- return outgoing;
331
- }
332
- triggerTtlRestoreIfApplicable(incomingMsg) {
333
- if (this.getRecycleBin() != null) {
334
- if (this.getRecycleBin().getTtlConfig() != null && this.getRecycleBin().getTtlConfig().isEnableTtl()) {
335
- //check if TTLRestore is triggered for the incoming set of partition keys
336
- let ttlRestore = this.getRecycleBin().getTtlRestoreSnapshot(incomingMsg);
337
- //pass to SCP if there is TTLRestore
338
- if (ttlRestore != null) {
339
- this.scp.process(ttlRestore.getStream(), ttlRestore);
340
- }
341
- }
342
- }
343
- }
344
- triggerTtlRemove() {
345
- if (this.getRecycleBin() != null) {
346
- let removeSnapshotList = this.getRecycleBin().getTtlRemoveSnapshot();
347
- removeSnapshotList.forEach(removeSS => {
348
- this.scp.process(removeSS.getStream(), removeSS);
349
- });
350
- }
351
- }
352
- startTtlVerification() {
353
- if (this.getRecycleBin() != null) {
354
- let ttlConfig = this.getRecycleBin().getTtlConfig();
355
- if (ttlConfig != null && ttlConfig.isEnableTtl()) {
356
- let runInterval = ttlConfig.getRunInterval();
357
- setInterval(() => this.triggerTtlRemove(), runInterval);
358
- console.log("Scheduled TTLCheck with interval of " + runInterval);
359
- }
360
- else {
361
- console.log("No TTL set. Not scheduling any TTL.");
362
- }
363
- }
364
- }
365
- isFeedMessage(mw) {
366
- let msgCls = mw.messageClass;
367
- if (msgCls instanceof message_class_1.InsertOddMessageClass || msgCls instanceof message_class_1.UpdateOddMessageClass
368
- || msgCls instanceof message_class_1.DeleteOddMessageClass || msgCls instanceof message_class_1.InsertEventMessageClass
369
- || msgCls instanceof message_class_1.UpdateEventMessageClass || msgCls instanceof message_class_1.DeleteEventMessageClass
370
- || msgCls instanceof message_class_1.InsertMatchMessageClass || msgCls instanceof message_class_1.UpdateMatchMessageClass
371
- || msgCls instanceof message_class_1.DeleteMatchMessageClass || msgCls instanceof message_class_1.RefreshMessageClass
372
- || msgCls instanceof message_class_1.TTLRemoveMessageClass || msgCls instanceof message_class_1.TTLRestoreMessageClass
373
- || msgCls instanceof message_class_1.ResetMessageClass || msgCls instanceof message_class_1.SwitchFilterStartMessageClass
374
- || msgCls instanceof message_class_1.SwitchFilterFailMessageClass
375
- || msgCls == this.sportsFeedMsgGroup.SWITCH_FILTER_START() || msgCls == this.sportsFeedMsgGroup.SWITCH_FILTER_END()
376
- || msgCls == this.sportsFeedMsgGroup.FULLSNAPSHOT_START() || msgCls == this.sportsFeedMsgGroup.FULLSNAPSHOT_END()
377
- || msgCls == this.sportsFeedMsgGroup.SWITCH_FILTER_FAIL()
378
- || msgCls == this.sportsFeedMsgGroup.TTL_RESTORE_START() || msgCls == this.sportsFeedMsgGroup.TTL_RESTORE_END()) {
379
- return true;
380
- }
381
- return false;
382
- }
383
- getScp() {
384
- return this.scp;
385
- }
386
- getRecycleBin() {
387
- return this.recycleBin;
388
- }
389
- };
390
- SportsFeedInProcessor = __decorate([
391
- (0, injection_js_1.Injectable)(),
392
- __metadata("design:paramtypes", [StreamCommandProcessor, message_class_1.SportsFeedMessageGroup, D.StreamNameCode, core_1.RecycleBin])
393
- ], SportsFeedInProcessor);
394
- exports.SportsFeedInProcessor = SportsFeedInProcessor;
395
- class MergeableIncoming extends data_structure_1.Incoming {
396
- constructor(sportsGrp, snapshotType, streamName, data, bin) {
397
- super(snapshotType, streamName, data);
398
- this.sportsGrp = sportsGrp;
399
- this.bin = bin;
400
- }
401
- apply(before) {
402
- if (before == null) {
403
- before = data_structure_1.IndexedSnapshotImpl.EMPTY_SNAPSHOT;
404
- }
405
- let outgoCol = [];
406
- this.beforeSnap = before;
407
- let wrap = new data_structure_1.MergeableWrapper();
408
- if (this.msgType() instanceof message_class_1.InsertMatchMessageClass || this.msgType() instanceof message_class_1.InsertEventMessageClass || this.msgType() instanceof message_class_1.DeleteMatchMessageClass || this.msgType() instanceof message_class_1.DeleteEventMessageClass || this.msgType() instanceof message_class_1.UpdateEventMessageClass) {
409
- let msgBefore = merge_1.SnapshotUtil.combineSnapshots(this.msgType(), this.data(), before);
410
- let incomeCol = merge_1.DeltaTransformingLogicImpl.transform(this.sportsGrp, this.stream(), this.msgType(), this.data(), msgBefore);
411
- for (let i of incomeCol) {
412
- let iDelta = new core_1.Delta(i, msgBefore.getAfterSs(), this.beforeSnap);
413
- outgoCol.push(iDelta);
414
- this.beforeSnap = msgBefore.getAfterSs();
415
- }
416
- wrap.setAfter(msgBefore.getAfterSs());
417
- wrap.setDeltaOut(outgoCol);
418
- }
419
- else if (this.msgType() instanceof message_class_1.TTLRemoveMessageClass) {
420
- let ttlWrapper = null;
421
- let snapshot = before;
422
- let keyRemoved = new Collections.Dictionary();
423
- let ttlRemoveList = [];
424
- let atleastOneKeyRemoved = false;
425
- let allKeys = before.getPartitionMap();
426
- for (let key of this.data().getPartitions().toArray()) {
427
- console.log("removing keys from upstream " + JSON.stringify(key));
428
- if (!allKeys.containsKey(key)) {
429
- continue;
430
- }
431
- atleastOneKeyRemoved = true;
432
- keyRemoved.setValue(key, allKeys.getValue(key));
433
- ttlWrapper = this.bin.removeData(new data_structure_1.TTLWrapper(), snapshot, key);
434
- snapshot = ttlWrapper.getRemainingSs();
435
- ttlRemoveList.push(ttlWrapper.getRemovedSs());
436
- }
437
- if (atleastOneKeyRemoved) {
438
- console.log("reseting ----->" + JSON.stringify(keyRemoved.keys()));
439
- wrap = merge_1.DeltaTransformingLogicImpl.transformTTLRemove(ttlRemoveList, this.bin.getGrp(), this.stream(), before, snapshot, keyRemoved);
440
- }
441
- else {
442
- wrap.setDeltaOut([]);
443
- wrap.setAfter(before);
444
- }
445
- }
446
- else if (this.msgType() instanceof message_class_1.TTLRestoreMessageClass) {
447
- let ttlWrapper = null;
448
- let snapshot = before;
449
- let restoredKeys = new Collections.Dictionary();
450
- let atleastOneKeyRestored = false;
451
- let matches = {};
452
- let ttlRestoreList = [];
453
- for (let key of this.data().getPartitions().toArray()) {
454
- console.log("restoring keys from upstream " + JSON.stringify(key));
455
- if (this.bin.containData(key)) {
456
- atleastOneKeyRestored = true;
457
- let restoredTime = new Date().getTime();
458
- restoredKeys.setValue(key, restoredTime);
459
- matches = this.bin.copyData(key, matches);
460
- ttlWrapper = this.bin.restoreData(new data_structure_1.TTLWrapper, snapshot, key, restoredTime);
461
- snapshot = ttlWrapper.getRemainingSs();
462
- ttlRestoreList.push(ttlWrapper.getRestoredSs());
463
- }
464
- }
465
- if (atleastOneKeyRestored) {
466
- console.log("restoring ----->" + JSON.stringify(restoredKeys.keys()));
467
- wrap = merge_1.DeltaTransformingLogicImpl.transformTTLRestore(ttlRestoreList, this.bin.getGrp(), this.stream(), before, snapshot, matches, restoredKeys);
468
- }
469
- else {
470
- wrap.setAfter(before);
471
- wrap.setDeltaOut([]);
472
- }
473
- }
474
- else {
475
- let msgBefore = merge_1.SnapshotUtil.combineSnapshots(this.msgType(), this.data(), before);
476
- let iDelta = new core_1.Delta(this, msgBefore.getAfterSs(), before);
477
- outgoCol.push(iDelta);
478
- wrap.setDeltaOut(outgoCol);
479
- wrap.setAfter(msgBefore.getAfterSs());
480
- }
481
- return wrap;
482
- }
483
- }
484
- exports.MergeableIncoming = MergeableIncoming;
@@ -1,13 +0,0 @@
1
- import * as rec from "@jayesol/jayeson.lib.record";
2
- import * as proto from "./protobuf_bundle";
3
- import { ICodec, EncodeAction } from "./codec";
4
- export declare class SoccerCodec implements ICodec {
5
- private codecHelper;
6
- constructor();
7
- private getMatch;
8
- private getEvent;
9
- decodeMatch(input: proto.BaseMatch[], pool: string[], action: EncodeAction, key: rec.PartitionKey): rec.IBetMatch[];
10
- decodeEvent(input: proto.BaseEvent[], pool: string[], action: EncodeAction, partition: rec.PartitionKey): rec.IBetMatch[];
11
- decodeRecord(input: proto.BaseRecord[], pool: string[], action: EncodeAction, partition: rec.PartitionKey): rec.IBetMatch[];
12
- decodeState(matchId: string, eventId: string, input: proto.BaseEventState, pool: string[], action: EncodeAction, partition: rec.PartitionKey, createTime?: number): rec.SoccerEventState;
13
- }