@fireproof/core-protocols-cloud 0.0.0-smoke-1b31059-1752074105
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/LICENSE.md +232 -0
- package/http-connection.d.ts +25 -0
- package/http-connection.js +150 -0
- package/http-connection.js.map +1 -0
- package/http-connection.ts +204 -0
- package/index.d.ts +4 -0
- package/index.js +5 -0
- package/index.js.map +1 -0
- package/index.ts +4 -0
- package/msg-raw-connection-base.d.ts +15 -0
- package/msg-raw-connection-base.js +24 -0
- package/msg-raw-connection-base.js.map +1 -0
- package/msg-raw-connection-base.ts +38 -0
- package/msger.d.ts +84 -0
- package/msger.js +365 -0
- package/msger.js.map +1 -0
- package/msger.ts +551 -0
- package/package.json +45 -0
- package/tsconfig.json +18 -0
- package/ws-connection.d.ts +39 -0
- package/ws-connection.js +201 -0
- package/ws-connection.js.map +1 -0
- package/ws-connection.ts +270 -0
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { buildErrorMsg } from "@fireproof/core-types-protocols-cloud";
|
|
2
|
+
export class MsgRawConnectionBase {
|
|
3
|
+
sthis;
|
|
4
|
+
exchangedGestalt;
|
|
5
|
+
constructor(sthis, exGestalt) {
|
|
6
|
+
this.sthis = sthis;
|
|
7
|
+
this.exchangedGestalt = exGestalt;
|
|
8
|
+
}
|
|
9
|
+
onErrorFns = new Map();
|
|
10
|
+
onError(fn) {
|
|
11
|
+
const key = this.sthis.nextId().str;
|
|
12
|
+
this.onErrorFns.set(key, fn);
|
|
13
|
+
return () => this.onErrorFns.delete(key);
|
|
14
|
+
}
|
|
15
|
+
buildErrorMsg(msgCtx, msg, err) {
|
|
16
|
+
const rmsg = Array.from(this.onErrorFns.values()).reduce((msg, fn) => {
|
|
17
|
+
return fn(msg, err);
|
|
18
|
+
}, msg);
|
|
19
|
+
const emsg = buildErrorMsg(msgCtx, rmsg, err);
|
|
20
|
+
msgCtx.logger.Error().Err(err).Any("msg", rmsg).Msg("connection error");
|
|
21
|
+
return emsg;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=msg-raw-connection-base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"msg-raw-connection-base.js","sourceRoot":"","sources":["msg-raw-connection-base.ts"],"names":[],"mappings":"AACA,OAAO,EAAqB,aAAa,EAAE,MAAM,uCAAuC,CAAC;AAIzF,MAAM,OAAO,oBAAoB;IACtB,KAAK,CAAY;IACjB,gBAAgB,CAAmB;IAE5C,YAAY,KAAgB,EAAE,SAA2B;QACvD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC;IACpC,CAAC;IAEQ,UAAU,GAAG,IAAI,GAAG,EAAqB,CAAC;IACnD,OAAO,CAAC,EAAa;QACnB,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC;QACpC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;QAC7B,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC3C,CAAC;IAED,aAAa,CACX,MAGC,EACD,GAAqB,EACrB,GAAU;QAGV,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,EAAE,EAAE,EAAE;YACnE,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;QACtB,CAAC,EAAE,GAAG,CAAC,CAAC;QACR,MAAM,IAAI,GAAG,aAAa,CAAC,MAAM,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;QAC9C,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;QACxE,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { SuperThis } from "@fireproof/core-types-base";
|
|
2
|
+
import { MsgBase, ErrorMsg, buildErrorMsg } from "@fireproof/core-types-protocols-cloud";
|
|
3
|
+
import { ExchangedGestalt, OnErrorFn, UnReg } from "./msger.js";
|
|
4
|
+
import { Logger } from "@adviser/cement";
|
|
5
|
+
|
|
6
|
+
export class MsgRawConnectionBase {
|
|
7
|
+
readonly sthis: SuperThis;
|
|
8
|
+
readonly exchangedGestalt: ExchangedGestalt;
|
|
9
|
+
|
|
10
|
+
constructor(sthis: SuperThis, exGestalt: ExchangedGestalt) {
|
|
11
|
+
this.sthis = sthis;
|
|
12
|
+
this.exchangedGestalt = exGestalt;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
readonly onErrorFns = new Map<string, OnErrorFn>();
|
|
16
|
+
onError(fn: OnErrorFn): UnReg {
|
|
17
|
+
const key = this.sthis.nextId().str;
|
|
18
|
+
this.onErrorFns.set(key, fn);
|
|
19
|
+
return () => this.onErrorFns.delete(key);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
buildErrorMsg(
|
|
23
|
+
msgCtx: {
|
|
24
|
+
readonly logger: Logger;
|
|
25
|
+
readonly sthis: SuperThis;
|
|
26
|
+
},
|
|
27
|
+
msg: Partial<MsgBase>,
|
|
28
|
+
err: Error,
|
|
29
|
+
): ErrorMsg {
|
|
30
|
+
// const logLine = this.sthis.logger.Error().Err(err).Any("msg", msg);
|
|
31
|
+
const rmsg = Array.from(this.onErrorFns.values()).reduce((msg, fn) => {
|
|
32
|
+
return fn(msg, err);
|
|
33
|
+
}, msg);
|
|
34
|
+
const emsg = buildErrorMsg(msgCtx, rmsg, err);
|
|
35
|
+
msgCtx.logger.Error().Err(err).Any("msg", rmsg).Msg("connection error");
|
|
36
|
+
return emsg;
|
|
37
|
+
}
|
|
38
|
+
}
|
package/msger.d.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { CoerceURI, Logger, Result, URI } from "@adviser/cement";
|
|
2
|
+
import { EnDeCoder, Gestalt, MsgBase, MsgerParams, RequestOpts, MsgWithError, QSId, FPJWKCloudAuthType, MsgWithConn, ReqOpenConn, MsgWithOptionalConn, MsgRawConnection } from "@fireproof/core-types-protocols-cloud";
|
|
3
|
+
import { SuperThis } from "@fireproof/core-types-base";
|
|
4
|
+
export declare function selectRandom<T>(arr: T[]): T;
|
|
5
|
+
export declare function timeout<T>(ms: number, promise: Promise<T>): Promise<T>;
|
|
6
|
+
export type OnMsgFn<T extends MsgBase = MsgBase> = (msg: MsgWithError<T>) => void;
|
|
7
|
+
export type UnReg = () => void;
|
|
8
|
+
export interface ExchangedGestalt {
|
|
9
|
+
readonly my: Gestalt;
|
|
10
|
+
readonly remote: Gestalt;
|
|
11
|
+
}
|
|
12
|
+
export type OnErrorFn = (msg: Partial<MsgBase>, err: Error) => Partial<MsgBase>;
|
|
13
|
+
export interface ActiveStream {
|
|
14
|
+
readonly id: string;
|
|
15
|
+
readonly bind: {
|
|
16
|
+
readonly msg: MsgBase;
|
|
17
|
+
readonly opts: RequestOpts;
|
|
18
|
+
};
|
|
19
|
+
timeout?: unknown;
|
|
20
|
+
controller?: ReadableStreamDefaultController<MsgWithError<MsgBase>>;
|
|
21
|
+
}
|
|
22
|
+
export declare function jsonEnDe(sthis: SuperThis): EnDeCoder;
|
|
23
|
+
export type MsgerParamsWithEnDe = MsgerParams & {
|
|
24
|
+
readonly ende: EnDeCoder;
|
|
25
|
+
};
|
|
26
|
+
export declare function defaultMsgParams(sthis: SuperThis, igs: Partial<MsgerParamsWithEnDe>): MsgerParamsWithEnDe;
|
|
27
|
+
export interface OpenParams {
|
|
28
|
+
readonly timeout: number;
|
|
29
|
+
}
|
|
30
|
+
export declare function applyStart(prC: Promise<Result<MsgRawConnection>>): Promise<Result<MsgRawConnection>>;
|
|
31
|
+
export declare function authTypeFromUri(logger: Logger, curi: CoerceURI): Promise<Result<FPJWKCloudAuthType>>;
|
|
32
|
+
export interface MsgerConnectParams {
|
|
33
|
+
readonly msgerParam: Partial<MsgerParamsWithEnDe>;
|
|
34
|
+
readonly conn: Partial<ReqOpenConn>;
|
|
35
|
+
readonly mowh: MsgOpenWSAndHttp;
|
|
36
|
+
}
|
|
37
|
+
export declare class Msger {
|
|
38
|
+
static connect(sthis: SuperThis, curl: CoerceURI, mParam: Partial<MsgerConnectParams>): Promise<Result<VirtualConnected>>;
|
|
39
|
+
private constructor();
|
|
40
|
+
}
|
|
41
|
+
export declare class MsgOpenWSAndHttp {
|
|
42
|
+
openHttp(vc: SuperThis, urls: URI[], msgP: MsgerParamsWithEnDe, exGestalt: ExchangedGestalt): Promise<Result<MsgRawConnection>>;
|
|
43
|
+
openWS(vc: SuperThis, url: URI, msgP: MsgerParamsWithEnDe, exGestalt: ExchangedGestalt): Promise<Result<MsgRawConnection>>;
|
|
44
|
+
}
|
|
45
|
+
interface RetryItem {
|
|
46
|
+
readonly retryCount: number;
|
|
47
|
+
}
|
|
48
|
+
export interface VirtualConnectedOptionals {
|
|
49
|
+
readonly retryCount: number;
|
|
50
|
+
readonly retryDelay: number;
|
|
51
|
+
readonly openWSorHttp: MsgOpenWSAndHttp;
|
|
52
|
+
readonly conn: Partial<ReqOpenConn>;
|
|
53
|
+
}
|
|
54
|
+
export interface VirtualConnectedRequired {
|
|
55
|
+
readonly curl: CoerceURI;
|
|
56
|
+
readonly msgerParams: Partial<MsgerParamsWithEnDe>;
|
|
57
|
+
}
|
|
58
|
+
export type VirtualConnectedOpts = Partial<VirtualConnectedOptionals> & Required<VirtualConnectedRequired>;
|
|
59
|
+
export declare class VirtualConnected {
|
|
60
|
+
readonly sthis: SuperThis;
|
|
61
|
+
readonly opts: VirtualConnectedOptionals & VirtualConnectedRequired;
|
|
62
|
+
readonly mowh: MsgOpenWSAndHttp;
|
|
63
|
+
readonly logger: Logger;
|
|
64
|
+
readonly id: string;
|
|
65
|
+
exchangedGestalt?: ExchangedGestalt;
|
|
66
|
+
realConn?: MsgRawConnection;
|
|
67
|
+
retries: RetryItem[];
|
|
68
|
+
virtualConn?: QSId;
|
|
69
|
+
constructor(sthis: SuperThis, opts: VirtualConnectedOpts);
|
|
70
|
+
get conn(): QSId;
|
|
71
|
+
readonly activeBinds: Map<string, ActiveStream>;
|
|
72
|
+
private handleBindRealConn;
|
|
73
|
+
private ensureOpts;
|
|
74
|
+
bind<S extends MsgWithConn, Q extends MsgWithOptionalConn>(req: Q, iopts: RequestOpts): ReadableStream<MsgWithError<S>>;
|
|
75
|
+
request<S extends MsgWithConn, Q extends MsgWithOptionalConn>(req: Q, iopts: RequestOpts): Promise<MsgWithError<S>>;
|
|
76
|
+
send<S extends MsgWithConn, Q extends MsgWithOptionalConn>(msg: Q): Promise<MsgWithError<S>>;
|
|
77
|
+
close(t: MsgWithOptionalConn): Promise<Result<void>>;
|
|
78
|
+
onMsg(msgFn: OnMsgFn<MsgWithConn>): UnReg;
|
|
79
|
+
private connect;
|
|
80
|
+
private getQSIdWithSideEffect;
|
|
81
|
+
private mutex;
|
|
82
|
+
private getRealConn;
|
|
83
|
+
}
|
|
84
|
+
export {};
|
package/msger.js
ADDED
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
import { BuildURI, Result, runtimeFn, URI } from "@adviser/cement";
|
|
2
|
+
import { buildReqGestalt, defaultGestalt, MsgIsResGestalt, MsgIsError, buildReqOpen, MsgIsResOpen, MsgIsConnected, MsgIsWithConn, } from "@fireproof/core-types-protocols-cloud";
|
|
3
|
+
import { ensurePath, HttpConnection } from "./http-connection.js";
|
|
4
|
+
import { WSConnection } from "./ws-connection.js";
|
|
5
|
+
import { ensureLogger, sleep } from "@fireproof/core-runtime";
|
|
6
|
+
import pLimit from "@fireproof/vendor/p-limit";
|
|
7
|
+
export function selectRandom(arr) {
|
|
8
|
+
return arr[Math.floor(Math.random() * arr.length)];
|
|
9
|
+
}
|
|
10
|
+
export function timeout(ms, promise) {
|
|
11
|
+
return new Promise((resolve, reject) => {
|
|
12
|
+
const timer = setTimeout(() => {
|
|
13
|
+
reject(new Error(`TIMEOUT after ${ms}ms`));
|
|
14
|
+
}, ms);
|
|
15
|
+
promise
|
|
16
|
+
.then(resolve)
|
|
17
|
+
.catch(reject)
|
|
18
|
+
.finally(() => clearTimeout(timer));
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
export function jsonEnDe(sthis) {
|
|
22
|
+
return {
|
|
23
|
+
encode: (node) => sthis.txt.encode(JSON.stringify(node)),
|
|
24
|
+
decode: (data) => JSON.parse(sthis.txt.decode(data)),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export function defaultMsgParams(sthis, igs) {
|
|
28
|
+
return {
|
|
29
|
+
mime: "application/json",
|
|
30
|
+
ende: jsonEnDe(sthis),
|
|
31
|
+
timeout: 3000,
|
|
32
|
+
protocolCapabilities: ["reqRes", "stream"],
|
|
33
|
+
...igs,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
export async function applyStart(prC) {
|
|
37
|
+
const rC = await prC;
|
|
38
|
+
if (rC.isErr()) {
|
|
39
|
+
return rC;
|
|
40
|
+
}
|
|
41
|
+
const c = rC.Ok();
|
|
42
|
+
const r = await c.start();
|
|
43
|
+
if (r.isErr()) {
|
|
44
|
+
return Result.Err(r.Err());
|
|
45
|
+
}
|
|
46
|
+
return rC;
|
|
47
|
+
}
|
|
48
|
+
export async function authTypeFromUri(logger, curi) {
|
|
49
|
+
const uri = URI.from(curi);
|
|
50
|
+
const authJWK = uri.getParam("authJWK");
|
|
51
|
+
if (!authJWK) {
|
|
52
|
+
return logger.Error().Url(uri).Msg("authJWK is required").ResultError();
|
|
53
|
+
}
|
|
54
|
+
return Result.Ok({
|
|
55
|
+
type: "fp-cloud-jwk",
|
|
56
|
+
params: {
|
|
57
|
+
jwk: authJWK,
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
function initialFPUri(curl) {
|
|
62
|
+
let gestaltUrl = URI.from(curl);
|
|
63
|
+
if (["", "/"].includes(gestaltUrl.pathname)) {
|
|
64
|
+
gestaltUrl = gestaltUrl.build().appendRelative("/fp").URI();
|
|
65
|
+
}
|
|
66
|
+
return gestaltUrl;
|
|
67
|
+
}
|
|
68
|
+
export class Msger {
|
|
69
|
+
static connect(sthis, curl, mParam) {
|
|
70
|
+
const vc = new VirtualConnected(sthis, {
|
|
71
|
+
curl,
|
|
72
|
+
conn: mParam.conn,
|
|
73
|
+
openWSorHttp: mParam.mowh,
|
|
74
|
+
msgerParams: mParam.msgerParam ?? {},
|
|
75
|
+
});
|
|
76
|
+
return Promise.resolve(Result.Ok(vc));
|
|
77
|
+
}
|
|
78
|
+
constructor() {
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
export class MsgOpenWSAndHttp {
|
|
82
|
+
async openHttp(vc, urls, msgP, exGestalt) {
|
|
83
|
+
return Result.Ok(new HttpConnection(vc, urls, msgP, exGestalt));
|
|
84
|
+
}
|
|
85
|
+
async openWS(vc, url, msgP, exGestalt) {
|
|
86
|
+
url = url.build().defParam("random", vc.nextId().str).URI();
|
|
87
|
+
const wsUrl = ensurePath(url, "ws");
|
|
88
|
+
let wsFactory;
|
|
89
|
+
if (runtimeFn().isNodeIsh) {
|
|
90
|
+
const { WebSocket } = await import("ws");
|
|
91
|
+
wsFactory = () => new WebSocket(wsUrl);
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
wsFactory = () => new WebSocket(wsUrl);
|
|
95
|
+
}
|
|
96
|
+
const wsc = new WSConnection(vc, wsFactory(), msgP, exGestalt);
|
|
97
|
+
return Result.Ok(wsc);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
export class VirtualConnected {
|
|
101
|
+
sthis;
|
|
102
|
+
opts;
|
|
103
|
+
mowh;
|
|
104
|
+
logger;
|
|
105
|
+
id;
|
|
106
|
+
exchangedGestalt;
|
|
107
|
+
realConn;
|
|
108
|
+
retries = [];
|
|
109
|
+
virtualConn;
|
|
110
|
+
constructor(sthis, opts) {
|
|
111
|
+
this.sthis = sthis;
|
|
112
|
+
this.id = sthis.nextId().str;
|
|
113
|
+
this.logger = ensureLogger(sthis, "VirtualConnected");
|
|
114
|
+
this.opts = {
|
|
115
|
+
...opts,
|
|
116
|
+
openWSorHttp: opts.openWSorHttp || new MsgOpenWSAndHttp(),
|
|
117
|
+
retryCount: opts.retryCount || 3,
|
|
118
|
+
retryDelay: opts.retryDelay || 500,
|
|
119
|
+
conn: { reqId: sthis.nextId().str, ...opts.conn },
|
|
120
|
+
};
|
|
121
|
+
this.mowh = this.opts.openWSorHttp;
|
|
122
|
+
}
|
|
123
|
+
get conn() {
|
|
124
|
+
if (!this.virtualConn) {
|
|
125
|
+
const err = new Error("conn is not set");
|
|
126
|
+
throw err;
|
|
127
|
+
}
|
|
128
|
+
return this.virtualConn;
|
|
129
|
+
}
|
|
130
|
+
activeBinds = new Map();
|
|
131
|
+
async handleBindRealConn(realConn, req, as) {
|
|
132
|
+
const conn = { ...this.conn, ...req.conn };
|
|
133
|
+
const stream = realConn.bind({ ...as.bind.msg, auth: req.auth, conn }, as.bind.opts);
|
|
134
|
+
const sreader = stream.getReader();
|
|
135
|
+
while (true) {
|
|
136
|
+
const { done, value: msg } = await sreader.read();
|
|
137
|
+
if (done) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
try {
|
|
141
|
+
if (MsgIsConnected(msg, this.conn) || MsgIsConnected(msg, conn)) {
|
|
142
|
+
as.controller?.enqueue(msg);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
catch (err) {
|
|
146
|
+
this.sthis.logger.Error().Err(err).Any({ msg }).Msg("Error in handleBindRealConn callback[ignored]");
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
ensureOpts(opts) {
|
|
151
|
+
return {
|
|
152
|
+
...opts,
|
|
153
|
+
timeout: opts.timeout ?? this.opts.msgerParams.timeout ?? 3000,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
bind(req, iopts) {
|
|
157
|
+
const opts = this.ensureOpts(iopts);
|
|
158
|
+
const id = this.sthis.nextId().str;
|
|
159
|
+
return new ReadableStream({
|
|
160
|
+
cancel: (err) => {
|
|
161
|
+
this.sthis.logger.Debug().Msg("vc-bind-cancel", id, err);
|
|
162
|
+
this.activeBinds.delete(id);
|
|
163
|
+
},
|
|
164
|
+
start: (ctl) => {
|
|
165
|
+
this.getRealConn(req, opts, async (realConn) => {
|
|
166
|
+
const as = {
|
|
167
|
+
id,
|
|
168
|
+
bind: {
|
|
169
|
+
msg: req,
|
|
170
|
+
opts,
|
|
171
|
+
},
|
|
172
|
+
controller: ctl,
|
|
173
|
+
};
|
|
174
|
+
this.activeBinds.set(id, as);
|
|
175
|
+
this.handleBindRealConn(realConn, req, as);
|
|
176
|
+
return Result.Ok(undefined);
|
|
177
|
+
}).catch((err) => {
|
|
178
|
+
ctl.error({
|
|
179
|
+
type: "error",
|
|
180
|
+
src: "VirtualConnection:bind",
|
|
181
|
+
message: err.message,
|
|
182
|
+
tid: req.tid,
|
|
183
|
+
version: req.version,
|
|
184
|
+
auth: req.auth,
|
|
185
|
+
stack: [],
|
|
186
|
+
});
|
|
187
|
+
});
|
|
188
|
+
},
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
request(req, iopts) {
|
|
192
|
+
const opts = this.ensureOpts(iopts);
|
|
193
|
+
const realFn = (realConn) => realConn.request({
|
|
194
|
+
...req,
|
|
195
|
+
conn: { ...this.virtualConn, ...req.conn },
|
|
196
|
+
}, opts);
|
|
197
|
+
if (opts.rawConn) {
|
|
198
|
+
return realFn(opts.rawConn);
|
|
199
|
+
}
|
|
200
|
+
return this.getRealConn(req, opts, realFn);
|
|
201
|
+
}
|
|
202
|
+
send(msg) {
|
|
203
|
+
return this.getRealConn(msg, {
|
|
204
|
+
waitFor: () => true,
|
|
205
|
+
}, async (realConn) => {
|
|
206
|
+
const myMsg = {
|
|
207
|
+
...msg,
|
|
208
|
+
conn: { ...this.conn, ...msg.conn },
|
|
209
|
+
};
|
|
210
|
+
const ret = await realConn.send(myMsg);
|
|
211
|
+
return ret;
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
close(t) {
|
|
215
|
+
return this.getRealConn(t, {
|
|
216
|
+
waitFor: () => true,
|
|
217
|
+
noRetry: true,
|
|
218
|
+
}, (realConn) => realConn.close(t));
|
|
219
|
+
}
|
|
220
|
+
onMsg(msgFn) {
|
|
221
|
+
throw new Error("Method not implemented.");
|
|
222
|
+
}
|
|
223
|
+
async connect(auth, curl, imsgP = {}) {
|
|
224
|
+
const jsMsgP = defaultMsgParams(this.sthis, { ...imsgP, mime: "application/json", ende: jsonEnDe(this.sthis) });
|
|
225
|
+
const gestaltUrl = initialFPUri(curl);
|
|
226
|
+
const gs = defaultGestalt(defaultMsgParams(this.sthis, imsgP), { id: "FP-Universal-Client" });
|
|
227
|
+
const rHC = await this.mowh.openHttp(this.sthis, [gestaltUrl], jsMsgP, { my: gs, remote: gs });
|
|
228
|
+
if (rHC.isErr()) {
|
|
229
|
+
return rHC;
|
|
230
|
+
}
|
|
231
|
+
const hc = rHC.Ok();
|
|
232
|
+
const resGestalt = await hc.request(buildReqGestalt(this.sthis, auth, gs), {
|
|
233
|
+
waitFor: MsgIsResGestalt,
|
|
234
|
+
noConn: true,
|
|
235
|
+
});
|
|
236
|
+
if (!MsgIsResGestalt(resGestalt)) {
|
|
237
|
+
return this.logger.Error().Any({ resGestalt }).Msg("should be ResGestalt").ResultError();
|
|
238
|
+
}
|
|
239
|
+
await hc.close(resGestalt);
|
|
240
|
+
const exGt = { my: gs, remote: resGestalt.gestalt };
|
|
241
|
+
const msgP = defaultMsgParams(this.sthis, imsgP);
|
|
242
|
+
this.exchangedGestalt = exGt;
|
|
243
|
+
let rRealConn;
|
|
244
|
+
if (exGt.remote.protocolCapabilities.includes("reqRes") && !exGt.remote.protocolCapabilities.includes("stream")) {
|
|
245
|
+
rRealConn = await this.mowh.openHttp(this.sthis, exGt.remote.httpEndpoints.map((i) => BuildURI.from(curl).resolve(i).URI()), msgP, exGt);
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
const wsUrl = BuildURI.from(gestaltUrl).resolve(selectRandom(exGt.remote.wsEndpoints)).URI();
|
|
249
|
+
rRealConn = await this.mowh.openWS(this.sthis, wsUrl, msgP, exGt);
|
|
250
|
+
}
|
|
251
|
+
if (rRealConn.isErr()) {
|
|
252
|
+
return rRealConn;
|
|
253
|
+
}
|
|
254
|
+
const realConn = rRealConn.Ok();
|
|
255
|
+
const rStart = await realConn.start();
|
|
256
|
+
if (rStart.isErr()) {
|
|
257
|
+
return Result.Err(rStart);
|
|
258
|
+
}
|
|
259
|
+
return rRealConn;
|
|
260
|
+
}
|
|
261
|
+
async getQSIdWithSideEffect(rawConn, msg, conn) {
|
|
262
|
+
const mOpen = await this.request(buildReqOpen(this.sthis, msg.auth, conn), {
|
|
263
|
+
waitFor: MsgIsResOpen,
|
|
264
|
+
noConn: true,
|
|
265
|
+
rawConn,
|
|
266
|
+
});
|
|
267
|
+
if (MsgIsError(mOpen)) {
|
|
268
|
+
return mOpen;
|
|
269
|
+
}
|
|
270
|
+
this.virtualConn = mOpen.conn;
|
|
271
|
+
return mOpen;
|
|
272
|
+
}
|
|
273
|
+
mutex = pLimit(1);
|
|
274
|
+
async getRealConn(msg, iopts, action) {
|
|
275
|
+
const opts = this.ensureOpts(iopts);
|
|
276
|
+
const whatToDo = await this.mutex(async () => {
|
|
277
|
+
if (!this.realConn) {
|
|
278
|
+
if (this.retries.length >= this.opts.retryCount) {
|
|
279
|
+
return {
|
|
280
|
+
whatToDo: "return",
|
|
281
|
+
value: {
|
|
282
|
+
type: "error",
|
|
283
|
+
src: "VirtualConnection:getRealConn",
|
|
284
|
+
message: "retry count exceeded",
|
|
285
|
+
tid: msg.tid,
|
|
286
|
+
version: msg.version,
|
|
287
|
+
auth: msg.auth,
|
|
288
|
+
stack: [],
|
|
289
|
+
},
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
const rConn = await this.connect(msg.auth, this.opts.curl, this.opts.msgerParams);
|
|
293
|
+
if (rConn.isErr()) {
|
|
294
|
+
this.retries.push({ retryCount: this.retries.length + 1 });
|
|
295
|
+
await sleep(this.opts.retryDelay * this.retries.length);
|
|
296
|
+
return {
|
|
297
|
+
whatToDo: "recurse",
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
this.realConn = rConn.Ok();
|
|
301
|
+
const mQSid = await this.getQSIdWithSideEffect(this.realConn, msg, {
|
|
302
|
+
reqId: this.sthis.nextId().str,
|
|
303
|
+
...this.virtualConn,
|
|
304
|
+
...this.opts.conn,
|
|
305
|
+
});
|
|
306
|
+
if (MsgIsError(mQSid)) {
|
|
307
|
+
return {
|
|
308
|
+
whatToDo: "return",
|
|
309
|
+
value: {
|
|
310
|
+
...mQSid,
|
|
311
|
+
tid: msg.tid,
|
|
312
|
+
},
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
for (const as of this.activeBinds.values()) {
|
|
316
|
+
void this.handleBindRealConn(this.realConn, msg, as);
|
|
317
|
+
}
|
|
318
|
+
return {
|
|
319
|
+
whatToDo: "recurse",
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
else {
|
|
323
|
+
if (!this.realConn.isReady) {
|
|
324
|
+
await this.realConn.close(msg);
|
|
325
|
+
this.realConn = undefined;
|
|
326
|
+
this.retries = [];
|
|
327
|
+
return { whatToDo: "recurse" };
|
|
328
|
+
}
|
|
329
|
+
if (!opts.noConn && !this.virtualConn) {
|
|
330
|
+
const conn = MsgIsWithConn(msg) ? { conn: msg.conn } : {};
|
|
331
|
+
return {
|
|
332
|
+
whatToDo: "return",
|
|
333
|
+
value: {
|
|
334
|
+
type: "error",
|
|
335
|
+
src: msg,
|
|
336
|
+
message: "virtualConn is not set",
|
|
337
|
+
tid: msg.tid,
|
|
338
|
+
...conn,
|
|
339
|
+
version: msg.version,
|
|
340
|
+
auth: msg.auth,
|
|
341
|
+
stack: [],
|
|
342
|
+
},
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
return {
|
|
346
|
+
whatToDo: "action",
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
switch (whatToDo.whatToDo) {
|
|
351
|
+
case "recurse":
|
|
352
|
+
return this.getRealConn(msg, opts, action);
|
|
353
|
+
case "return":
|
|
354
|
+
return whatToDo.value;
|
|
355
|
+
case "action":
|
|
356
|
+
if (!this.realConn) {
|
|
357
|
+
throw new Error("realConn is not set, this should not happen");
|
|
358
|
+
}
|
|
359
|
+
return action(this.realConn);
|
|
360
|
+
default:
|
|
361
|
+
throw new Error(`Unknown action: ${whatToDo.whatToDo} for msg: ${msg.type} with id: ${this.id}`);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
}
|
|
365
|
+
//# sourceMappingURL=msger.js.map
|
package/msger.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"msger.js","sourceRoot":"","sources":["msger.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAqB,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AACtF,OAAO,EACL,eAAe,EACf,cAAc,EAKd,eAAe,EAIf,UAAU,EASV,YAAY,EACZ,YAAY,EAGZ,cAAc,EACd,aAAa,GAEd,MAAM,uCAAuC,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAC9D,OAAO,MAAM,MAAM,2BAA2B,CAAC;AAO/C,MAAM,UAAU,YAAY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