jspurefix 5.11.1 → 5.11.3
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/README.md +13 -1
- package/dist/buffer/fixml/fixml-parser.js +1 -1
- package/dist/buffer/fixml/fixml-parser.js.map +1 -1
- package/dist/config/empty-log-factory.d.ts +2 -2
- package/dist/config/empty-log-factory.js +1 -1
- package/dist/config/empty-log-factory.js.map +1 -1
- package/dist/config/get-js-fx-logger.d.ts +2 -2
- package/dist/config/get-js-fx-logger.js.map +1 -1
- package/dist/config/js-fix-logger-factory.d.ts +2 -2
- package/dist/config/js-fix-logger-factory.js.map +1 -1
- package/dist/config/js-fix-logger.d.ts +9 -8
- package/dist/config/js-fix-logger.js +4 -4
- package/dist/config/js-fix-logger.js.map +1 -1
- package/dist/config/js-fix-winston-log-factory.d.ts +2 -2
- package/dist/config/js-fix-winston-log-factory.js +2 -2
- package/dist/config/js-fix-winston-log-factory.js.map +1 -1
- package/dist/config/winston-logger.d.ts +5 -2
- package/dist/config/winston-logger.js +57 -9
- package/dist/config/winston-logger.js.map +1 -1
- package/dist/dictionary/fragment-safety.d.ts +26 -0
- package/dist/dictionary/fragment-safety.js +154 -0
- package/dist/dictionary/fragment-safety.js.map +1 -0
- package/dist/dictionary/index.d.ts +1 -0
- package/dist/dictionary/index.js +1 -0
- package/dist/dictionary/index.js.map +1 -1
- package/dist/runtime/make-config.js +1 -1
- package/dist/runtime/make-config.js.map +1 -1
- package/dist/runtime/session-launcher.js +1 -1
- package/dist/runtime/session-launcher.js.map +1 -1
- package/dist/sample/http/oms/http-client.js +1 -1
- package/dist/sample/http/oms/http-client.js.map +1 -1
- package/dist/sample/http/oms/http-server.js +1 -1
- package/dist/sample/http/oms/http-server.js.map +1 -1
- package/dist/sample/tcp/qf-md/md-client.js +1 -1
- package/dist/sample/tcp/qf-md/md-client.js.map +1 -1
- package/dist/sample/tcp/qf-md/md-server.js +1 -1
- package/dist/sample/tcp/qf-md/md-server.js.map +1 -1
- package/dist/sample/tcp/recovering-skeleton/respawn-acceptor.js +1 -1
- package/dist/sample/tcp/recovering-skeleton/respawn-acceptor.js.map +1 -1
- package/dist/sample/tcp/recovering-skeleton/skeleton-client.js +1 -1
- package/dist/sample/tcp/recovering-skeleton/skeleton-client.js.map +1 -1
- package/dist/sample/tcp/recovering-skeleton/skeleton-server.js +1 -1
- package/dist/sample/tcp/recovering-skeleton/skeleton-server.js.map +1 -1
- package/dist/sample/tcp/skeleton/skeleton-session.js +1 -1
- package/dist/sample/tcp/skeleton/skeleton-session.js.map +1 -1
- package/dist/sample/tcp/trade-capture/trade-capture-client.js +1 -1
- package/dist/sample/tcp/trade-capture/trade-capture-client.js.map +1 -1
- package/dist/sample/tcp/trade-capture/trade-capture-server.js +1 -1
- package/dist/sample/tcp/trade-capture/trade-capture-server.js.map +1 -1
- package/dist/store/fix-msg-memory-store.js +1 -1
- package/dist/store/fix-msg-memory-store.js.map +1 -1
- package/dist/transport/ascii/ascii-msg-transmitter.js +1 -1
- package/dist/transport/ascii/ascii-msg-transmitter.js.map +1 -1
- package/dist/transport/ascii/ascii-session.js +1 -1
- package/dist/transport/ascii/ascii-session.js.map +1 -1
- package/dist/transport/http/http-acceptor-listener.js +1 -1
- package/dist/transport/http/http-acceptor-listener.js.map +1 -1
- package/dist/transport/http/http-acceptor.js +2 -2
- package/dist/transport/http/http-acceptor.js.map +1 -1
- package/dist/transport/http/http-initiator.js +1 -1
- package/dist/transport/http/http-initiator.js.map +1 -1
- package/dist/transport/http/http-json-sample-adapter.js +1 -1
- package/dist/transport/http/http-json-sample-adapter.js.map +1 -1
- package/dist/transport/session/fix-session.js +3 -3
- package/dist/transport/session/fix-session.js.map +1 -1
- package/dist/transport/session/session-registry.js +1 -1
- package/dist/transport/session/session-registry.js.map +1 -1
- package/dist/transport/tcp/recovering-tcp-initiator.js +1 -1
- package/dist/transport/tcp/recovering-tcp-initiator.js.map +1 -1
- package/dist/transport/tcp/tcp-acceptor-listener.js +2 -2
- package/dist/transport/tcp/tcp-acceptor-listener.js.map +1 -1
- package/dist/transport/tcp/tcp-acceptor.js +2 -2
- package/dist/transport/tcp/tcp-acceptor.js.map +1 -1
- package/dist/transport/tcp/tcp-initiator-connector.js +2 -2
- package/dist/transport/tcp/tcp-initiator-connector.js.map +1 -1
- package/dist/transport/tcp/tcp-initiator.js +1 -1
- package/dist/transport/tcp/tcp-initiator.js.map +1 -1
- package/docs/instrumentation.md +360 -0
- package/docs/scattered-components.md +280 -0
- package/jsfix.test_client.txt +62 -62
- package/jsfix.test_server.txt +72 -72
- package/package.json +1 -1
- package/src/buffer/fixml/fixml-parser.ts +1 -1
- package/src/config/empty-log-factory.ts +2 -2
- package/src/config/get-js-fx-logger.ts +2 -2
- package/src/config/js-fix-logger-factory.ts +8 -2
- package/src/config/js-fix-logger.ts +23 -8
- package/src/config/js-fix-winston-log-factory.ts +3 -3
- package/src/config/winston-logger.ts +93 -10
- package/src/dictionary/fragment-safety.ts +225 -0
- package/src/dictionary/index.ts +1 -0
- package/src/runtime/make-config.ts +1 -1
- package/src/runtime/session-launcher.ts +1 -1
- package/src/sample/http/oms/http-client.ts +1 -1
- package/src/sample/http/oms/http-server.ts +1 -1
- package/src/sample/tcp/qf-md/md-client.ts +1 -1
- package/src/sample/tcp/qf-md/md-server.ts +1 -1
- package/src/sample/tcp/recovering-skeleton/respawn-acceptor.ts +2 -1
- package/src/sample/tcp/recovering-skeleton/skeleton-client.ts +1 -1
- package/src/sample/tcp/recovering-skeleton/skeleton-server.ts +1 -1
- package/src/sample/tcp/skeleton/skeleton-session.ts +1 -1
- package/src/sample/tcp/trade-capture/trade-capture-client.ts +2 -1
- package/src/sample/tcp/trade-capture/trade-capture-server.ts +2 -1
- package/src/store/fix-msg-memory-store.ts +2 -1
- package/src/transport/ascii/ascii-msg-transmitter.ts +2 -1
- package/src/transport/ascii/ascii-session.ts +2 -1
- package/src/transport/http/http-acceptor-listener.ts +2 -1
- package/src/transport/http/http-acceptor.ts +2 -1
- package/src/transport/http/http-initiator.ts +2 -1
- package/src/transport/http/http-json-sample-adapter.ts +1 -1
- package/src/transport/session/fix-session.ts +2 -1
- package/src/transport/session/session-registry.ts +1 -1
- package/src/transport/tcp/recovering-tcp-initiator.ts +2 -1
- package/src/transport/tcp/tcp-acceptor-listener.ts +4 -2
- package/src/transport/tcp/tcp-acceptor.ts +2 -1
- package/src/transport/tcp/tcp-initiator-connector.ts +4 -2
- package/src/transport/tcp/tcp-initiator.ts +2 -1
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FragmentSafety = exports.FragmentSafetyCode = void 0;
|
|
4
|
+
exports.describeFinding = describeFinding;
|
|
5
|
+
const contained_1 = require("./contained");
|
|
6
|
+
var FragmentSafetyCode;
|
|
7
|
+
(function (FragmentSafetyCode) {
|
|
8
|
+
FragmentSafetyCode["SiblingTagCollision"] = "sibling-tag-collision";
|
|
9
|
+
FragmentSafetyCode["UnclaimableComponent"] = "unclaimable-component";
|
|
10
|
+
})(FragmentSafetyCode || (exports.FragmentSafetyCode = FragmentSafetyCode = {}));
|
|
11
|
+
function describeFinding(f) {
|
|
12
|
+
switch (f.code) {
|
|
13
|
+
case FragmentSafetyCode.SiblingTagCollision:
|
|
14
|
+
return `${f.path}: tag ${f.tag} is claimed by ${f.owners.join(' and ')}`;
|
|
15
|
+
case FragmentSafetyCode.UnclaimableComponent:
|
|
16
|
+
return `${f.path}: owns no tag of its own`;
|
|
17
|
+
default:
|
|
18
|
+
return f.path;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
class FragmentSafety {
|
|
22
|
+
constructor() {
|
|
23
|
+
this.findings = [];
|
|
24
|
+
this.analysed = new Set();
|
|
25
|
+
this.owned = new Map();
|
|
26
|
+
}
|
|
27
|
+
ownTags(set) {
|
|
28
|
+
const memo = this.owned.get(set);
|
|
29
|
+
if (memo)
|
|
30
|
+
return memo;
|
|
31
|
+
this.owned.set(set, []);
|
|
32
|
+
const tags = [];
|
|
33
|
+
for (const field of set.fields) {
|
|
34
|
+
switch (field.type) {
|
|
35
|
+
case contained_1.ContainedFieldType.Simple: {
|
|
36
|
+
tags.push(field.definition.tag);
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
case contained_1.ContainedFieldType.Component: {
|
|
40
|
+
const cf = field;
|
|
41
|
+
for (const t of this.ownTags(cf.definition)) {
|
|
42
|
+
tags.push(t);
|
|
43
|
+
}
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
case contained_1.ContainedFieldType.Group: {
|
|
47
|
+
const gf = field;
|
|
48
|
+
const nof = gf.definition.noOfField;
|
|
49
|
+
if (nof) {
|
|
50
|
+
tags.push(nof.tag);
|
|
51
|
+
}
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
default:
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
this.owned.set(set, tags);
|
|
59
|
+
return tags;
|
|
60
|
+
}
|
|
61
|
+
static analyse(definitions) {
|
|
62
|
+
const instance = new FragmentSafety();
|
|
63
|
+
const seen = new Set();
|
|
64
|
+
for (const message of definitions.message.values()) {
|
|
65
|
+
if (seen.has(message))
|
|
66
|
+
continue;
|
|
67
|
+
seen.add(message);
|
|
68
|
+
instance.walk(message, message.name);
|
|
69
|
+
}
|
|
70
|
+
return instance.findings;
|
|
71
|
+
}
|
|
72
|
+
static analyseSet(set, path) {
|
|
73
|
+
const instance = new FragmentSafety();
|
|
74
|
+
instance.walk(set, path !== null && path !== void 0 ? path : set.name);
|
|
75
|
+
return instance.findings;
|
|
76
|
+
}
|
|
77
|
+
walk(set, path) {
|
|
78
|
+
if (this.analysed.has(set))
|
|
79
|
+
return;
|
|
80
|
+
this.analysed.add(set);
|
|
81
|
+
this.checkSiblings(set, path);
|
|
82
|
+
for (const field of set.fields) {
|
|
83
|
+
switch (field.type) {
|
|
84
|
+
case contained_1.ContainedFieldType.Component: {
|
|
85
|
+
const cf = field;
|
|
86
|
+
this.checkClaimable(cf, `${path}.${cf.name}`);
|
|
87
|
+
this.walk(cf.definition, `${path}.${cf.name}`);
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
case contained_1.ContainedFieldType.Group: {
|
|
91
|
+
const gf = field;
|
|
92
|
+
this.walk(gf.definition, `${path}.${gf.name}`);
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
default:
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
checkClaimable(cf, path) {
|
|
101
|
+
if (this.ownTags(cf.definition).length > 0)
|
|
102
|
+
return;
|
|
103
|
+
this.findings.push({
|
|
104
|
+
code: FragmentSafetyCode.UnclaimableComponent,
|
|
105
|
+
path,
|
|
106
|
+
set: cf.name,
|
|
107
|
+
tag: 0,
|
|
108
|
+
owners: []
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
checkSiblings(set, path) {
|
|
112
|
+
const claims = new Map();
|
|
113
|
+
for (const field of set.fields) {
|
|
114
|
+
for (const tag of this.claimsOf(field)) {
|
|
115
|
+
const owners = claims.get(tag);
|
|
116
|
+
if (owners) {
|
|
117
|
+
if (!owners.includes(field.name)) {
|
|
118
|
+
owners.push(field.name);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
claims.set(tag, [field.name]);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
for (const [tag, owners] of claims) {
|
|
127
|
+
if (owners.length < 2)
|
|
128
|
+
continue;
|
|
129
|
+
this.findings.push({
|
|
130
|
+
code: FragmentSafetyCode.SiblingTagCollision,
|
|
131
|
+
path,
|
|
132
|
+
set: set.name,
|
|
133
|
+
tag,
|
|
134
|
+
owners
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
claimsOf(field) {
|
|
139
|
+
switch (field.type) {
|
|
140
|
+
case contained_1.ContainedFieldType.Simple:
|
|
141
|
+
return [field.definition.tag];
|
|
142
|
+
case contained_1.ContainedFieldType.Component:
|
|
143
|
+
return this.ownTags(field.definition);
|
|
144
|
+
case contained_1.ContainedFieldType.Group: {
|
|
145
|
+
const nof = field.definition.noOfField;
|
|
146
|
+
return nof ? [nof.tag] : [];
|
|
147
|
+
}
|
|
148
|
+
default:
|
|
149
|
+
return [];
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
exports.FragmentSafety = FragmentSafety;
|
|
154
|
+
//# sourceMappingURL=fragment-safety.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fragment-safety.js","sourceRoot":"","sources":["../../src/dictionary/fragment-safety.ts"],"names":[],"mappings":";;;AA6DA,0CASC;AAtED,2CAOoB;AAoBpB,IAAY,kBAWX;AAXD,WAAY,kBAAkB;IAK5B,mEAA6C,CAAA;IAK7C,oEAA8C,CAAA;AAChD,CAAC,EAXW,kBAAkB,kCAAlB,kBAAkB,QAW7B;AAuBD,SAAgB,eAAe,CAAE,CAAyB;IACxD,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC;QACf,KAAK,kBAAkB,CAAC,mBAAmB;YACzC,OAAO,GAAG,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,GAAG,kBAAkB,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAA;QAC1E,KAAK,kBAAkB,CAAC,oBAAoB;YAC1C,OAAO,GAAG,CAAC,CAAC,IAAI,0BAA0B,CAAA;QAC5C;YACE,OAAO,CAAC,CAAC,IAAI,CAAA;IACjB,CAAC;AACH,CAAC;AAED,MAAa,cAAc;IAA3B;QACmB,aAAQ,GAA6B,EAAE,CAAA;QACvC,aAAQ,GAAG,IAAI,GAAG,EAAiB,CAAA;QACnC,UAAK,GAAG,IAAI,GAAG,EAA2B,CAAA;IAqJ7D,CAAC;IA1IQ,OA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,CAAC;qBAAM,CAAC;oBACN,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;gBAC/B,CAAC;YACH,CAAC;QACH,CAAC;QACD,KAAK,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;YACnC,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;gBAAE,SAAQ;YAC/B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;gBACjB,IAAI,EAAE,kBAAkB,CAAC,mBAAmB;gBAC5C,IAAI;gBACJ,GAAG,EAAE,GAAG,CAAC,IAAI;gBACb,GAAG;gBACH,MAAM;aACP,CAAC,CAAA;QACJ,CAAC;IACH,CAAC;IAEO,QAAQ,CAAE,KAAqB;QACrC,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;YACnB,KAAK,8BAAkB,CAAC,MAAM;gBAC5B,OAAO,CAAE,KAA8B,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;YACzD,KAAK,8BAAkB,CAAC,SAAS;gBAC/B,OAAO,IAAI,CAAC,OAAO,CAAE,KAAiC,CAAC,UAAU,CAAC,CAAA;YACpE,KAAK,8BAAkB,CAAC,KAAK,CAAC,CAAC,CAAC;gBAC9B,MAAM,GAAG,GAAI,KAA6B,CAAC,UAAU,CAAC,SAAS,CAAA;gBAC/D,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;YAC7B,CAAC;YACD;gBACE,OAAO,EAAE,CAAA;QACb,CAAC;IACH,CAAC;CACF;AAxJD,wCAwJC","sourcesContent":["import {\n ContainedComponentField,\n ContainedField,\n ContainedFieldType,\n ContainedGroupField,\n ContainedSimpleField,\n IContainedSet\n} from './contained'\nimport { FixDefinitions } from './definition'\n\n/**\n * Static analysis of a dictionary, asking one question: if a component's tags arrived\n * scattered through a message rather than adjacently, could this dictionary still say\n * unambiguously which component each tag belongs to?\n *\n * The segment parser normally answers that from *position* - a tag between the first and\n * last tag of a component belongs to it. A counterparty that emits a component's tags\n * non-adjacently breaks the inference, and the tags themselves become the only evidence\n * left. That works whenever the children of one set own disjoint tags, which FIX's tag\n * numbering conventions (Underlying*, Leg*, NestedParties2/3) exist to guarantee, but a\n * house dictionary is under no obligation to honour them.\n *\n * See docs/scattered-components.md. Nothing in the engine consumes this yet - it is a\n * diagnostic run against a dictionary to find out whether the assumption holds before any\n * code is written that depends on it.\n */\n\nexport enum FragmentSafetyCode {\n /**\n * two children of one set both claim the same tag, so a scattered instance of either\n * could not be attributed to one of them by tag alone\n */\n SiblingTagCollision = 'sibling-tag-collision',\n /**\n * a component owns no tag at its own level, so a scattered instance leaves no evidence\n * it was ever present\n */\n UnclaimableComponent = 'unclaimable-component'\n}\n\nexport interface IFragmentSafetyFinding {\n readonly code: FragmentSafetyCode\n /**\n * dotted path to the set the finding is about, from the message it was first reached\n * through e.g. 'NewOrderSingle.Instrument'\n */\n readonly path: string\n /**\n * name of the set whose children collide, or of the unclaimable component\n */\n readonly set: string\n /**\n * the contended tag, or 0 for an unclaimable component\n */\n readonly tag: number\n /**\n * names of the children of `set` that each claim `tag`\n */\n readonly owners: string[]\n}\n\nexport function describeFinding (f: IFragmentSafetyFinding): string {\n switch (f.code) {\n case FragmentSafetyCode.SiblingTagCollision:\n return `${f.path}: tag ${f.tag} is claimed by ${f.owners.join(' and ')}`\n case FragmentSafetyCode.UnclaimableComponent:\n return `${f.path}: owns no tag of its own`\n default:\n return f.path\n }\n}\n\nexport class FragmentSafety {\n private readonly findings: IFragmentSafetyFinding[] = []\n private readonly analysed = new Set<IContainedSet>()\n private readonly owned = new Map<IContainedSet, number[]>()\n\n /**\n * tags a set can claim at its own level - its simple fields, the same from any\n * component nested below it, and the NumInGroup tag of any group it contains.\n *\n * a group's *interior* is deliberately excluded. a repeating group is the one\n * self describing construct in tag value FIX, so its instances are always delimiter\n * framed and contiguous, and its member tags are never evidence about the level above.\n * this is the same distinction `flattenedTag` does not draw.\n */\n public ownTags (set: IContainedSet): number[] {\n const memo = this.owned.get(set)\n if (memo) return memo\n // seed before recursing so a self referencing dictionary terminates\n this.owned.set(set, [])\n const tags: number[] = []\n for (const field of set.fields) {\n switch (field.type) {\n case ContainedFieldType.Simple: {\n tags.push((field as ContainedSimpleField).definition.tag)\n break\n }\n case ContainedFieldType.Component: {\n const cf = field as ContainedComponentField\n for (const t of this.ownTags(cf.definition)) {\n tags.push(t)\n }\n break\n }\n case ContainedFieldType.Group: {\n const gf = field as ContainedGroupField\n const nof = gf.definition.noOfField\n if (nof) {\n tags.push(nof.tag)\n }\n break\n }\n default:\n break\n }\n }\n this.owned.set(set, tags)\n return tags\n }\n\n /**\n * every message in the dictionary, and every component and group reachable from one,\n * each analysed once however many messages reach it\n */\n public static analyse (definitions: FixDefinitions): IFragmentSafetyFinding[] {\n const instance = new FragmentSafety()\n // the message map is keyed by name, msgType and abbreviation, so walk distinct sets\n const seen = new Set<IContainedSet>()\n for (const message of definitions.message.values()) {\n if (seen.has(message)) continue\n seen.add(message)\n instance.walk(message, message.name)\n }\n return instance.findings\n }\n\n /**\n * a single set and everything below it, for a dictionary fragment under test\n */\n public static analyseSet (set: IContainedSet, path?: string): IFragmentSafetyFinding[] {\n const instance = new FragmentSafety()\n instance.walk(set, path ?? set.name)\n return instance.findings\n }\n\n private walk (set: IContainedSet, path: string): void {\n if (this.analysed.has(set)) return\n this.analysed.add(set)\n this.checkSiblings(set, path)\n for (const field of set.fields) {\n switch (field.type) {\n case ContainedFieldType.Component: {\n const cf = field as ContainedComponentField\n this.checkClaimable(cf, `${path}.${cf.name}`)\n this.walk(cf.definition, `${path}.${cf.name}`)\n break\n }\n case ContainedFieldType.Group: {\n // the instance body of a group is a level in its own right, and everything\n // said about scattering above applies again inside it\n const gf = field as ContainedGroupField\n this.walk(gf.definition, `${path}.${gf.name}`)\n break\n }\n default:\n break\n }\n }\n }\n\n private checkClaimable (cf: ContainedComponentField, path: string): void {\n if (this.ownTags(cf.definition).length > 0) return\n this.findings.push({\n code: FragmentSafetyCode.UnclaimableComponent,\n path,\n set: cf.name,\n tag: 0,\n owners: []\n })\n }\n\n private checkSiblings (set: IContainedSet, path: string): void {\n // tag -> the children of this set claiming it. a tag reaching two children is what\n // makes a scattered instance unattributable\n const claims = new Map<number, string[]>()\n for (const field of set.fields) {\n for (const tag of this.claimsOf(field)) {\n const owners = claims.get(tag)\n if (owners) {\n if (!owners.includes(field.name)) {\n owners.push(field.name)\n }\n } else {\n claims.set(tag, [field.name])\n }\n }\n }\n for (const [tag, owners] of claims) {\n if (owners.length < 2) continue\n this.findings.push({\n code: FragmentSafetyCode.SiblingTagCollision,\n path,\n set: set.name,\n tag,\n owners\n })\n }\n }\n\n private claimsOf (field: ContainedField): number[] {\n switch (field.type) {\n case ContainedFieldType.Simple:\n return [(field as ContainedSimpleField).definition.tag]\n case ContainedFieldType.Component:\n return this.ownTags((field as ContainedComponentField).definition)\n case ContainedFieldType.Group: {\n const nof = (field as ContainedGroupField).definition.noOfField\n return nof ? [nof.tag] : []\n }\n default:\n return []\n }\n }\n}\n"]}
|
package/dist/dictionary/index.js
CHANGED
|
@@ -19,5 +19,6 @@ __exportStar(require("./field-enum"), exports);
|
|
|
19
19
|
__exportStar(require("./contained/fields-dispatch"), exports);
|
|
20
20
|
__exportStar(require("./fix-parser"), exports);
|
|
21
21
|
__exportStar(require("./fix-versions"), exports);
|
|
22
|
+
__exportStar(require("./fragment-safety"), exports);
|
|
22
23
|
__exportStar(require("./set-reduce"), exports);
|
|
23
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/dictionary/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAgC;AAChC,+CAA4B;AAC5B,8DAA2C;AAC3C,+CAA4B;AAC5B,iDAA8B;AAC9B,+CAA4B","sourcesContent":["export * from './dict-primitive'\nexport * from './field-enum'\nexport * from './contained/fields-dispatch'\nexport * from './fix-parser'\nexport * from './fix-versions'\nexport * from './set-reduce'\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/dictionary/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,mDAAgC;AAChC,+CAA4B;AAC5B,8DAA2C;AAC3C,+CAA4B;AAC5B,iDAA8B;AAC9B,oDAAiC;AACjC,+CAA4B","sourcesContent":["export * from './dict-primitive'\nexport * from './field-enum'\nexport * from './contained/fields-dispatch'\nexport * from './fix-parser'\nexport * from './fix-versions'\nexport * from './fragment-safety'\nexport * from './set-reduce'\n"]}
|
|
@@ -49,7 +49,7 @@ let RuntimeFactory = class RuntimeFactory {
|
|
|
49
49
|
if (!type)
|
|
50
50
|
reject(new Error('no application type in application object'));
|
|
51
51
|
this.definitionFactory.getDefinitions(path, (t) => {
|
|
52
|
-
return this.logFactory.logger(`${type}.${t}
|
|
52
|
+
return this.logFactory.logger(`${type}.${t}`, { component: t, role: type });
|
|
53
53
|
}).then((definitions) => {
|
|
54
54
|
const config = new config_1.JsFixConfig(this.msgFactory, definitions, description, ascii_1.AsciiChars.Soh, this.logFactory);
|
|
55
55
|
resolve(config);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"make-config.js","sourceRoot":"","sources":["../../src/runtime/make-config.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4C;AAE5C,sCAAyE;AAEzE,mCAA4C;AAC5C,uCAA6C;AAC7C,2CAAsC;AAG/B,IAAM,cAAc,GAApB,MAAM,cAAc;IACzB,YAC6C,iBAAoC,EAC1B,UAA8B,EAC9B,UAA8B,EAC7B,WAAgC;QAH3C,sBAAiB,GAAjB,iBAAiB,CAAmB;QAC1B,eAAU,GAAV,UAAU,CAAoB;QAC9B,eAAU,GAAV,UAAU,CAAoB;QAC7B,gBAAW,GAAX,WAAW,CAAqB;IAAG,CAAC;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AE,CAAC;oBACX,MAAM,CAAC,CAAC,CAAC,CAAA;gBACX,CAAC;YACH,CAAC,CAAC,CAAA;QACJ,CAAC;KAAA;CACF,CAAA;AA9BY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,qBAAU,GAAE;IAGR,WAAA,IAAA,iBAAM,EAAC,wBAAiB,CAAC,CAAA;IACzB,WAAA,IAAA,iBAAM,EAAC,oBAAQ,CAAC,kBAAkB,CAAC,CAAA;IACnC,WAAA,IAAA,iBAAM,EAAC,oBAAQ,CAAC,kBAAkB,CAAC,CAAA;IACnC,WAAA,IAAA,iBAAM,EAAC,oBAAQ,CAAC,mBAAmB,CAAC,CAAA;qCAHyB,wBAAiB;QACd,2BAAkB;GAH1E,cAAc,CA8B1B","sourcesContent":["import { AsciiChars } from '../buffer/ascii'\nimport { ISessionDescription, ISessionMsgFactory } from '../transport/'\nimport { IJsFixConfig, JsFixConfig, JsFixLoggerFactory } from '../config'\nimport { FixDefinitions } from '../dictionary/definition'\nimport { DefinitionFactory } from '../util/'\nimport { injectable, inject } from 'tsyringe'\nimport { DITokens } from './di-tokens'\n\n@injectable()\nexport class RuntimeFactory {\n constructor (\n @inject(DefinitionFactory) public readonly definitionFactory: DefinitionFactory,\n @inject(DITokens.JsFixLoggerFactory) public readonly logFactory: JsFixLoggerFactory,\n @inject(DITokens.ISessionMsgFactory) public readonly msgFactory: ISessionMsgFactory,\n @inject(DITokens.ISessionDescription) public readonly description: ISessionDescription) {}\n\n async makeConfig (): Promise<IJsFixConfig> {\n const description = this.description || null\n return await new Promise<IJsFixConfig>((resolve, reject) => {\n try {\n if (!description) reject(new Error('no description object'))\n const path = description.application?.dictionary ?? 'na'\n if (!path) reject(new Error('no dictionary in application object'))\n const type = description.application?.type ?? null\n if (!type) reject(new Error('no application type in application object'))\n this.definitionFactory.getDefinitions(path,\n (t: string) => {\n return this.logFactory.logger(`${type}.${t}`, { component: t, role: type })\n }).then((definitions: FixDefinitions) => {\n const config = new JsFixConfig(this.msgFactory, definitions, description, AsciiChars.Soh, this.logFactory)\n resolve(config)\n }).catch(e => {\n reject(e)\n })\n } catch (e) {\n reject(e)\n }\n })\n }\n}\n"]}
|
|
@@ -56,7 +56,7 @@ class SessionLauncher {
|
|
|
56
56
|
this.acceptorEntity = null;
|
|
57
57
|
this.initiatorEntity = null;
|
|
58
58
|
this.stopRequested = false;
|
|
59
|
-
this.logger = this.loggerFactory.logger('launcher');
|
|
59
|
+
this.logger = this.loggerFactory.logger('launcher', { component: 'SessionLauncher' });
|
|
60
60
|
this.initiatorConfig = initiatorConfig ? this.loadConfig(initiatorConfig) : null;
|
|
61
61
|
this.acceptorConfig = acceptorConfig ? this.loadConfig(acceptorConfig) : null;
|
|
62
62
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-launcher.js","sourceRoot":"","sources":["../../src/runtime/session-launcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4B;AAC5B,sCAAiH;AAIjH,2DAAsD;AACtD,2CAAsC;AAEtC,MAAM,oBAAoB,GAAG,IAAI,+BAAsB,CAAC,sBAAa,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAA;AAE7F,MAAsB,eAAe;IAMnC,YACE,kBAAuD,IAAI,EAC3D,iBAAsD,IAAI,EACzC,gBAAoC,oBAAoB;QAAxD,kBAAa,GAAb,aAAa,CAA2C;QARpE,SAAI,GAAW,QAAQ,CAAA;QAiBpB,qBAAgB,GACxB,IAAI,oCAAgB,CAAC,CAAC,CAAsB,EAAE,EAAE,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAA;QA6BzE,mBAAc,GAAqB,IAAI,CAAA;QACvC,oBAAe,GAAqB,IAAI,CAAA;QACxC,kBAAa,GAAY,KAAK,CAAA;QAvCpC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,UAAU,CAAC,CAA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AAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAA;QAC9C,CAAC;QACD,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AAzPD,0CAyPC","sourcesContent":["import * as path from 'path'\nimport { IJsFixConfig, IJsFixLogger, JsFixLoggerFactory, JsFixWinstonLogFactory, WinstonLogger } from '../config'\nimport { FixEntity, FixSession, ISessionDescription, ISessionMsgFactory } from '../transport'\nimport { DependencyContainer } from 'tsyringe'\nimport { EngineFactory } from './engine-factory'\nimport { SessionContainer } from './session-container'\nimport { DITokens } from './di-tokens'\n\nconst defaultLoggerFactory = new JsFixWinstonLogFactory(WinstonLogger.consoleOptions('info'))\n\nexport abstract class SessionLauncher {\n public root: string = '../../'\n protected readonly logger: IJsFixLogger\n public readonly initiatorConfig: ISessionDescription | null\n public readonly acceptorConfig: ISessionDescription | null\n\n protected constructor (\n initiatorConfig: string | ISessionDescription | null = null,\n acceptorConfig: string | ISessionDescription | null = null,\n private readonly loggerFactory: JsFixLoggerFactory = defaultLoggerFactory\n ) {\n this.logger = this.loggerFactory.logger('launcher')\n this.initiatorConfig = initiatorConfig ? this.loadConfig(initiatorConfig) : null\n this.acceptorConfig = acceptorConfig ? this.loadConfig(acceptorConfig) : null\n }\n\n // the arrow defers to makeSessionMsgFactory at resolve time, so a subclass need\n // only override that one method - no SessionContainer subclass required\n protected sessionContainer: SessionContainer =\n new SessionContainer((d: ISessionDescription) => this.makeSessionMsgFactory(d))\n\n /**\n * Override to supply this application's own session message factory - the place to\n * put a Logon carrying tags the standard message does not, or a header a\n * counterparty stamps differently. Return null (the default) for the stock\n * factory.\n *\n * For a Logon that only needs extra fields, prefer the \"Logon\" block in the session\n * description - it needs no code at all. Reach for a factory when the values are\n * computed at run time (a signature, a nonce, a token fetched at start up).\n */\n protected makeSessionMsgFactory (_description: ISessionDescription): ISessionMsgFactory | null {\n return null\n }\n\n private async empty (): Promise<any> {\n return await new Promise((resolve, reject) => {\n try {\n setImmediate(() => {\n this.logger.info('resolving an empty promise')\n resolve(null)\n })\n } catch (e) {\n reject(e)\n }\n })\n }\n\n private acceptorEntity: FixEntity | null = null\n private initiatorEntity: FixEntity | null = null\n private stopRequested: boolean = false\n\n protected async getAcceptor (sessionContainer: DependencyContainer): Promise<any> {\n if (sessionContainer.isRegistered<FixEntity>(DITokens.FixEntity)) {\n const entity = sessionContainer.resolve<FixEntity>(DITokens.FixEntity)\n this.acceptorEntity = entity\n // a stop can arrive while the container is still being built - the listener has\n // no existence yet to close, so honour the request by never opening it\n if (this.stopRequested) {\n this.logger.info('stop requested before the acceptor started - not listening')\n return this.empty()\n }\n return entity.start()\n } else {\n return this.empty()\n }\n }\n\n protected async getInitiator (sessionContainer: DependencyContainer): Promise<any> {\n if (sessionContainer.isRegistered<FixEntity>(DITokens.FixEntity)) {\n const entity = sessionContainer.resolve<FixEntity>(DITokens.FixEntity)\n this.initiatorEntity = entity\n if (this.stopRequested) {\n this.logger.info('stop requested before the initiator started - not connecting')\n return this.empty()\n }\n return entity.start()\n } else {\n return this.empty()\n }\n }\n\n /**\n * provide a factory which will be invoked with a config where an instance of the application\n * should be constructed and returned.\n * @param config to be provided to the constucted application representing this session\n * @protected\n */\n protected makeFactory (config: IJsFixConfig): EngineFactory | null {\n return null\n }\n\n /**\n * Stop what this launcher started - close the acceptor's listener, and give up a\n * resilient initiator's attempts to get its transport back.\n *\n * An acceptor is meant to outlive any one counterparty, so nothing closes its\n * listener on its own. That is right for a venue and wrong for an application\n * which knows it is finished: the listening socket alone keeps node alive, long\n * after every session has logged out and every transport has been harvested.\n *\n * Until now the only caller was the both-roles branch of setup() below, which an\n * application cannot reach once it gives the acceptor a launcher of its own - the\n * usual arrangement as soon as more than one client is involved. There was then\n * no way to shut a listener down short of killing the process.\n *\n * A resilient initiator had the same problem from the other side: losing the\n * transport schedules another attempt, so it too kept the process alive with no way\n * to call it off. See issue #72.\n *\n * Safe before start (the request is remembered and neither is opened), and safe to\n * call twice. run() resolves once the listener has closed and the initiator has\n * given up.\n */\n public stop (): void {\n this.stopRequested = true\n this.stopAcceptor()\n this.stopInitiator()\n }\n\n public async run (): Promise<boolean> {\n return await new Promise<any>((resolve, reject) => {\n const logger = this.logger\n logger.info('launching ..')\n this.setup().then(() => {\n logger.info('.. done')\n resolve(true)\n }).catch((e: Error) => {\n logger.error(e)\n reject(e)\n })\n })\n }\n\n public exec (): void {\n this.run().then(() => {\n console.log('finished.')\n }).catch(e => {\n console.error(e)\n })\n }\n\n /**\n * is this session config representing an ascii based session\n * @param description config to be tested.\n */\n public isAscii (description: ISessionDescription): boolean {\n return this.sessionContainer.isAscii(description)\n }\n\n /**\n * is this session config representing an initiator based session\n * @param description config to be tested.\n */\n public isInitiator (description: ISessionDescription): boolean {\n return this.sessionContainer.isInitiator(description)\n }\n\n protected registerApplication (_: DependencyContainer): void {\n this.logger.info('bypass register via DI')\n }\n\n private async makeSystem (description: ISessionDescription): Promise<DependencyContainer> {\n const name = description.application?.name ?? 'na'\n const protocol = description.application?.protocol ?? 'ascii'\n this.logger.info(`creating app ${name} [protocol ${protocol}]`)\n return await this.sessionContainer.makeSystem(description)\n }\n\n private register (container: DependencyContainer): void {\n const config = container.resolve<IJsFixConfig>(DITokens.IJsFixConfig)\n const factory = this.makeFactory(config)\n if (!factory) {\n this.registerApplication(container)\n } else {\n if (factory.makeSession) {\n // resolve the config from the container doing the resolving, not the one\n // captured here. An acceptor resolves each session from a per-connection\n // child scope which re-registers IJsFixConfig, so this is how an application\n // receives that session's own description, store and message factory.\n container.register<FixSession>(DITokens.FixSession, {\n useFactory: (c) => factory.makeSession(c.resolve<IJsFixConfig>(DITokens.IJsFixConfig))\n })\n }\n }\n }\n\n private async makeClient (): Promise<any> {\n if (!this.initiatorConfig) return\n const sessionContainer = await this.makeSystem(this.initiatorConfig)\n this.register(sessionContainer)\n this.logger.info('create initiator')\n return await this.getInitiator(sessionContainer)\n }\n\n private async makeServer (): Promise<any> {\n if (!this.acceptorConfig) return\n const sessionContainer = await this.makeSystem(this.acceptorConfig)\n this.register(sessionContainer)\n this.logger.info('create acceptor')\n return await this.getAcceptor(sessionContainer)\n }\n\n async serverOrEmpty (): Promise<any> {\n return this.acceptorConfig ? this.makeServer() : this.empty()\n }\n\n async clientOrEmpty (): Promise<any> {\n return this.initiatorConfig ? this.makeClient() : this.empty()\n }\n\n private async setup (): Promise<any> {\n this.sessionContainer.registerGlobal(this.loggerFactory)\n const server = this.serverOrEmpty()\n const client = this.clientOrEmpty()\n this.logger.info('launching ....')\n if (this.acceptorConfig && this.initiatorConfig) {\n // Both mode: client drives the lifecycle. When client finishes,\n // stop the acceptor so the process can exit cleanly.\n await client\n this.logger.info('client finished, stopping acceptor')\n this.stop()\n return true\n }\n return await Promise.all([server, client])\n }\n\n private stopAcceptor (): void {\n const entity = this.acceptorEntity as any\n if (entity && typeof entity.stop === 'function') {\n entity.stop()\n }\n }\n\n // only a resilient initiator has anything to call off - a plain one ends with its\n // session, so it has no stop to find here\n private stopInitiator (): void {\n const entity = this.initiatorEntity as any\n if (entity && typeof entity.stop === 'function') {\n entity.stop()\n }\n }\n\n private loadConfig (config: string | ISessionDescription): ISessionDescription {\n if (typeof config === 'string') {\n return require(path.join(this.root, config))\n }\n return config\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"session-launcher.js","sourceRoot":"","sources":["../../src/runtime/session-launcher.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4B;AAC5B,sCAAiH;AAIjH,2DAAsD;AACtD,2CAAsC;AAEtC,MAAM,oBAAoB,GAAG,IAAI,+BAAsB,CAAC,sBAAa,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC,CAAA;AAE7F,MAAsB,eAAe;IAMnC,YACE,kBAAuD,IAAI,EAC3D,iBAAsD,IAAI,EACzC,gBAAoC,oBAAoB;QAAxD,kBAAa,GAAb,aAAa,CAA2C;QARpE,SAAI,GAAW,QAAQ,CAAA;QAiBpB,qBAAgB,GACxB,IAAI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,aAAa;QACnB,MAAM,MAAM,GAAG,IAAI,CAAC,eAAsB,CAAA;QAC1C,IAAI,MAAM,IAAI,OAAO,MAAM,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YAChD,MAAM,CAAC,IAAI,EAAE,CAAA;QACf,CAAC;IACH,CAAC;IAEO,UAAU,CAAE,MAAoC;QACtD,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;YAC/B,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAA;QAC9C,CAAC;QACD,OAAO,MAAM,CAAA;IACf,CAAC;CACF;AAzPD,0CAyPC","sourcesContent":["import * as path from 'path'\nimport { IJsFixConfig, IJsFixLogger, JsFixLoggerFactory, JsFixWinstonLogFactory, WinstonLogger } from '../config'\nimport { FixEntity, FixSession, ISessionDescription, ISessionMsgFactory } from '../transport'\nimport { DependencyContainer } from 'tsyringe'\nimport { EngineFactory } from './engine-factory'\nimport { SessionContainer } from './session-container'\nimport { DITokens } from './di-tokens'\n\nconst defaultLoggerFactory = new JsFixWinstonLogFactory(WinstonLogger.consoleOptions('info'))\n\nexport abstract class SessionLauncher {\n public root: string = '../../'\n protected readonly logger: IJsFixLogger\n public readonly initiatorConfig: ISessionDescription | null\n public readonly acceptorConfig: ISessionDescription | null\n\n protected constructor (\n initiatorConfig: string | ISessionDescription | null = null,\n acceptorConfig: string | ISessionDescription | null = null,\n private readonly loggerFactory: JsFixLoggerFactory = defaultLoggerFactory\n ) {\n this.logger = this.loggerFactory.logger('launcher', { component: 'SessionLauncher' })\n this.initiatorConfig = initiatorConfig ? this.loadConfig(initiatorConfig) : null\n this.acceptorConfig = acceptorConfig ? this.loadConfig(acceptorConfig) : null\n }\n\n // the arrow defers to makeSessionMsgFactory at resolve time, so a subclass need\n // only override that one method - no SessionContainer subclass required\n protected sessionContainer: SessionContainer =\n new SessionContainer((d: ISessionDescription) => this.makeSessionMsgFactory(d))\n\n /**\n * Override to supply this application's own session message factory - the place to\n * put a Logon carrying tags the standard message does not, or a header a\n * counterparty stamps differently. Return null (the default) for the stock\n * factory.\n *\n * For a Logon that only needs extra fields, prefer the \"Logon\" block in the session\n * description - it needs no code at all. Reach for a factory when the values are\n * computed at run time (a signature, a nonce, a token fetched at start up).\n */\n protected makeSessionMsgFactory (_description: ISessionDescription): ISessionMsgFactory | null {\n return null\n }\n\n private async empty (): Promise<any> {\n return await new Promise((resolve, reject) => {\n try {\n setImmediate(() => {\n this.logger.info('resolving an empty promise')\n resolve(null)\n })\n } catch (e) {\n reject(e)\n }\n })\n }\n\n private acceptorEntity: FixEntity | null = null\n private initiatorEntity: FixEntity | null = null\n private stopRequested: boolean = false\n\n protected async getAcceptor (sessionContainer: DependencyContainer): Promise<any> {\n if (sessionContainer.isRegistered<FixEntity>(DITokens.FixEntity)) {\n const entity = sessionContainer.resolve<FixEntity>(DITokens.FixEntity)\n this.acceptorEntity = entity\n // a stop can arrive while the container is still being built - the listener has\n // no existence yet to close, so honour the request by never opening it\n if (this.stopRequested) {\n this.logger.info('stop requested before the acceptor started - not listening')\n return this.empty()\n }\n return entity.start()\n } else {\n return this.empty()\n }\n }\n\n protected async getInitiator (sessionContainer: DependencyContainer): Promise<any> {\n if (sessionContainer.isRegistered<FixEntity>(DITokens.FixEntity)) {\n const entity = sessionContainer.resolve<FixEntity>(DITokens.FixEntity)\n this.initiatorEntity = entity\n if (this.stopRequested) {\n this.logger.info('stop requested before the initiator started - not connecting')\n return this.empty()\n }\n return entity.start()\n } else {\n return this.empty()\n }\n }\n\n /**\n * provide a factory which will be invoked with a config where an instance of the application\n * should be constructed and returned.\n * @param config to be provided to the constucted application representing this session\n * @protected\n */\n protected makeFactory (config: IJsFixConfig): EngineFactory | null {\n return null\n }\n\n /**\n * Stop what this launcher started - close the acceptor's listener, and give up a\n * resilient initiator's attempts to get its transport back.\n *\n * An acceptor is meant to outlive any one counterparty, so nothing closes its\n * listener on its own. That is right for a venue and wrong for an application\n * which knows it is finished: the listening socket alone keeps node alive, long\n * after every session has logged out and every transport has been harvested.\n *\n * Until now the only caller was the both-roles branch of setup() below, which an\n * application cannot reach once it gives the acceptor a launcher of its own - the\n * usual arrangement as soon as more than one client is involved. There was then\n * no way to shut a listener down short of killing the process.\n *\n * A resilient initiator had the same problem from the other side: losing the\n * transport schedules another attempt, so it too kept the process alive with no way\n * to call it off. See issue #72.\n *\n * Safe before start (the request is remembered and neither is opened), and safe to\n * call twice. run() resolves once the listener has closed and the initiator has\n * given up.\n */\n public stop (): void {\n this.stopRequested = true\n this.stopAcceptor()\n this.stopInitiator()\n }\n\n public async run (): Promise<boolean> {\n return await new Promise<any>((resolve, reject) => {\n const logger = this.logger\n logger.info('launching ..')\n this.setup().then(() => {\n logger.info('.. done')\n resolve(true)\n }).catch((e: Error) => {\n logger.error(e)\n reject(e)\n })\n })\n }\n\n public exec (): void {\n this.run().then(() => {\n console.log('finished.')\n }).catch(e => {\n console.error(e)\n })\n }\n\n /**\n * is this session config representing an ascii based session\n * @param description config to be tested.\n */\n public isAscii (description: ISessionDescription): boolean {\n return this.sessionContainer.isAscii(description)\n }\n\n /**\n * is this session config representing an initiator based session\n * @param description config to be tested.\n */\n public isInitiator (description: ISessionDescription): boolean {\n return this.sessionContainer.isInitiator(description)\n }\n\n protected registerApplication (_: DependencyContainer): void {\n this.logger.info('bypass register via DI')\n }\n\n private async makeSystem (description: ISessionDescription): Promise<DependencyContainer> {\n const name = description.application?.name ?? 'na'\n const protocol = description.application?.protocol ?? 'ascii'\n this.logger.info(`creating app ${name} [protocol ${protocol}]`)\n return await this.sessionContainer.makeSystem(description)\n }\n\n private register (container: DependencyContainer): void {\n const config = container.resolve<IJsFixConfig>(DITokens.IJsFixConfig)\n const factory = this.makeFactory(config)\n if (!factory) {\n this.registerApplication(container)\n } else {\n if (factory.makeSession) {\n // resolve the config from the container doing the resolving, not the one\n // captured here. An acceptor resolves each session from a per-connection\n // child scope which re-registers IJsFixConfig, so this is how an application\n // receives that session's own description, store and message factory.\n container.register<FixSession>(DITokens.FixSession, {\n useFactory: (c) => factory.makeSession(c.resolve<IJsFixConfig>(DITokens.IJsFixConfig))\n })\n }\n }\n }\n\n private async makeClient (): Promise<any> {\n if (!this.initiatorConfig) return\n const sessionContainer = await this.makeSystem(this.initiatorConfig)\n this.register(sessionContainer)\n this.logger.info('create initiator')\n return await this.getInitiator(sessionContainer)\n }\n\n private async makeServer (): Promise<any> {\n if (!this.acceptorConfig) return\n const sessionContainer = await this.makeSystem(this.acceptorConfig)\n this.register(sessionContainer)\n this.logger.info('create acceptor')\n return await this.getAcceptor(sessionContainer)\n }\n\n async serverOrEmpty (): Promise<any> {\n return this.acceptorConfig ? this.makeServer() : this.empty()\n }\n\n async clientOrEmpty (): Promise<any> {\n return this.initiatorConfig ? this.makeClient() : this.empty()\n }\n\n private async setup (): Promise<any> {\n this.sessionContainer.registerGlobal(this.loggerFactory)\n const server = this.serverOrEmpty()\n const client = this.clientOrEmpty()\n this.logger.info('launching ....')\n if (this.acceptorConfig && this.initiatorConfig) {\n // Both mode: client drives the lifecycle. When client finishes,\n // stop the acceptor so the process can exit cleanly.\n await client\n this.logger.info('client finished, stopping acceptor')\n this.stop()\n return true\n }\n return await Promise.all([server, client])\n }\n\n private stopAcceptor (): void {\n const entity = this.acceptorEntity as any\n if (entity && typeof entity.stop === 'function') {\n entity.stop()\n }\n }\n\n // only a resilient initiator has anything to call off - a plain one ends with its\n // session, so it has no stop to find here\n private stopInitiator (): void {\n const entity = this.initiatorEntity as any\n if (entity && typeof entity.stop === 'function') {\n entity.stop()\n }\n }\n\n private loadConfig (config: string | ISessionDescription): ISessionDescription {\n if (typeof config === 'string') {\n return require(path.join(this.root, config))\n }\n return config\n }\n}\n"]}
|
|
@@ -27,7 +27,7 @@ let HttpClient = class HttpClient extends fixml_1.FixmlSession {
|
|
|
27
27
|
this.factory = new oms_factory_1.OmsFactory('TradersRUs');
|
|
28
28
|
this.logReceivedMsgs = true;
|
|
29
29
|
this.fixLog = config.logFactory.plain(`jsfix.${(_b = (_a = config === null || config === void 0 ? void 0 : config.description) === null || _a === void 0 ? void 0 : _a.application) === null || _b === void 0 ? void 0 : _b.name}.txt`);
|
|
30
|
-
this.logger = config.logFactory.logger(`${this.me}
|
|
30
|
+
this.logger = config.logFactory.logger(`${this.me}`, { component: 'HttpClient', app: this.me });
|
|
31
31
|
}
|
|
32
32
|
onApplicationMsg(msgType, view) {
|
|
33
33
|
var _a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-client.js","sourceRoot":"","sources":["../../../../src/sample/http/oms/http-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oDAAuD;AAGvD,+CAA0C;AAC1C,0DAAkE;AAClE,uCAA6C;AAC7C,8CAA2C;AAGpC,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,oBAAY;IAI1C,YAA4C,MAAoC,EACrD,gBAAwC,EAAE;;QACnE,KAAK,CAAC,MAAM,CAAC,CAAA;QAF6C,WAAM,GAAN,MAAM,CAAc;QACrC,kBAAa,GAAb,aAAa,CAAa;QAFpD,YAAO,GAAe,IAAI,wBAAU,CAAC,YAAY,CAAC,CAAA;QAIjE,IAAI,CAAC,eAAe,GAAG,IAAI,CAAA;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,SAAS,MAAA,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,WAAW,0CAAE,WAAW,0CAAE,IAAI,MAAM,CAAC,CAAA;QAC5F,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"http-client.js","sourceRoot":"","sources":["../../../../src/sample/http/oms/http-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,oDAAuD;AAGvD,+CAA0C;AAC1C,0DAAkE;AAClE,u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AAC;QACH,CAAC;IACH,CAAC;IAGS,SAAS,CAAE,CAAS,EAAE,GAAW;QACzC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACvB,CAAC;IAES,SAAS,CAAE,CAAS,EAAE,GAAW;QACzC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACvB,CAAC;IAES,OAAO,CAAE,IAAa,EAAE,IAAY,EAAE,QAAgB;QAC9D,OAAO,IAAI,CAAA;IACb,CAAC;IAES,OAAO,CAAE,CAAU;QAC3B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;QAC3B,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,CAAA;QACxC,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,EAAE,iBAAI,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,CAAA;QACpE,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,GAAG,CAAC,CAAA;QAChC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,qBAAqB,aAAa,EAAE,CAAC,CAAA;QACtD,UAAU,CAAC,GAAG,EAAE;YACd,IAAI,CAAC,IAAI,EAAE,CAAA;QACb,CAAC,EAAE,EAAE,GAAG,IAAI,CAAC,CAAA;IACf,CAAC;IAES,SAAS;QACjB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IAC7B,CAAC;CACF,CAAA;AAxDY,gCAAU;qBAAV,UAAU;IADtB,IAAA,qBAAU,GAAE;IAKG,WAAA,IAAA,iBAAM,EAAC,kBAAQ,CAAC,YAAY,CAAC,CAAA;IACxC,WAAA,IAAA,iBAAM,EAAC,eAAe,CAAC,CAAA;;GALf,UAAU,CAwDtB","sourcesContent":["import { FixmlSession } from '../../../transport/fixml'\nimport { MsgView } from '../../../buffer'\nimport { IJsFixLogger, IJsFixConfig } from '../../../config'\nimport { OmsFactory } from './oms-factory'\nimport { IExecutionReport, Side } from '../../../types/FIXML50SP2'\nimport { inject, injectable } from 'tsyringe'\nimport { DITokens } from '../../../runtime'\n\n@injectable()\nexport class HttpClient extends FixmlSession {\n private readonly logger: IJsFixLogger\n private readonly fixLog: IJsFixLogger\n private readonly factory: OmsFactory = new OmsFactory('TradersRUs')\n constructor (@inject(DITokens.IJsFixConfig) public readonly config: IJsFixConfig,\n @inject('logoutSeconds') public readonly logoutSeconds: number = 45) {\n super(config)\n this.logReceivedMsgs = true\n this.fixLog = config.logFactory.plain(`jsfix.${config?.description?.application?.name}.txt`)\n this.logger = config.logFactory.logger(`${this.me}`, { component: 'HttpClient', app: this.me })\n }\n\n protected onApplicationMsg (msgType: string, view: MsgView): void {\n // dispatch messages\n this.logger.info(view.toJson())\n switch (msgType) {\n case 'BizMsgRej': {\n this.logger.warning('received rejection')\n break\n }\n\n case 'ExecRpt': {\n const fill: (IExecutionReport | null) = view.toObject() as IExecutionReport\n this.logger.info(`received execution report ${fill?.OrderQtyData?.OrderQty}@${fill.Price}`)\n break\n }\n }\n }\n\n // use msgType for example to persist only trade capture messages to database\n protected onDecoded (_: string, txt: string): void {\n this.fixLog.info(txt)\n }\n\n protected onEncoded (_: string, txt: string): void {\n this.fixLog.info(txt)\n }\n\n protected onLogon (view: MsgView, user: string, password: string): boolean {\n return true\n }\n\n protected onReady (_: MsgView): void {\n this.logger.info('onReady')\n const logoutSeconds = this.logoutSeconds\n const req = this.factory.createOrder('IBM', Side.Buy, 10000, 100.12)\n this.send('NewOrderSingle', req)\n this.logger.info(`will logout after ${logoutSeconds}`)\n setTimeout(() => {\n this.done()\n }, 11 * 1000)\n }\n\n protected onStopped (): void {\n this.logger.info('stopped')\n }\n}\n"]}
|
|
@@ -25,7 +25,7 @@ let HttpServer = class HttpServer extends fixml_1.FixmlSession {
|
|
|
25
25
|
this.factory = new oms_factory_1.OmsFactory('server');
|
|
26
26
|
this.logReceivedMsgs = true;
|
|
27
27
|
this.fixLog = config.logFactory.plain(`jsfix.${(_b = (_a = config === null || config === void 0 ? void 0 : config.description) === null || _a === void 0 ? void 0 : _a.application) === null || _b === void 0 ? void 0 : _b.name}.txt`);
|
|
28
|
-
this.logger = config.logFactory.logger(`${this.me}
|
|
28
|
+
this.logger = config.logFactory.logger(`${this.me}`, { component: 'HttpServer', app: this.me });
|
|
29
29
|
}
|
|
30
30
|
onApplicationMsg(msgType, view) {
|
|
31
31
|
this.logger.info(view.toJson());
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http-server.js","sourceRoot":"","sources":["../../../../src/sample/http/oms/http-server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,oDAAuD;AAGvD,+CAA0C;AAC1C,uCAA6C;AAC7C,8CAA2C;AAGpC,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,oBAAY;IAK1C,YAA4C,MAAoC;;QAC9E,KAAK,CAAC,MAAM,CAAC,CAAA;QAD6C,WAAM,GAAN,MAAM,CAAc;QAF/D,YAAO,GAAe,IAAI,wBAAU,CAAC,QAAQ,CAAC,CAAA;QAI7D,IAAI,CAAC,eAAe,GAAG,IAAI,CAAA;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,SAAS,MAAA,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,WAAW,0CAAE,WAAW,0CAAE,IAAI,MAAM,CAAC,CAAA;QAC5F,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,EAAE,EAAE,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"http-server.js","sourceRoot":"","sources":["../../../../src/sample/http/oms/http-server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,oDAAuD;AAGvD,+CAA0C;AAC1C,uCAA6C;AAC7C,8CAA2C;AAGpC,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,oBAAY;IAK1C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,GAAW;QACzC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACvB,CAAC;IAES,SAAS,CAAE,CAAS,EAAE,GAAW;QACzC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACvB,CAAC;IAES,OAAO,CAAE,IAAa,EAAE,IAAY,EAAE,QAAgB;QAC9D,OAAO,IAAI,CAAA;IACb,CAAC;IAES,OAAO,CAAE,IAAa;QAC9B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IAC7B,CAAC;IAES,SAAS;QACjB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IAC7B,CAAC;CACF,CAAA;AAnDY,gCAAU;qBAAV,UAAU;IADtB,IAAA,qBAAU,GAAE;IAMG,WAAA,IAAA,iBAAM,EAAC,kBAAQ,CAAC,YAAY,CAAC,CAAA;;GALhC,UAAU,CAmDtB","sourcesContent":["import { MsgView } from '../../../buffer'\nimport { FixmlSession } from '../../../transport/fixml'\nimport { IJsFixLogger, IJsFixConfig } from '../../../config'\nimport { INewOrderSingle, IExecutionReport } from '../../../types/FIXML50SP2'\nimport { OmsFactory } from './oms-factory'\nimport { inject, injectable } from 'tsyringe'\nimport { DITokens } from '../../../runtime'\n\n@injectable()\nexport class HttpServer extends FixmlSession {\n private readonly logger: IJsFixLogger\n private readonly fixLog: IJsFixLogger\n private readonly factory: OmsFactory = new OmsFactory('server')\n\n constructor (@inject(DITokens.IJsFixConfig) public readonly config: IJsFixConfig) {\n super(config)\n this.logReceivedMsgs = true\n this.fixLog = config.logFactory.plain(`jsfix.${config?.description?.application?.name}.txt`)\n this.logger = config.logFactory.logger(`${this.me}`, { component: 'HttpServer', app: this.me })\n }\n\n protected onApplicationMsg (msgType: string, view: MsgView): void {\n // dispatch messages\n this.logger.info(view.toJson())\n switch (msgType) {\n case 'Order': {\n const order: INewOrderSingle = view.toObject() as INewOrderSingle\n this.logger.info(`received order id ${order.ClOrdID}`)\n const fill: IExecutionReport = this.factory.fillOrder(order)\n this.send('ExecutionReport', fill)\n break\n }\n\n default: {\n this.logger.warning(`received unknown msgType ${msgType}`)\n break\n }\n }\n }\n\n // use msgType for example to persist only trade capture messages to database\n protected onDecoded (_: string, txt: string): void {\n this.fixLog.info(txt)\n }\n\n protected onEncoded (_: string, txt: string): void {\n this.fixLog.info(txt)\n }\n\n protected onLogon (view: MsgView, user: string, password: string): boolean {\n return true\n }\n\n protected onReady (view: MsgView): void {\n this.logger.info('onReady')\n }\n\n protected onStopped (): void {\n this.logger.info('stopped')\n }\n}\n"]}
|
|
@@ -25,7 +25,7 @@ let MDClient = class MDClient extends transport_1.AsciiSession {
|
|
|
25
25
|
this.config = config;
|
|
26
26
|
this.logReceivedMsgs = true;
|
|
27
27
|
this.fixLog = config.logFactory.plain(`jsfix.${(_b = (_a = config === null || config === void 0 ? void 0 : config.description) === null || _a === void 0 ? void 0 : _a.application) === null || _b === void 0 ? void 0 : _b.name}.txt`);
|
|
28
|
-
this.logger = config.logFactory.logger(`${this.me}:MDClient
|
|
28
|
+
this.logger = config.logFactory.logger(`${this.me}:MDClient`, { component: 'MDClient', app: this.me });
|
|
29
29
|
}
|
|
30
30
|
onApplicationMsg(_, view) {
|
|
31
31
|
this.logger.info(`${view.toJson()}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"md-client.js","sourceRoot":"","sources":["../../../../src/sample/tcp/qf-md/md-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,kDAAiD;AACjD,0CAAwC;AAGxC,6CAAwC;AACxC,uCAA6C;AAC7C,8CAA2C;AAGpC,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,wBAAY;IAIxC,YAA4D,MAAoB;;QAC9E,KAAK,CAAC,MAAM,CAAC,CAAA;QAD6C,WAAM,GAAN,MAAM,CAAc;QAE9E,IAAI,CAAC,eAAe,GAAG,IAAI,CAAA;QAC3B,IAAI,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AES,SAAS,CAAE,CAAS,EAAE,GAAW;QACzC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACvB,CAAC;IAES,SAAS,CAAE,CAAS,EAAE,GAAW;QACzC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACvB,CAAC;IAES,OAAO,CAAE,IAAa;QAC9B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;QACzB,MAAM,aAAa,GAAG,EAAE,CAAA;QACxB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,qBAAqB,aAAa,EAAE,CAAC,CAAA;QACtD,MAAM,GAAG,GAAG,sBAAS,CAAC,eAAe,CAAC,SAAS,CAAC,CAAA;QAChD,IAAI,CAAC,IAAI,CAAC,eAAO,CAAC,iBAAiB,EAAE,GAAG,CAAC,CAAA;QACzC,UAAU,CAAC,GAAG,EAAE;YACd,IAAI,CAAC,IAAI,EAAE,CAAA;QACb,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC,CAAA;IAC1B,CAAC;IAES,OAAO,CAAE,IAAa,EAAE,IAAY,EAAE,QAAgB;QAC9D,OAAO,IAAI,CAAA;IACb,CAAC;CACF,CAAA;AAzCY,4BAAQ;mBAAR,QAAQ;IADpB,IAAA,qBAAU,GAAE;IAKG,WAAA,IAAA,iBAAM,EAAC,kBAAQ,CAAC,YAAY,CAAC,CAAA;;GAJhC,QAAQ,CAyCpB","sourcesContent":["import { MsgView } from '../../../buffer'\nimport { AsciiSession } from '../../../transport'\nimport { MsgType } from '../../../types'\nimport { IJsFixLogger, IJsFixConfig } from '../../../config'\n\nimport { MDFactory } from './md-factory'\nimport { inject, injectable } from 'tsyringe'\nimport { DITokens } from '../../../runtime'\n\n@injectable()\nexport class MDClient extends AsciiSession {\n private readonly logger: IJsFixLogger\n private readonly fixLog: IJsFixLogger\n\n constructor (@inject(DITokens.IJsFixConfig) public readonly config: IJsFixConfig) {\n super(config)\n this.logReceivedMsgs = true\n this.fixLog = config.logFactory.plain(`jsfix.${config?.description?.application?.name}.txt`)\n this.logger = config.logFactory.logger(`${this.me}:MDClient`, { component: 'MDClient', app: this.me })\n }\n\n protected onApplicationMsg (_: string, view: MsgView): void {\n this.logger.info(`${view.toJson()}`)\n }\n\n protected onStopped (): void {\n this.logger.info('stopped')\n }\n\n protected onDecoded (_: string, txt: string): void {\n this.fixLog.info(txt)\n }\n\n protected onEncoded (_: string, txt: string): void {\n this.fixLog.info(txt)\n }\n\n protected onReady (view: MsgView): void {\n this.logger.info('ready')\n const logoutSeconds = 32\n this.logger.info(`will logout after ${logoutSeconds}`)\n const mdr = MDFactory.BidOfferRequest('EUR/USD')\n this.send(MsgType.MarketDataRequest, mdr)\n setTimeout(() => {\n this.done()\n }, logoutSeconds * 1000)\n }\n\n protected onLogon (view: MsgView, user: string, password: string): boolean {\n return true\n }\n}\n"]}
|
|
@@ -23,7 +23,7 @@ let MDServer = class MDServer extends transport_1.AsciiSession {
|
|
|
23
23
|
this.config = config;
|
|
24
24
|
this.timerHandle = null;
|
|
25
25
|
this.logReceivedMsgs = true;
|
|
26
|
-
this.logger = config.logFactory.logger(`${this.me}:MDServer
|
|
26
|
+
this.logger = config.logFactory.logger(`${this.me}:MDServer`, { component: 'MDServer', app: this.me });
|
|
27
27
|
this.fixLog = config.logFactory.plain(`jsfix.${(_b = (_a = config === null || config === void 0 ? void 0 : config.description) === null || _a === void 0 ? void 0 : _a.application) === null || _b === void 0 ? void 0 : _b.name}.txt`);
|
|
28
28
|
}
|
|
29
29
|
onApplicationMsg(msgType, view) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"md-server.js","sourceRoot":"","sources":["../../../../src/sample/tcp/qf-md/md-server.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,kDAAiD;AACjD,0CAAwC;AAGxC,uCAA6C;AAKtC,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,wBAAY;IAKxC,YAAqC,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AuB,IAAI,CAAC,QAAQ,EAAwB,CAAA;gBACrE,MAAK;YACP,CAAC;QACH,CAAC;IACH,CAAC;IAES,OAAO,CAAE,IAAa;QAE9B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAA;IACzC,CAAC;IAES,SAAS;QACjB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;QAC3B,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YACrB,aAAa,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;QACjC,CAAC;IACH,CAAC;IAES,OAAO,CAAE,IAAa,EAAE,IAAY,EAAE,QAAgB;QAC9D,OAAO,IAAI,CAAA;IACb,CAAC;IAES,SAAS,CAAE,OAAe,EAAE,GAAW;QAC/C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACvB,CAAC;IAES,SAAS,CAAE,OAAe,EAAE,GAAW;QAC/C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACvB,CAAC;CACF,CAAA;AA7CY,4BAAQ;mBAAR,QAAQ;IADpB,IAAA,qBAAU,GAAE;IAMG,WAAA,IAAA,iBAAM,EAAC,cAAc,CAAC,CAAA;;GALzB,QAAQ,CA6CpB","sourcesContent":["import { MsgView } from '../../../buffer'\nimport { AsciiSession } from '../../../transport'\nimport { MsgType } from '../../../types'\nimport { IJsFixLogger, IJsFixConfig } from '../../../config'\nimport { IMarketDataRequest } from '../../../types/FIX4.4/quickfix'\nimport { inject, injectable } from 'tsyringe'\n\n// interfaces generated by compiler to make messages easy in an IDE\n\n@injectable()\nexport class MDServer extends AsciiSession {\n private readonly logger: IJsFixLogger\n private readonly fixLog: IJsFixLogger\n private readonly timerHandle: NodeJS.Timeout | null = null\n\n constructor (@inject('IJsFixConfig') public readonly config: IJsFixConfig) {\n super(config)\n this.logReceivedMsgs = true\n this.logger = config.logFactory.logger(`${this.me}:MDServer`, { component: 'MDServer', app: this.me })\n this.fixLog = config.logFactory.plain(`jsfix.${config?.description?.application?.name}.txt`)\n }\n\n protected onApplicationMsg (msgType: string, view: MsgView): void {\n this.logger.info(`${view.toJson()}`)\n switch (msgType) {\n case MsgType.MarketDataRequest: {\n const req: IMarketDataRequest = view.toObject() as IMarketDataRequest\n break\n }\n }\n }\n\n protected onReady (view: MsgView): void {\n // server waits for client to make a request\n this.logger.info('ready for requests.')\n }\n\n protected onStopped (): void {\n this.logger.info('stopped')\n if (this.timerHandle) {\n clearInterval(this.timerHandle)\n }\n }\n\n protected onLogon (view: MsgView, user: string, password: string): boolean {\n return true\n }\n\n protected onDecoded (msgType: string, txt: string): void {\n this.fixLog.info(txt)\n }\n\n protected onEncoded (msgType: string, txt: string): void {\n this.fixLog.info(txt)\n }\n}\n"]}
|
|
@@ -30,7 +30,7 @@ let RespawnAcceptor = class RespawnAcceptor extends transport_1.FixEntity {
|
|
|
30
30
|
super(config);
|
|
31
31
|
this.config = config;
|
|
32
32
|
this.sessions = new Map();
|
|
33
|
-
this.logger = config.logFactory.logger('RespawnAcceptor');
|
|
33
|
+
this.logger = config.logFactory.logger('RespawnAcceptor', { component: 'RespawnAcceptor', role: 'acceptor' });
|
|
34
34
|
}
|
|
35
35
|
start() {
|
|
36
36
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"respawn-acceptor.js","sourceRoot":"","sources":["../../../../src/sample/tcp/recovering-skeleton/respawn-acceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AACA,gDAA4D;AAC5D,uCAA6C;AAC7C,kDAA0D;AAMnD,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,qBAAS;IAI5C,YAAqC,MAAoC;QACvE,KAAK,CAAC,MAAM,CAAC,CAAA;QADsC,WAAM,GAAN,MAAM,CAAc;QAFxD,aAAQ,GAA4B,IAAI,GAAG,EAAsB,CAAA;QAIhF,IAAI,CAAC,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,CAAC,6CAA6C,SAAS,EAAE,CAAC,CAAA;wBAC1E,MAAM,QAAQ,CAAC,KAAK,EAAE,CAAA;wBACtB,MAAK;oBACP,CAAC;oBAAC,OAAO,CAAC,EAAE,CAAC;wBACX,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,0CAA0C,SAAS,EAAE,CAAC,CAAA;oBACzE,CAAC;oBACD,EAAE,SAAS,CAAA;gBACb,CAAC;gBACD,IAAI,SAAS,GAAG,CAAC,EAAE,CAAC;oBAClB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,+BAA+B,SAAS,EAAE,CAAC,CAAA;oBAC5D,MAAM,CAAC,SAAS,CAAC,CAAA;gBACnB,CAAC;qBAAM,CAAC;oBACN,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,aAAa,SAAS,EAAE,CAAC,CAAA;oBAC1C,OAAO,CAAC,SAAS,CAAC,CAAA;gBACpB,CAAC;YACH,CAAC,CAAA,CAAC,CAAA;QACJ,CAAC;KAAA;CACF,CAAA;AApGY,0CAAe;0BAAf,eAAe;IAD3B,IAAA,qBAAU,GAAE;IAKG,WAAA,IAAA,iBAAM,EAAC,cAAc,CAAC,CAAA;;GAJzB,eAAe,CAoG3B","sourcesContent":["import { IJsFixConfig, IJsFixLogger } from '../../../config'\nimport { TcpAcceptorListener } from '../../../transport/tcp'\nimport { inject, injectable } from 'tsyringe'\nimport { FixEntity, FixSession } from '../../../transport'\nimport { MsgView } from '../../../buffer'\nimport { MsgTransport } from '../../../transport/factory'\nimport { ILooseObject } from '../../../collections/collection'\n\n@injectable()\nexport class RespawnAcceptor extends FixEntity {\n private readonly logger: IJsFixLogger\n private readonly sessions: Map<string, FixSession> = new Map<string, FixSession>()\n\n constructor (@inject('IJsFixConfig') public readonly config: IJsFixConfig) {\n super(config)\n this.logger = config.logFactory.logger('RespawnAcceptor',\n { component: 'RespawnAcceptor', role: 'acceptor' })\n }\n\n // if acceptor errors e.g. via a forced connection drop, then respawn\n // a set number of times.\n\n public async start (): Promise<any> {\n return await this.waitFor()\n }\n\n protected rxOnMsg (session: FixSession, msgType: string, view: MsgView): void {\n this.logger.info(`rxOnMsg msgType = ${msgType}`)\n const o: ILooseObject = view.toObject() as ILooseObject\n const key: string = o.StandardHeader.SenderCompID\n if (!this.sessions.has(key)) {\n this.logger.info(`onSession: new session acceptor SenderCompID = ${key} created, count = ${this.sessions.size}}`)\n this.sessions.set(key, session)\n }\n }\n\n private resetSessionSeqNo (session: FixSession): void {\n const key = this.config.description.TargetCompID\n if (this.sessions.has(key)) {\n const lastSession = this.sessions.get(key)\n const lastPeerSeqNum = lastSession?.lastPeerSeqNum() ?? 0\n this.logger.info(`resetSessionSeqNo: set lastPeerSeqNum ${lastPeerSeqNum} for key ${key}`)\n session.reset(lastPeerSeqNum)\n this.sessions.delete(key)\n }\n }\n\n private resetLastSentSeqNo (): void {\n if (!this.resetSeqNo()) {\n const key = this.config.description.TargetCompID\n if (this.sessions.has(key)) {\n const lastSession = this.sessions.get(key)\n const lastSentSeqNum = lastSession?.lastSentSeqNum() ?? 0\n this.logger.info(`resetLastSentSeqNo: set seqNo ${lastSentSeqNum} for key ${key}`)\n this.config.description.LastSentSeqNum = lastSentSeqNum\n }\n }\n }\n\n private onSession (session: FixSession, transport: MsgTransport): void {\n this.resetSessionSeqNo(session)\n const rx = transport.receiver\n rx?.on('msg', (msgType: string, view: MsgView) => { this.rxOnMsg(session, msgType, view) })\n }\n\n private subscribe (listener: TcpAcceptorListener): void {\n listener.on('session', (s, transport) => { this.onSession(s, transport) })\n }\n\n /*\n private unsubscribe (listener: TcpAcceptorListener): void {\n listener.removeListener('session', this.onSession)\n }\n */\n\n private resetSeqNo (): boolean {\n return this.config.description.ResetSeqNumFlag\n }\n\n public async waitFor (respawns: number = 1): Promise<any> {\n return await new Promise<any>(async (resolve, reject) => {\n let respawned = 0\n while (respawned <= respawns) {\n try {\n const sessionContainer = this.config.sessionContainer\n // if previously running a session then retrieve its last state\n // as need to adjust seqNo if not resetting.\n this.resetLastSentSeqNo()\n const listener = sessionContainer.resolve<TcpAcceptorListener>(TcpAcceptorListener)\n this.subscribe(listener)\n const dropConnectionTimeout = respawned === 0 ? 5 : -1\n sessionContainer.register('dropConnectionTimeout', { useValue: dropConnectionTimeout })\n this.logger.info(`waitFor: waiting for acceptor respawned = ${respawned}`)\n await listener.start()\n break\n } catch (e) {\n this.logger.info(`waitFor: error in acceptor respawned = ${respawned}`)\n }\n ++respawned\n }\n if (respawned > 0) {\n this.logger.info(`acceptor respawned reject = ${respawned}`)\n reject(respawned)\n } else {\n this.logger.info(`resolve = ${respawned}`)\n resolve(respawned)\n }\n })\n }\n}\n"]}
|
|
@@ -23,7 +23,7 @@ let SkeletonClient = class SkeletonClient extends transport_1.AsciiSession {
|
|
|
23
23
|
this.logoutSeconds = logoutSeconds;
|
|
24
24
|
this.logReceivedMsgs = true;
|
|
25
25
|
this.fixLog = config.logFactory.plain(`jsfix.${(_b = (_a = config === null || config === void 0 ? void 0 : config.description) === null || _a === void 0 ? void 0 : _a.application) === null || _b === void 0 ? void 0 : _b.name}.txt`);
|
|
26
|
-
this.logger = config.logFactory.logger(`${this.me}
|
|
26
|
+
this.logger = config.logFactory.logger(`${this.me}`, { component: 'SkeletonClient', app: this.me });
|
|
27
27
|
}
|
|
28
28
|
onApplicationMsg(msgType, view) {
|
|
29
29
|
switch (msgType) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skeleton-client.js","sourceRoot":"","sources":["../../../../src/sample/tcp/recovering-skeleton/skeleton-client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,kDAAiD;AAEjD,uCAA6C;AAGtC,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,wBAAY;IAI9C,YAAqD,MAAoB,EAC9B,aAAqB;;QAC9D,KAAK,CAAC,MAAM,CAAC,CAAA;QAFsC,WAAM,GAAN,MAAM,CAAc;QAC9B,kBAAa,GAAb,aAAa,CAAQ;QAE9D,IAAI,CAAC,eAA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BACpD,MAAK;YACP,CAAC;QACH,CAAC;IACH,CAAC;IAES,SAAS,CAAE,CAAS,EAAE,GAAW;QACzC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACvB,CAAC;IAES,SAAS,CAAE,CAAS,EAAE,GAAW;QACzC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IACvB,CAAC;IAES,OAAO,CAAE,IAAa,EAAE,IAAY,EAAE,QAAgB;QAC9D,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,qBAAqB,IAAI,EAAE,CAAC,CAAA;QAC7C,OAAO,IAAI,CAAA;IACb,CAAC;IAES,OAAO,CAAE,IAAa;QAC9B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;QAC3B,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,CAAA;QACxC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,qBAAqB,aAAa,EAAE,CAAC,CAAA;QACtD,UAAU,CAAC,GAAG,EAAE;YACd,IAAI,CAAC,IAAI,EAAE,CAAA;QACb,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC,CAAA;IAC1B,CAAC;IAES,SAAS;QACjB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IAC7B,CAAC;CACF,CAAA;AA/CY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,qBAAU,GAAE;IAKG,WAAA,IAAA,iBAAM,EAAC,cAAc,CAAC,CAAA;IACjC,WAAA,IAAA,iBAAM,EAAC,eAAe,CAAC,CAAA;;GALf,cAAc,CA+C1B","sourcesContent":["import { MsgView } from '../../../buffer'\nimport { AsciiSession } from '../../../transport'\nimport { IJsFixLogger, IJsFixConfig } from '../../../config'\nimport { inject, injectable } from 'tsyringe'\n\n@injectable()\nexport class SkeletonClient extends AsciiSession {\n private readonly logger: IJsFixLogger\n private readonly fixLog: IJsFixLogger\n\n constructor (@inject('IJsFixConfig') public readonly config: IJsFixConfig,\n @inject('logoutSeconds') public readonly logoutSeconds: number) {\n super(config)\n this.logReceivedMsgs = true\n this.fixLog = config.logFactory.plain(`jsfix.${config?.description?.application?.name}.txt`)\n this.logger = config.logFactory.logger(`${this.me}`, { component: 'SkeletonClient', app: this.me })\n }\n\n protected onApplicationMsg (msgType: string, view: MsgView): void {\n // dispatch messages\n switch (msgType) {\n default: {\n this.logger.info(`received message type ${msgType}`)\n break\n }\n }\n }\n\n protected onDecoded (_: string, txt: string): void {\n this.fixLog.info(txt)\n }\n\n protected onEncoded (_: string, txt: string): void {\n this.fixLog.info(txt)\n }\n\n protected onLogon (view: MsgView, user: string, password: string): boolean {\n this.logger.info(`peer logs in user ${user}`)\n return true\n }\n\n protected onReady (view: MsgView): void {\n this.logger.info('onReady')\n const logoutSeconds = this.logoutSeconds\n this.logger.info(`will logout after ${logoutSeconds}`)\n setTimeout(() => {\n this.done()\n }, logoutSeconds * 1000)\n }\n\n protected onStopped (): void {\n this.logger.info('stopped')\n }\n}\n"]}
|
|
@@ -23,7 +23,7 @@ let SkeletonServer = class SkeletonServer extends transport_1.AsciiSession {
|
|
|
23
23
|
this.dropConnectionTimeout = dropConnectionTimeout;
|
|
24
24
|
this.logReceivedMsgs = true;
|
|
25
25
|
this.fixLog = config.logFactory.plain(`jsfix.${(_b = (_a = config === null || config === void 0 ? void 0 : config.description) === null || _a === void 0 ? void 0 : _a.application) === null || _b === void 0 ? void 0 : _b.name}.txt`);
|
|
26
|
-
this.logger = config.logFactory.logger(`${this.me}
|
|
26
|
+
this.logger = config.logFactory.logger(`${this.me}`, { component: 'SkeletonServer', app: this.me });
|
|
27
27
|
}
|
|
28
28
|
onApplicationMsg(msgType, _) {
|
|
29
29
|
switch (msgType) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"skeleton-server.js","sourceRoot":"","sources":["../../../../src/sample/tcp/recovering-skeleton/skeleton-server.ts"],"names":[],"mappings":";;;;;;;;;;;;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,CAAC;YACN,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gCAAgC,CAAC,CAAA;QACpD,CAAC;IACH,CAAC;IAES,SAAS;QACjB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;IAC7B,CAAC;CACF,CAAA;AAvDY,wCAAc;yBAAd,cAAc;IAD1B,IAAA,qBAAU,GAAE;IAKG,WAAA,IAAA,iBAAM,EAAC,cAAc,CAAC,CAAA;IACjC,WAAA,IAAA,iBAAM,EAAC,uBAAuB,CAAC,CAAA;;GALvB,cAAc,CAuD1B","sourcesContent":["import { MsgView } from '../../../buffer'\nimport { AsciiSession } from '../../../transport'\nimport { IJsFixLogger, IJsFixConfig } from '../../../config'\nimport { inject, injectable } from 'tsyringe'\n\n@injectable()\nexport class SkeletonServer extends AsciiSession {\n private readonly logger: IJsFixLogger\n private readonly fixLog: IJsFixLogger\n\n constructor (@inject('IJsFixConfig') public readonly config: IJsFixConfig,\n @inject('dropConnectionTimeout') public readonly dropConnectionTimeout: number) {\n super(config)\n this.logReceivedMsgs = true\n this.fixLog = config.logFactory.plain(`jsfix.${config?.description?.application?.name}.txt`)\n this.logger = config.logFactory.logger(`${this.me}`, { component: 'SkeletonServer', app: this.me })\n }\n\n protected onApplicationMsg (msgType: string, _: MsgView): void {\n // dispatch messages\n switch (msgType) {\n default: {\n this.logger.info(`received message type ${msgType}`)\n break\n }\n }\n }\n\n // use msgType for example to persist only trade capture messages to database\n protected onDecoded (_: string, txt: string): void {\n this.fixLog.info(txt)\n }\n\n // delimiter substitution now done in encoding\n protected onEncoded (_: string, txt: string): void {\n this.fixLog.info(txt)\n }\n\n protected onLogon (view: MsgView, user: string, password: string): boolean {\n this.logger.info(`peer logs in user ${user}`)\n return true\n }\n\n protected onReady (view: MsgView): void {\n this.logger.info('onReady')\n if (this.dropConnectionTimeout > 0) {\n this.logger.info(`acceptor is ready for requests - drop connection in ${this.dropConnectionTimeout}`)\n setTimeout(() => {\n setImmediate(() => {\n this.logger.info('kill transport')\n this.stop(new Error(`loss of tcp. ${this.me}`))\n })\n }, this.dropConnectionTimeout * 1000)\n } else {\n this.logger.info('acceptor is ready for requests')\n }\n }\n\n protected onStopped (): void {\n this.logger.info('stopped')\n }\n}\n"]}
|
|
@@ -26,7 +26,7 @@ let SkeletonSession = class SkeletonSession extends transport_1.AsciiSession {
|
|
|
26
26
|
this.useInMemoryStore = useInMemoryStore;
|
|
27
27
|
this.logReceivedMsgs = true;
|
|
28
28
|
this.fixLog = config.logFactory.plain(`jsfix.${(_b = (_a = config === null || config === void 0 ? void 0 : config.description) === null || _a === void 0 ? void 0 : _a.application) === null || _b === void 0 ? void 0 : _b.name}.txt`);
|
|
29
|
-
this.logger = config.logFactory.logger(`${this.me}
|
|
29
|
+
this.logger = config.logFactory.logger(`${this.me}`, { component: 'SkeletonSession', app: this.me });
|
|
30
30
|
}
|
|
31
31
|
onApplicationMsg(msgType, view) {
|
|
32
32
|
var _a;
|