@effect-app/infra 0.17.0 → 0.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/_cjs/api/setupRequest.cjs +22 -4
- package/_cjs/api/setupRequest.cjs.map +1 -1
- package/_cjs/services/QueueMaker/errors.cjs +54 -0
- package/_cjs/services/QueueMaker/errors.cjs.map +1 -0
- package/_cjs/services/QueueMaker/memQueue.cjs +79 -0
- package/_cjs/services/QueueMaker/memQueue.cjs.map +1 -0
- package/_cjs/services/QueueMaker/sbqueue.cjs +80 -0
- package/_cjs/services/QueueMaker/sbqueue.cjs.map +1 -0
- package/_cjs/services/QueueMaker/service.cjs +9 -0
- package/_cjs/services/QueueMaker/service.cjs.map +1 -0
- package/_src/_global.ext.ts +4 -0
- package/_src/api/setupRequest.ts +19 -0
- package/_src/services/QueueMaker/errors.ts +48 -0
- package/_src/services/QueueMaker/memQueue.ts +102 -0
- package/_src/services/QueueMaker/sbqueue.ts +118 -0
- package/_src/services/QueueMaker/service.ts +14 -0
- package/dist/_global.ext.d.ts +4 -0
- package/dist/_global.ext.d.ts.map +1 -1
- package/dist/api/setupRequest.d.ts +5 -0
- package/dist/api/setupRequest.d.ts.map +1 -1
- package/dist/api/setupRequest.js +20 -3
- package/dist/services/QueueMaker/errors.d.ts +24 -0
- package/dist/services/QueueMaker/errors.d.ts.map +1 -0
- package/dist/services/QueueMaker/errors.js +37 -0
- package/dist/services/QueueMaker/memQueue.d.ts +25 -0
- package/dist/services/QueueMaker/memQueue.d.ts.map +1 -0
- package/dist/services/QueueMaker/memQueue.js +60 -0
- package/dist/services/QueueMaker/sbqueue.d.ts +31 -0
- package/dist/services/QueueMaker/sbqueue.d.ts.map +1 -0
- package/dist/services/QueueMaker/sbqueue.js +61 -0
- package/dist/services/QueueMaker/service.d.ts +15 -0
- package/dist/services/QueueMaker/service.d.ts.map +1 -0
- package/dist/services/QueueMaker/service.js +2 -0
- package/package.json +45 -4
package/CHANGELOG.md
CHANGED
|
@@ -3,17 +3,20 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
exports.setupRequestFrom =
|
|
6
|
+
exports.setupReq3 = setupReq3;
|
|
7
|
+
exports.setupRequestFrom = exports.setupRequest = void 0;
|
|
8
8
|
var tsplus_module_1 = _interopRequireWildcard(require("@effect/io/Effect"));
|
|
9
9
|
var tsplus_module_2 = _interopRequireWildcard(require("@effect-app/prelude/_ext/misc"));
|
|
10
10
|
var tsplus_module_3 = _interopRequireWildcard(require("@effect-app/core/Function"));
|
|
11
11
|
var tsplus_module_4 = _interopRequireWildcard(require("@effect-app/infra/RequestContext"));
|
|
12
|
-
require("
|
|
12
|
+
var tsplus_module_5 = _interopRequireWildcard(require("@effect-app/prelude/schema"));
|
|
13
|
+
var _RequestContext2 = require("../RequestContext.cjs");
|
|
13
14
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
14
15
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
15
16
|
const setupRequest = setupRequest_1;
|
|
16
17
|
exports.setupRequest = setupRequest;
|
|
18
|
+
const setupRequestFrom = setupRequestFrom_1;
|
|
19
|
+
exports.setupRequestFrom = setupRequestFrom;
|
|
17
20
|
/**
|
|
18
21
|
* @tsplus fluent effect/io/Effect setupRequest
|
|
19
22
|
*/
|
|
@@ -27,7 +30,22 @@ function setupRequest_1(self, requestContext) {
|
|
|
27
30
|
/**
|
|
28
31
|
* @tsplus getter effect/io/Effect setupRequestFrom
|
|
29
32
|
*/
|
|
30
|
-
function
|
|
33
|
+
function setupRequestFrom_1(self) {
|
|
31
34
|
return tsplus_module_1.serviceWithEffect(tsplus_module_4.tag, requestContext => setupRequest_1(self, requestContext));
|
|
32
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* @tsplus fluent effect/io/Effect setupRequestFromWith
|
|
38
|
+
*/
|
|
39
|
+
function setupReq3(self, name) {
|
|
40
|
+
return tsplus_module_1.provideService(setupRequestFrom_1(self), tsplus_module_4.tag, makeInternalRequestContext(name));
|
|
41
|
+
}
|
|
42
|
+
function makeInternalRequestContext(name) {
|
|
43
|
+
const id = tsplus_module_5.StringId.make();
|
|
44
|
+
return new _RequestContext2.RequestContext({
|
|
45
|
+
id,
|
|
46
|
+
rootId: id,
|
|
47
|
+
locale: "en",
|
|
48
|
+
name: tsplus_module_5.ReasonableString(name)
|
|
49
|
+
});
|
|
50
|
+
}
|
|
33
51
|
//# sourceMappingURL=setupRequest.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setupRequest.cjs","mappings":"
|
|
1
|
+
{"version":3,"file":"setupRequest.cjs","mappings":";;;;;;;;;;;;AAAA;AAAqD;AAAA;MAKrCA,YAAY;AAAA;MAcZC,gBAAgB;AAAA;AAjBhC;;;AAGA,wBAAsCC,IAAqB,EAAEC,cAA8B;EACzF,OAAOC,oBAAI,CACTC,4BAAI,EAAS,SAAS,CAAC,EACvBC,6BAAoB;IAClBC,aAAa,EAAEJ,cAAc,CAACK,MAAM;IACpCC,SAAS,EAAEN,cAAc,CAACO,EAAE;IAC5BC,WAAW,EAAER,cAAc,CAACS;GAC7B,CAAC,CACH;AACH;AAEA;;;AAGA,4BAA0CV,IAAqB;EAC7D,OAAOG,uDAAoCF,cAAc,IAAIU,mBAAI,EAAcV,cAAc,CAAC,CAAC;AACjG;AAEA;;;AAGM,SAAUW,SAAS,CAAUZ,IAAqB,EAAEU,IAAY;EACpE,OAAOP,sDAAI,wBAE2BU,0BAA0B,CAACH,IAAI,CAAC,CAAC;AACzE;AAEA,SAASG,0BAA0B,CAACH,IAAY;EAC9C,MAAMF,EAAE,GAAGM,wBAAQ,CAACC,IAAI,EAAE;EAC1B,OAAO,IAAIC,+BAAc,CAAC;IACxBR,EAAE;IACFF,MAAM,EAAEE,EAAE;IACVS,MAAM,EAAE,IAAI;IACZP,IAAI,EAAEI,gCAAgB,CAACJ,IAAI;GAC5B,CAAC;AACJ","names":["setupRequest","setupRequestFrom","self","requestContext","tsplus_module_3","tsplus_module_1","tsplus_module_2","requestRootId","rootId","requestId","id","requestName","name","setupRequest_1","setupReq3","makeInternalRequestContext","tsplus_module_5","make","RequestContext","locale"],"sourceRoot":"","sources":["../../_src/api/setupRequest.ts"],"sourcesContent":[null]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.MessageException = exports.FatalQueueException = void 0;
|
|
7
|
+
exports.forkDaemonReportQueue = forkDaemonReportQueue;
|
|
8
|
+
exports.reportFailure = reportFailure;
|
|
9
|
+
exports.reportQueueError = exports.reportFatalQueueError = void 0;
|
|
10
|
+
var tsplus_module_1 = _interopRequireWildcard(require("@effect/io/Effect"));
|
|
11
|
+
var tsplus_module_2 = _interopRequireWildcard(require("@effect-app/infra/RequestContext"));
|
|
12
|
+
var tsplus_module_3 = _interopRequireWildcard(require("@effect-app/core/Effect"));
|
|
13
|
+
var _errorReporter = require("@effect-app/infra/errorReporter");
|
|
14
|
+
var _errors = require("@effect-app/infra/errors");
|
|
15
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
16
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
|
+
class MessageException extends _errors.CauseException {
|
|
18
|
+
constructor(cause) {
|
|
19
|
+
super(cause, "Message");
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
exports.MessageException = MessageException;
|
|
23
|
+
class FatalQueueException extends _errors.CauseException {
|
|
24
|
+
constructor(cause) {
|
|
25
|
+
super(cause, "Message");
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.FatalQueueException = FatalQueueException;
|
|
29
|
+
const reportQueueError_ = (0, _errorReporter.reportError)(cause => new MessageException(cause));
|
|
30
|
+
const reportQueueError = (cause, context) => tsplus_module_1.serviceWithEffect(tsplus_module_2.tag, requestContext => tsplus_module_1.sync(() => reportQueueError_(cause, {
|
|
31
|
+
requestContext,
|
|
32
|
+
...context
|
|
33
|
+
})));
|
|
34
|
+
/**
|
|
35
|
+
* Forks the effect into a new fiber attached to the global scope. Because the
|
|
36
|
+
* new fiber is attached to the global scope, when the fiber executing the
|
|
37
|
+
* returned effect terminates, the forked fiber will continue running.
|
|
38
|
+
*
|
|
39
|
+
* Reports errors.
|
|
40
|
+
*
|
|
41
|
+
* @tsplus getter effect/io/Effect forkDaemonReportQueue
|
|
42
|
+
*/
|
|
43
|
+
exports.reportQueueError = reportQueueError;
|
|
44
|
+
function forkDaemonReportQueue(self) {
|
|
45
|
+
return tsplus_module_1.daemonChildren(tsplus_module_1.fork(tsplus_module_1.tapErrorCause(self, reportQueueError)));
|
|
46
|
+
}
|
|
47
|
+
const reportFatalQueueError = (0, _errorReporter.reportError)(cause => new FatalQueueException(cause));
|
|
48
|
+
exports.reportFatalQueueError = reportFatalQueueError;
|
|
49
|
+
function reportFailure(name) {
|
|
50
|
+
return self => tsplus_module_1.tap(tsplus_module_1.exit(self), exit => exit._tag === "Failure" ? reportFatalQueueError(exit.cause, {
|
|
51
|
+
name
|
|
52
|
+
}) : tsplus_module_3.unit);
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=errors.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.cjs","mappings":";;;;;;;;;;;;AAAA;AACA;AAAyD;AAAA;AAGnD,MAAOA,gBAAoB,SAAQC,sBAAiB;EACxDC,YAAYC,KAAe;IACzB,KAAK,CAACA,KAAK,EAAE,SAAS,CAAC;EACzB;;AACD;AAEK,MAAOC,mBAAuB,SAAQH,sBAAiB;EAC3DC,YAAYC,KAAe;IACzB,KAAK,CAACA,KAAK,EAAE,SAAS,CAAC;EACzB;;AACD;AAED,MAAME,iBAAiB,GAAG,8BAAW,EAACF,KAAK,IAAI,IAAIH,gBAAgB,CAACG,KAAK,CAAC,CAAC;AAEpE,MAAMG,gBAAgB,GAAG,CAACH,KAAqB,EAAEI,OAA6C,KACnGC,uDAAoCC,cAAc,IAChDD,2BAAOH,iBAAiB,CAACF,KAAK,EAAE;EAAEM,cAAc;EAAE,GAAGF;AAAO,CAAE,CAAC,CAAC,CACjE;AAEH;;;;;;;;;AAAA;AASM,SAAUG,qBAAqB,CAAUC,IAAqB;EAClE,2DAAOH,kCAAI,EAAeF,gBAAgB,CAAC;AAC7C;AAEO,MAAMM,qBAAqB,GAAG,8BAAW,EAC9CT,KAAK,IAAI,IAAIC,mBAAmB,CAACD,KAAK,CAAC,CACxC;AAAA;AAEK,SAAUU,aAAa,CAACC,IAAY;EACxC,OAAiBH,IAAqB,IACpCH,6CAAI,GAAUO,IAAI,IAChBA,IAAI,CAACC,IAAI,KAAK,SAAS,GACnBJ,qBAAqB,CAACG,IAAI,CAACZ,KAAK,EAAE;IAAEW;EAAI,CAAE,CAAC,GAC5CG,oBAAY,CAChB;AACL","names":["MessageException","CauseException","constructor","cause","FatalQueueException","reportQueueError_","reportQueueError","context","tsplus_module_1","requestContext","forkDaemonReportQueue","self","reportFatalQueueError","reportFailure","name","exit","_tag","tsplus_module_3"],"sourceRoot":"","sources":["../../../_src/services/QueueMaker/errors.ts"],"sourcesContent":[null]}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.makeMemQueue = makeMemQueue;
|
|
7
|
+
exports.silence = silence;
|
|
8
|
+
var tsplus_module_1 = _interopRequireWildcard(require("@effect/io/Effect"));
|
|
9
|
+
var tsplus_module_2 = _interopRequireWildcard(require("@effect-app/infra/RequestContext"));
|
|
10
|
+
var tsplus_module_3 = _interopRequireWildcard(require("@effect-app/core/_ext/Iterable"));
|
|
11
|
+
var tsplus_module_4 = _interopRequireWildcard(require("@effect-app/infra/services/QueueMaker/errors"));
|
|
12
|
+
var tsplus_module_5 = _interopRequireWildcard(require("@effect-app/prelude/utils"));
|
|
13
|
+
var tsplus_module_6 = _interopRequireWildcard(require("@effect-app/prelude/_ext/misc"));
|
|
14
|
+
var tsplus_module_7 = _interopRequireWildcard(require("@effect-app/prelude/schema"));
|
|
15
|
+
var tsplus_module_8 = _interopRequireWildcard(require("@effect-app/infra/api/setupRequest"));
|
|
16
|
+
var tsplus_module_9 = _interopRequireWildcard(require("@effect/io/Cause"));
|
|
17
|
+
var tsplus_module_10 = _interopRequireWildcard(require("@effect-app/core/Effect"));
|
|
18
|
+
var tsplus_module_11 = _interopRequireWildcard(require("@effect/io/Exit"));
|
|
19
|
+
var _memQueue = require("@effect-app/infra-adapters/memQueue");
|
|
20
|
+
var _errors2 = require("./errors.cjs");
|
|
21
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
22
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
23
|
+
/**
|
|
24
|
+
* @tsplus static QueueMaker.Ops makeMem
|
|
25
|
+
*/
|
|
26
|
+
function makeMemQueue(queueName, queueDrainName, encoder, makeHandleEvent, provideContext, parseDrain) {
|
|
27
|
+
return tsplus_module_1.gen(function* ($) {
|
|
28
|
+
const mem = yield* $(tsplus_module_1.service(_memQueue.MemQueue));
|
|
29
|
+
const q = yield* $(mem.getOrCreateQueue(queueName));
|
|
30
|
+
const qReply = yield* $(mem.getOrCreateQueue(queueDrainName));
|
|
31
|
+
return {
|
|
32
|
+
publish: (...messages) => tsplus_module_1.gen(function* ($) {
|
|
33
|
+
const requestContext = yield* $(tsplus_module_1.service(tsplus_module_2.tag));
|
|
34
|
+
return yield* $(tsplus_module_4.forkDaemonReportQueue(tsplus_module_3.ext_forEach(messages, m => tsplus_module_1.asUnit(
|
|
35
|
+
// we JSON encode, because that is what the wire also does, and it reveals holes in e.g unknown encoders (Date->String)
|
|
36
|
+
tsplus_module_1.flatMap(tsplus_module_1.sync(() => JSON.stringify(encoder({
|
|
37
|
+
body: m,
|
|
38
|
+
meta: requestContext
|
|
39
|
+
})))
|
|
40
|
+
// .tap((msg) => info("Publishing Mem Message: " + utils.inspect(msg)))
|
|
41
|
+
, _ => q.offer(_))))));
|
|
42
|
+
}),
|
|
43
|
+
drain: tsplus_module_1.gen(function* ($) {
|
|
44
|
+
const handleEvent = yield* $(makeHandleEvent);
|
|
45
|
+
const processMessage = msg =>
|
|
46
|
+
// we JSON parse, because that is what the wire also does, and it reveals holes in e.g unknown encoders (Date->String)
|
|
47
|
+
tsplus_module_1.flatMap(tsplus_module_1.orDie(tsplus_module_1.flatMap(tsplus_module_1.sync(() => JSON.parse(msg)), parseDrain)), ({
|
|
48
|
+
body,
|
|
49
|
+
meta
|
|
50
|
+
}) => provideContext(tsplus_module_2.RequestContext.inherit(meta, {
|
|
51
|
+
id: body.id,
|
|
52
|
+
locale: "en",
|
|
53
|
+
name: tsplus_module_7.ReasonableString(body._tag)
|
|
54
|
+
}))(tsplus_module_1.zipRight(tsplus_module_6.logAnnotates({
|
|
55
|
+
body: tsplus_module_5.RecordPretty(tsplus_module_5.object$(body)),
|
|
56
|
+
meta: tsplus_module_5.RecordPretty(tsplus_module_5.object$(meta))
|
|
57
|
+
})(tsplus_module_1.logDebug(`$$ [${queueDrainName}] Processing incoming message`)), silence(handleEvent(body)))));
|
|
58
|
+
return yield* $(tsplus_module_1.forkScoped(tsplus_module_8.setupReq3((0, _errors2.reportFailure)("drain")(tsplus_module_1.forever(tsplus_module_1.flatMap(qReply.take(), x => tsplus_module_1.uninterruptible(processMessage(x))))), "Queue.ReceiveMessage")));
|
|
59
|
+
})
|
|
60
|
+
};
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
// We want the Queue to continue processing even on errors per messages
|
|
64
|
+
// must make sure that the errors are processed/handled beforehand.
|
|
65
|
+
function silence(inp) {
|
|
66
|
+
return tsplus_module_1.flatMap(tsplus_module_1.exit(inp), result => tsplus_module_1.gen(function* ($) {
|
|
67
|
+
const requestContext = yield* $(tsplus_module_1.service(tsplus_module_2.tag));
|
|
68
|
+
return yield* $(tsplus_module_11.match(result, cause => {
|
|
69
|
+
if (tsplus_module_9.isInterrupted(cause)) {
|
|
70
|
+
return tsplus_module_1.failCause(cause);
|
|
71
|
+
}
|
|
72
|
+
(0, _errors2.reportQueueError)(cause, {
|
|
73
|
+
requestContext
|
|
74
|
+
});
|
|
75
|
+
return tsplus_module_10.unit;
|
|
76
|
+
}, () => tsplus_module_10.unit));
|
|
77
|
+
}));
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=memQueue.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memQueue.cjs","mappings":";;;;;;;;;;;;;;;;;;AAAA;AAGA;AAA6D;AAAA;AAG7D;;;AAGM,SAAUA,YAAY,CAC1BC,SAAiB,EACjBC,cAAsB,EACtBC,OAAyD,EACzDC,eAAwF,EACxFC,cAEuC,EACvCC,UAGmF;EAEnF,OAAOC,oBAAW,WAAUC,CAAC;IAC3B,MAAMC,GAAG,GAAG,OAAOD,CAAC,yBAACE,kBAAQ,EAAQ;IACrC,MAAMC,CAAC,GAAG,OAAOH,CAAC,CAACC,GAAG,CAACG,gBAAgB,CAACX,SAAS,CAAC,CAAC;IACnD,MAAMY,MAAM,GAAG,OAAOL,C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AC,yBAH/BhC,8BAAM,CAACiC,IAAI,EAAE,EACFC,CAAC,IAAGlC,gCAACoB,cAAc,CAACc,CAAC,CAAC,CAAgB,CAAC,IAG1B,sBAAsB,CAAC,EAEhD;MACH,CAAC;KAC+B;EACpC,CAAC,CAAC;AACJ;AAEA;AACA;AACM,SAAUH,OAAO,CAAUI,GAAoB;EACnD,OAAOnC,gDAAG,GAAcoC,MAAM,IAC5BpC,oBAAW,WAAUC,CAAC;IACpB,MAAMQ,cAAc,GAAG,OAAOR,CAAC,8CAA2B;IAC1D,OAAO,OAAOA,CAAC,CACboC,6BAAM,EACJC,KAAK,IAAG;MACN,IAAIC,mCAAK,CAAgB,EAAE;QACzB,iCAAQD,KAAsB;;MAEhC,6BAAgB,EAACA,KAAK,EAAE;QAAE7B;MAAc,CAAE,CAAC;MAC3C;IACF,CAAC,EACD,MAAK+B,qBAAY,CAClB,CACF;EACH,CAAC,CAAC,CACH;AACH","names":["makeMemQueue","queueName","queueDrainName","encoder","makeHandleEvent","provideContext","parseDrain","tsplus_module_1","$","mem","MemQueue","q","getOrCreateQueue","qReply","publish","messages","requestContext","tsplus_module_3","m","JSON","stringify","body","meta","_","offer","drain","handleEvent","processMessage","msg","parse","RequestContext","inherit","id","locale","name","tsplus_module_7","_tag","tsplus_module_6","silence","tsplus_module_8","take","x","inp","result","tsplus_module_11","cause","tsplus_module_9","tsplus_module_10"],"sourceRoot":"","sources":["../../../_src/services/QueueMaker/memQueue.ts"],"sourcesContent":[null]}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.makeServiceBusLayers = makeServiceBusLayers;
|
|
7
|
+
exports.makeServiceBusQueue = makeServiceBusQueue;
|
|
8
|
+
var tsplus_module_1 = _interopRequireWildcard(require("@effect/io/Effect"));
|
|
9
|
+
var tsplus_module_2 = _interopRequireWildcard(require("@effect-app/core/Tag"));
|
|
10
|
+
var tsplus_module_3 = _interopRequireWildcard(require("@effect-app/prelude/utils"));
|
|
11
|
+
var tsplus_module_4 = _interopRequireWildcard(require("@effect-app/prelude/_ext/misc"));
|
|
12
|
+
var tsplus_module_5 = _interopRequireWildcard(require("@effect-app/prelude/schema"));
|
|
13
|
+
var tsplus_module_6 = _interopRequireWildcard(require("@effect-app/infra/api/setupRequest"));
|
|
14
|
+
var tsplus_module_7 = _interopRequireWildcard(require("@effect-app/infra/RequestContext"));
|
|
15
|
+
var tsplus_module_8 = _interopRequireWildcard(require("@effect-app/infra/services/QueueMaker/errors"));
|
|
16
|
+
var tsplus_module_9 = _interopRequireWildcard(require("@effect/io/Layer"));
|
|
17
|
+
var _ServiceBus = require("@effect-app/infra-adapters/ServiceBus");
|
|
18
|
+
var _errorReporter = require("@effect-app/infra/errorReporter");
|
|
19
|
+
var _errors2 = require("./errors.cjs");
|
|
20
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
21
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
22
|
+
/**
|
|
23
|
+
* @tsplus static QueueMaker.Ops makeServiceBus
|
|
24
|
+
*/
|
|
25
|
+
function makeServiceBusQueue(_queueName, queueDrainName, encoder, makeHandleEvent, provideContext, parseDrain) {
|
|
26
|
+
return tsplus_module_1.gen(function* ($) {
|
|
27
|
+
const s = yield* $(tsplus_module_1.service(_ServiceBus.Sender));
|
|
28
|
+
const receiver = yield* $(tsplus_module_1.service(_ServiceBus.Receiver));
|
|
29
|
+
const receiverLayer = tsplus_module_2.makeLayer(_ServiceBus.Receiver, receiver);
|
|
30
|
+
return {
|
|
31
|
+
drain: tsplus_module_1.gen(function* ($) {
|
|
32
|
+
const handleEvent = yield* $(makeHandleEvent);
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
34
|
+
function processMessage(messageBody) {
|
|
35
|
+
return tsplus_module_1.asUnit(tsplus_module_1.orDie(tsplus_module_6.setupReq3(tsplus_module_1.flatMap(tsplus_module_1.tapErrorCause(tsplus_module_1.orDie(tsplus_module_1.flatMap(tsplus_module_1.sync(() => JSON.parse(messageBody)), x => parseDrain(x))), report), ({
|
|
36
|
+
body,
|
|
37
|
+
meta
|
|
38
|
+
}) => provideContext(tsplus_module_7.RequestContext.inherit(meta, {
|
|
39
|
+
id: body.id,
|
|
40
|
+
locale: "en",
|
|
41
|
+
name: tsplus_module_5.ReasonableString(body._tag)
|
|
42
|
+
}))(tsplus_module_1.tapErrorCause(tsplus_module_1.zipRight(tsplus_module_4.logAnnotates({
|
|
43
|
+
body: tsplus_module_3.RecordPretty(tsplus_module_3.object$(body)),
|
|
44
|
+
meta: tsplus_module_3.RecordPretty(tsplus_module_3.object$(meta))
|
|
45
|
+
})(tsplus_module_1.logDebug(`$$ [${queueDrainName}] Processing incoming message`)), handleEvent(body)), report))), "Queue.ReceiveMessage")));
|
|
46
|
+
}
|
|
47
|
+
return yield* $(tsplus_module_1.provideSomeLayer((0, _ServiceBus.subscribe)({
|
|
48
|
+
processMessage: x => tsplus_module_1.uninterruptible(processMessage(x.body)),
|
|
49
|
+
processError: err => tsplus_module_1.sync(() => (0, _errorReporter.captureException)(err.error))
|
|
50
|
+
}), receiverLayer));
|
|
51
|
+
}),
|
|
52
|
+
publish: (...messages) => tsplus_module_1.gen(function* ($) {
|
|
53
|
+
const requestContext = yield* $(tsplus_module_1.service(tsplus_module_7.tag));
|
|
54
|
+
return yield* $(tsplus_module_8.forkDaemonReportQueue(tsplus_module_1.promise(() => s.sendMessages(messages.map(x => ({
|
|
55
|
+
body: JSON.stringify(encoder({
|
|
56
|
+
body: x,
|
|
57
|
+
meta: requestContext
|
|
58
|
+
})),
|
|
59
|
+
messageId: x.id,
|
|
60
|
+
contentType: "application/json"
|
|
61
|
+
}))))));
|
|
62
|
+
})
|
|
63
|
+
};
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* @tsplus static QueueMaker.Ops makeServiceBusLayers
|
|
68
|
+
*/
|
|
69
|
+
function makeServiceBusLayers(url, queueName, queueDrainName) {
|
|
70
|
+
return tsplus_module_9.provide(tsplus_module_9.merge((0, _ServiceBus.LiveSender)(queueName))((0, _ServiceBus.LiveReceiver)(queueDrainName)))((0, _ServiceBus.LiveServiceBusClient)(url));
|
|
71
|
+
}
|
|
72
|
+
function report(cause) {
|
|
73
|
+
return tsplus_module_1.gen(function* ($) {
|
|
74
|
+
const requestContext = yield* $(tsplus_module_1.service(tsplus_module_7.tag));
|
|
75
|
+
return (0, _errors2.reportQueueError)(cause, {
|
|
76
|
+
requestContext
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=sbqueue.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sbqueue.cjs","mappings":";;;;;;;;;;;;;;;;AAAA;AASA;AAGA;AAA8C;AAAA;AAG9C;;;AAGM,SAAUA,mBAAmB,CAQjCC,UAAkB,EAClBC,cAAsB,EACtBC,OAAyD,EACzDC,eAAwF,EACxFC,cAEuC,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vB,aAAa,CAAC,CACnC;MACH,CAAC,CAAC;MAEFwB,OAAO,EAAE,CAAC,GAAGC,QAAQ,KACnB/B,oBAAW,WAAUC,CAAC;QACpB,MAAM+B,cAAc,GAAG,OAAO/B,CAAC,8CAA2B;QAC1D,OAAO,OAAOA,CAAC,uCACbD,wBAAe,MACbE,CAAC,CAAC+B,YAAY,CACZF,QAAQ,CAACG,GAAG,CAACnB,CAAC,KAAK;UACjBE,IAAI,EAAEJ,IAAI,CAACsB,SAAS,CAClBvC,OAAO,CAAC;YAAEqB,IAAI,EAAEF,CAAC;YAAEG,IAAI,EAAEc;UAAc,CAAE,CAAC,CAC3C;UACDI,SAAS,EAAErB,CAAC,CAACM,EAAE;UACfgB,WAAW,EAAE;SACd,CAAC,CAAC,CACJ,CACF,EAEF;MACH,CAAC;KAC6B;EACpC,CAAC,CAAC;AACJ;AAEA;;;AAGM,SAAUC,oBAAoB,CAACC,GAAW,EAAEC,SAAiB,EAAE7C,cAAsB;EACzF,+BACK8C,sBAAgC,0BAAU,EAACD,SAAS,CAAC,EAApD,4BAAY,EAAC7C,cAAc,CAAC,EAAyB,CADpD,oCAAoB,EAAC4C,GAAG,CAAC;AAElC;AAEA,SAASvB,MAAM,CAAI0B,KAAe;EAChC,OAAO1C,oBAAW,WAAUC,CAAC;IAC3B,MAAM+B,cAAc,GAAG,OAAO/B,CAAC,8CAA2B;IAC1D,OAAO,6BAAgB,EAACyC,KAAK,EAAE;MAAEV;IAAc,CAAE,CAAC;EACpD,CAAC,CAAC;AACJ","names":["makeServiceBusQueue","_queueName","queueDrainName","encoder","makeHandleEvent","provideContext","parseDrain","tsplus_module_1","$","s","Sender","receiver","Receiver","receiverLayer","tsplus_module_2","drain","handleEvent","processMessage","messageBody","tsplus_module_6","JSON","parse","x","report","body","meta","RequestContext","inherit","id","locale","name","tsplus_module_5","_tag","tsplus_module_4","processError","err","error","publish","messages","requestContext","sendMessages","map","stringify","messageId","contentType","makeServiceBusLayers","url","queueName","tsplus_module_9","cause"],"sourceRoot":"","sources":["../../../_src/services/QueueMaker/sbqueue.ts"],"sourcesContent":[null]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.cjs","mappings":";;;;;;AAaO,MAAMA,UAAU,GAAkB,EAAE;AAAA","names":["QueueMaker"],"sourceRoot":"","sources":["../../../_src/services/QueueMaker/service.ts"],"sourcesContent":[null]}
|
package/_src/_global.ext.ts
CHANGED
|
@@ -10,6 +10,10 @@ import type {} from "@effect-app/infra/services/Emailer/Sendgrid"
|
|
|
10
10
|
* @tsplus global
|
|
11
11
|
*/
|
|
12
12
|
import type {} from "@effect-app/infra/services/Operations/live"
|
|
13
|
+
/**
|
|
14
|
+
* @tsplus global
|
|
15
|
+
*/
|
|
16
|
+
import type {} from "@effect-app/infra/services/QueueMaker/errors"
|
|
13
17
|
/**
|
|
14
18
|
* @tsplus global
|
|
15
19
|
*/
|
package/_src/api/setupRequest.ts
CHANGED
|
@@ -20,3 +20,22 @@ export function setupRequest<R, E, A>(self: Effect<R, E, A>, requestContext: Req
|
|
|
20
20
|
export function setupRequestFrom<R, E, A>(self: Effect<R, E, A>) {
|
|
21
21
|
return RequestContext.Tag.accessWithEffect(requestContext => self.setupRequest(requestContext))
|
|
22
22
|
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @tsplus fluent effect/io/Effect setupRequestFromWith
|
|
26
|
+
*/
|
|
27
|
+
export function setupReq3<R, E, A>(self: Effect<R, E, A>, name: string) {
|
|
28
|
+
return self
|
|
29
|
+
.setupRequestFrom
|
|
30
|
+
.provideService(RequestContext.Tag, makeInternalRequestContext(name))
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function makeInternalRequestContext(name: string) {
|
|
34
|
+
const id = StringId.make()
|
|
35
|
+
return new RequestContext({
|
|
36
|
+
id,
|
|
37
|
+
rootId: id,
|
|
38
|
+
locale: "en",
|
|
39
|
+
name: ReasonableString(name)
|
|
40
|
+
})
|
|
41
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { reportError } from "@effect-app/infra/errorReporter"
|
|
2
|
+
import { CauseException } from "@effect-app/infra/errors"
|
|
3
|
+
import { RequestContext } from "@effect-app/infra/RequestContext"
|
|
4
|
+
|
|
5
|
+
export class MessageException<E> extends CauseException<E> {
|
|
6
|
+
constructor(cause: Cause<E>) {
|
|
7
|
+
super(cause, "Message")
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class FatalQueueException<E> extends CauseException<E> {
|
|
12
|
+
constructor(cause: Cause<E>) {
|
|
13
|
+
super(cause, "Message")
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const reportQueueError_ = reportError(cause => new MessageException(cause))
|
|
18
|
+
|
|
19
|
+
export const reportQueueError = (cause: Cause<unknown>, context?: Record<string, unknown> | undefined) =>
|
|
20
|
+
RequestContext.Tag.accessWithEffect(requestContext =>
|
|
21
|
+
Effect(reportQueueError_(cause, { requestContext, ...context }))
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Forks the effect into a new fiber attached to the global scope. Because the
|
|
26
|
+
* new fiber is attached to the global scope, when the fiber executing the
|
|
27
|
+
* returned effect terminates, the forked fiber will continue running.
|
|
28
|
+
*
|
|
29
|
+
* Reports errors.
|
|
30
|
+
*
|
|
31
|
+
* @tsplus getter effect/io/Effect forkDaemonReportQueue
|
|
32
|
+
*/
|
|
33
|
+
export function forkDaemonReportQueue<R, E, A>(self: Effect<R, E, A>) {
|
|
34
|
+
return self.tapErrorCause(reportQueueError).fork.daemonChildren
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export const reportFatalQueueError = reportError(
|
|
38
|
+
cause => new FatalQueueException(cause)
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
export function reportFailure(name: string) {
|
|
42
|
+
return <R, E, A>(self: Effect<R, E, A>) =>
|
|
43
|
+
self.exit.tap(exit =>
|
|
44
|
+
exit._tag === "Failure"
|
|
45
|
+
? reportFatalQueueError(exit.cause, { name })
|
|
46
|
+
: Effect.unit
|
|
47
|
+
)
|
|
48
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { MemQueue } from "@effect-app/infra-adapters/memQueue"
|
|
2
|
+
import { RequestContext } from "@effect-app/infra/RequestContext"
|
|
3
|
+
import type { CustomSchemaException } from "@effect-app/prelude/schema"
|
|
4
|
+
import { reportFailure, reportQueueError } from "./errors.js"
|
|
5
|
+
import type { QueueBase } from "./service.js"
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @tsplus static QueueMaker.Ops makeMem
|
|
9
|
+
*/
|
|
10
|
+
export function makeMemQueue<DrainR, Evt, DrainEvt extends { id: StringId; _tag: string }, RContext, EvtE, DrainE>(
|
|
11
|
+
queueName: string,
|
|
12
|
+
queueDrainName: string,
|
|
13
|
+
encoder: (e: { body: Evt; meta: RequestContext }) => EvtE,
|
|
14
|
+
makeHandleEvent: Effect<DrainR, never, (ks: DrainEvt) => Effect<RContext, DrainE, void>>,
|
|
15
|
+
provideContext: (context: RequestContext) => <R, E, A>(
|
|
16
|
+
eff: Effect<RContext | R, E, A>
|
|
17
|
+
) => Effect<Exclude<R, RContext>, E, A>,
|
|
18
|
+
parseDrain: (
|
|
19
|
+
a: unknown,
|
|
20
|
+
env?: Parser.ParserEnv | undefined
|
|
21
|
+
) => Effect<never, CustomSchemaException, { body: DrainEvt; meta: RequestContext }>
|
|
22
|
+
) {
|
|
23
|
+
return Effect.gen(function*($) {
|
|
24
|
+
const mem = yield* $(MemQueue.access)
|
|
25
|
+
const q = yield* $(mem.getOrCreateQueue(queueName))
|
|
26
|
+
const qReply = yield* $(mem.getOrCreateQueue(queueDrainName))
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
publish: (...messages) =>
|
|
30
|
+
Effect.gen(function*($) {
|
|
31
|
+
const requestContext = yield* $(RequestContext.Tag.access)
|
|
32
|
+
return yield* $(
|
|
33
|
+
messages.forEachEffect(m =>
|
|
34
|
+
// we JSON encode, because that is what the wire also does, and it reveals holes in e.g unknown encoders (Date->String)
|
|
35
|
+
Effect(() =>
|
|
36
|
+
JSON.stringify(
|
|
37
|
+
encoder({ body: m, meta: requestContext })
|
|
38
|
+
)
|
|
39
|
+
)
|
|
40
|
+
// .tap((msg) => info("Publishing Mem Message: " + utils.inspect(msg)))
|
|
41
|
+
.flatMap(_ => q.offer(_))
|
|
42
|
+
.asUnit
|
|
43
|
+
)
|
|
44
|
+
.forkDaemonReportQueue
|
|
45
|
+
)
|
|
46
|
+
}),
|
|
47
|
+
drain: Effect.gen(function*($) {
|
|
48
|
+
const handleEvent = yield* $(makeHandleEvent)
|
|
49
|
+
const processMessage = (msg: string) =>
|
|
50
|
+
// we JSON parse, because that is what the wire also does, and it reveals holes in e.g unknown encoders (Date->String)
|
|
51
|
+
Effect(() => JSON.parse(msg))
|
|
52
|
+
.flatMap(parseDrain)
|
|
53
|
+
.orDie
|
|
54
|
+
.flatMap(({ body, meta }) =>
|
|
55
|
+
Effect
|
|
56
|
+
.logDebug(`$$ [${queueDrainName}] Processing incoming message`)
|
|
57
|
+
.apply(Effect.logAnnotates({ body: body.$$.pretty, meta: meta.$$.pretty }))
|
|
58
|
+
.zipRight(silence(handleEvent(body)))
|
|
59
|
+
.apply(
|
|
60
|
+
provideContext(
|
|
61
|
+
RequestContext.inherit(meta, {
|
|
62
|
+
id: body.id,
|
|
63
|
+
locale: "en" as const,
|
|
64
|
+
name: ReasonableString(body._tag)
|
|
65
|
+
})
|
|
66
|
+
)
|
|
67
|
+
)
|
|
68
|
+
)
|
|
69
|
+
return yield* $(
|
|
70
|
+
qReply.take()
|
|
71
|
+
.flatMap(x => processMessage(x).uninterruptible)
|
|
72
|
+
.forever
|
|
73
|
+
.apply(reportFailure("drain"))
|
|
74
|
+
.setupRequestFromWith("Queue.ReceiveMessage")
|
|
75
|
+
.forkScoped
|
|
76
|
+
)
|
|
77
|
+
})
|
|
78
|
+
} satisfies QueueBase<DrainR, Evt>
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// We want the Queue to continue processing even on errors per messages
|
|
83
|
+
// must make sure that the errors are processed/handled beforehand.
|
|
84
|
+
export function silence<R, E, A>(inp: Effect<R, E, A>) {
|
|
85
|
+
return inp.exit.flatMap(result =>
|
|
86
|
+
Effect.gen(function*($) {
|
|
87
|
+
const requestContext = yield* $(RequestContext.Tag.access)
|
|
88
|
+
return yield* $(
|
|
89
|
+
result.match(
|
|
90
|
+
cause => {
|
|
91
|
+
if (cause.isInterrupted()) {
|
|
92
|
+
return (cause as Cause<never>).failCause
|
|
93
|
+
}
|
|
94
|
+
reportQueueError(cause, { requestContext })
|
|
95
|
+
return Effect.unit
|
|
96
|
+
},
|
|
97
|
+
() => Effect.unit
|
|
98
|
+
)
|
|
99
|
+
)
|
|
100
|
+
})
|
|
101
|
+
)
|
|
102
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import {
|
|
2
|
+
LiveReceiver,
|
|
3
|
+
LiveSender,
|
|
4
|
+
LiveServiceBusClient,
|
|
5
|
+
Receiver,
|
|
6
|
+
Sender,
|
|
7
|
+
subscribe
|
|
8
|
+
} from "@effect-app/infra-adapters/ServiceBus"
|
|
9
|
+
import type {} from "@azure/service-bus"
|
|
10
|
+
import { captureException } from "@effect-app/infra/errorReporter"
|
|
11
|
+
import { RequestContext } from "@effect-app/infra/RequestContext"
|
|
12
|
+
import type { CustomSchemaException } from "@effect-app/prelude/schema"
|
|
13
|
+
import { reportQueueError } from "./errors.js"
|
|
14
|
+
import type { QueueBase } from "./service.js"
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* @tsplus static QueueMaker.Ops makeServiceBus
|
|
18
|
+
*/
|
|
19
|
+
export function makeServiceBusQueue<
|
|
20
|
+
DrainR,
|
|
21
|
+
Evt extends { id: StringId; _tag: string },
|
|
22
|
+
DrainEvt extends { id: StringId; _tag: string },
|
|
23
|
+
RContext,
|
|
24
|
+
EvtE,
|
|
25
|
+
DrainE
|
|
26
|
+
>(
|
|
27
|
+
_queueName: string,
|
|
28
|
+
queueDrainName: string,
|
|
29
|
+
encoder: (e: { body: Evt; meta: RequestContext }) => EvtE,
|
|
30
|
+
makeHandleEvent: Effect<DrainR, never, (ks: DrainEvt) => Effect<RContext, DrainE, void>>,
|
|
31
|
+
provideContext: (context: RequestContext) => <R, E, A>(
|
|
32
|
+
eff: Effect<RContext | R, E, A>
|
|
33
|
+
) => Effect<Exclude<R, RContext>, E, A>,
|
|
34
|
+
parseDrain: (
|
|
35
|
+
a: unknown,
|
|
36
|
+
env?: Parser.ParserEnv | undefined
|
|
37
|
+
) => Effect<never, CustomSchemaException, { body: DrainEvt; meta: RequestContext }>
|
|
38
|
+
) {
|
|
39
|
+
return Effect.gen(function*($) {
|
|
40
|
+
const s = yield* $(Sender.access)
|
|
41
|
+
const receiver = yield* $(Receiver.access)
|
|
42
|
+
const receiverLayer = Receiver.makeLayer(receiver)
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
drain: Effect.gen(function*($) {
|
|
46
|
+
const handleEvent = yield* $(makeHandleEvent)
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
48
|
+
function processMessage(messageBody: any) {
|
|
49
|
+
return Effect.sync(() => JSON.parse(messageBody))
|
|
50
|
+
.flatMap(x => parseDrain(x))
|
|
51
|
+
.orDie
|
|
52
|
+
.tapErrorCause(report)
|
|
53
|
+
.flatMap(({ body, meta }) =>
|
|
54
|
+
Effect
|
|
55
|
+
.logDebug(`$$ [${queueDrainName}] Processing incoming message`)
|
|
56
|
+
.apply(Effect.logAnnotates({ body: body.$$.pretty, meta: meta.$$.pretty }))
|
|
57
|
+
.zipRight(handleEvent(body))
|
|
58
|
+
.tapErrorCause(report)
|
|
59
|
+
.apply(
|
|
60
|
+
provideContext(
|
|
61
|
+
RequestContext.inherit(meta, {
|
|
62
|
+
id: body.id,
|
|
63
|
+
locale: "en" as const,
|
|
64
|
+
name: ReasonableString(body._tag)
|
|
65
|
+
})
|
|
66
|
+
)
|
|
67
|
+
)
|
|
68
|
+
)
|
|
69
|
+
.setupRequestFromWith("Queue.ReceiveMessage")
|
|
70
|
+
.orDie
|
|
71
|
+
.asUnit
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return yield* $(
|
|
75
|
+
subscribe({
|
|
76
|
+
processMessage: x => processMessage(x.body).uninterruptible,
|
|
77
|
+
processError: err => Effect(captureException(err.error))
|
|
78
|
+
})
|
|
79
|
+
.provideSomeLayer(receiverLayer)
|
|
80
|
+
)
|
|
81
|
+
}),
|
|
82
|
+
|
|
83
|
+
publish: (...messages) =>
|
|
84
|
+
Effect.gen(function*($) {
|
|
85
|
+
const requestContext = yield* $(RequestContext.Tag.access)
|
|
86
|
+
return yield* $(
|
|
87
|
+
Effect.promise(() =>
|
|
88
|
+
s.sendMessages(
|
|
89
|
+
messages.map(x => ({
|
|
90
|
+
body: JSON.stringify(
|
|
91
|
+
encoder({ body: x, meta: requestContext })
|
|
92
|
+
),
|
|
93
|
+
messageId: x.id, /* correllationid: requestId */
|
|
94
|
+
contentType: "application/json"
|
|
95
|
+
}))
|
|
96
|
+
)
|
|
97
|
+
)
|
|
98
|
+
.forkDaemonReportQueue
|
|
99
|
+
)
|
|
100
|
+
})
|
|
101
|
+
} satisfies QueueBase<DrainR, Evt>
|
|
102
|
+
})
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* @tsplus static QueueMaker.Ops makeServiceBusLayers
|
|
107
|
+
*/
|
|
108
|
+
export function makeServiceBusLayers(url: string, queueName: string, queueDrainName: string) {
|
|
109
|
+
return LiveServiceBusClient(url)
|
|
110
|
+
>> (LiveReceiver(queueDrainName) + LiveSender(queueName))
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function report<E>(cause: Cause<E>) {
|
|
114
|
+
return Effect.gen(function*($) {
|
|
115
|
+
const requestContext = yield* $(RequestContext.Tag.access)
|
|
116
|
+
return reportQueueError(cause, { requestContext })
|
|
117
|
+
})
|
|
118
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { RequestContext } from "@effect-app/infra/RequestContext"
|
|
2
|
+
|
|
3
|
+
export interface QueueBase<RContext, Evt> {
|
|
4
|
+
drain: Effect<Scope | RContext, never, void>
|
|
5
|
+
publish: (
|
|
6
|
+
...messages: NonEmptyReadonlyArray<Evt>
|
|
7
|
+
) => Effect<RequestContext, never, void>
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @tsplus type QueueMaker.Ops
|
|
12
|
+
*/
|
|
13
|
+
export interface QueueMakerOps {}
|
|
14
|
+
export const QueueMaker: QueueMakerOps = {}
|
package/dist/_global.ext.d.ts
CHANGED
|
@@ -10,6 +10,10 @@ import type {} from "@effect-app/infra/services/Emailer/Sendgrid";
|
|
|
10
10
|
* @tsplus global
|
|
11
11
|
*/
|
|
12
12
|
import type {} from "@effect-app/infra/services/Operations/live";
|
|
13
|
+
/**
|
|
14
|
+
* @tsplus global
|
|
15
|
+
*/
|
|
16
|
+
import type {} from "@effect-app/infra/services/QueueMaker/errors";
|
|
13
17
|
/**
|
|
14
18
|
* @tsplus global
|
|
15
19
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_global.ext.d.ts","sourceRoot":"","sources":["../_src/_global.ext.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,MAAM,yCAAyC,CAAA;AAC7D;;GAEG;AACH,OAAO,KAAK,EAAE,MAAM,6CAA6C,CAAA;AACjE;;GAEG;AACH,OAAO,KAAK,EAAE,MAAM,4CAA4C,CAAA;AAChE;;GAEG;AACH,OAAO,KAAK,EAAE,MAAM,6BAA6B,CAAA;AACjD;;GAEG;AACH,OAAO,KAAK,EAAE,MAAM,8BAA8B,CAAA;AAClD;;GAEG;AACH,OAAO,KAAK,EAAE,MAAM,8BAA8B,CAAA;AAClD;;GAEG;AACH,OAAO,KAAK,EAAE,MAAM,6BAA6B,CAAA;AAEjD;;GAEG;AACH,OAAO,KAAK,EAAE,MAAM,oCAAoC,CAAA;AAExD;;GAEG;AACH,OAAO,EAAE,MAAM,mCAAmC,CAAA"}
|
|
1
|
+
{"version":3,"file":"_global.ext.d.ts","sourceRoot":"","sources":["../_src/_global.ext.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,MAAM,yCAAyC,CAAA;AAC7D;;GAEG;AACH,OAAO,KAAK,EAAE,MAAM,6CAA6C,CAAA;AACjE;;GAEG;AACH,OAAO,KAAK,EAAE,MAAM,4CAA4C,CAAA;AAChE;;GAEG;AACH,OAAO,KAAK,EAAE,MAAM,8CAA8C,CAAA;AAClE;;GAEG;AACH,OAAO,KAAK,EAAE,MAAM,6BAA6B,CAAA;AACjD;;GAEG;AACH,OAAO,KAAK,EAAE,MAAM,8BAA8B,CAAA;AAClD;;GAEG;AACH,OAAO,KAAK,EAAE,MAAM,8BAA8B,CAAA;AAClD;;GAEG;AACH,OAAO,KAAK,EAAE,MAAM,6BAA6B,CAAA;AAEjD;;GAEG;AACH,OAAO,KAAK,EAAE,MAAM,oCAAoC,CAAA;AAExD;;GAEG;AACH,OAAO,EAAE,MAAM,mCAAmC,CAAA"}
|
|
@@ -10,4 +10,9 @@ export declare function setupRequest<R, E, A>(self: Effect<R, E, A>, requestCont
|
|
|
10
10
|
* @tsplus location "@effect-app/infra/api/setupRequest"
|
|
11
11
|
*/
|
|
12
12
|
export declare function setupRequestFrom<R, E, A>(self: Effect<R, E, A>): import("@effect/io/Effect").Effect<RequestContext | R, E, A>;
|
|
13
|
+
/**
|
|
14
|
+
* @tsplus fluent effect/io/Effect setupRequestFromWith
|
|
15
|
+
* @tsplus location "@effect-app/infra/api/setupRequest"
|
|
16
|
+
*/
|
|
17
|
+
export declare function setupReq3<R, E, A>(self: Effect<R, E, A>, name: string): import("@effect/io/Effect").Effect<Exclude<R, RequestContext>, E, A>;
|
|
13
18
|
//# sourceMappingURL=setupRequest.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setupRequest.d.ts","sourceRoot":"","sources":["../../_src/api/setupRequest.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;;;;;AAKrD,wBAAgB,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,cAAc,EAAE,cAAc,+CAS1F;;;;;AAKD,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,gEAE9D"}
|
|
1
|
+
{"version":3,"file":"setupRequest.d.ts","sourceRoot":"","sources":["../../_src/api/setupRequest.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;;;;;AAKrD,wBAAgB,YAAY,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,cAAc,EAAE,cAAc,+CAS1F;;;;;AAKD,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,gEAE9D;;;;;AAKD,wBAAgB,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,wEAIrE"}
|
package/dist/api/setupRequest.js
CHANGED
|
@@ -2,8 +2,10 @@ import * as tsplus_module_1 from "@effect/io/Effect";
|
|
|
2
2
|
import * as tsplus_module_2 from "@effect-app/prelude/_ext/misc";
|
|
3
3
|
import * as tsplus_module_3 from "@effect-app/core/Function";
|
|
4
4
|
import * as tsplus_module_4 from "@effect-app/infra/RequestContext";
|
|
5
|
+
import * as tsplus_module_5 from "@effect-app/prelude/schema";
|
|
5
6
|
export const setupRequest = setupRequest_1;
|
|
6
|
-
|
|
7
|
+
export const setupRequestFrom = setupRequestFrom_1;
|
|
8
|
+
import { RequestContext } from "../RequestContext.js";
|
|
7
9
|
/**
|
|
8
10
|
* @tsplus fluent effect/io/Effect setupRequest
|
|
9
11
|
*/
|
|
@@ -17,7 +19,22 @@ function setupRequest_1(self, requestContext) {
|
|
|
17
19
|
/**
|
|
18
20
|
* @tsplus getter effect/io/Effect setupRequestFrom
|
|
19
21
|
*/
|
|
20
|
-
|
|
22
|
+
function setupRequestFrom_1(self) {
|
|
21
23
|
return tsplus_module_1.serviceWithEffect(tsplus_module_4.tag, requestContext => setupRequest_1(self, requestContext));
|
|
22
24
|
}
|
|
23
|
-
|
|
25
|
+
/**
|
|
26
|
+
* @tsplus fluent effect/io/Effect setupRequestFromWith
|
|
27
|
+
*/
|
|
28
|
+
export function setupReq3(self, name) {
|
|
29
|
+
return tsplus_module_1.provideService(setupRequestFrom_1(self), tsplus_module_4.tag, makeInternalRequestContext(name));
|
|
30
|
+
}
|
|
31
|
+
function makeInternalRequestContext(name) {
|
|
32
|
+
const id = tsplus_module_5.StringId.make();
|
|
33
|
+
return new RequestContext({
|
|
34
|
+
id,
|
|
35
|
+
rootId: id,
|
|
36
|
+
locale: "en",
|
|
37
|
+
name: tsplus_module_5.ReasonableString(name)
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2V0dXBSZXF1ZXN0LmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vX3NyYy9hcGkvc2V0dXBSZXF1ZXN0LnRzIl0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BQ0osQ0FBQyJ9
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Cause } from "@effect/io/Cause";
|
|
2
|
+
import { Effect } from "@effect/io/Effect";
|
|
3
|
+
import { CauseException } from "@effect-app/infra/errors";
|
|
4
|
+
import { RequestContext } from "@effect-app/infra/RequestContext";
|
|
5
|
+
export declare class MessageException<E> extends CauseException<E> {
|
|
6
|
+
constructor(cause: Cause<E>);
|
|
7
|
+
}
|
|
8
|
+
export declare class FatalQueueException<E> extends CauseException<E> {
|
|
9
|
+
constructor(cause: Cause<E>);
|
|
10
|
+
}
|
|
11
|
+
export declare const reportQueueError: (cause: Cause<unknown>, context?: Record<string, unknown> | undefined) => import("@effect/io/Effect").Effect<RequestContext, never, import("@effect/io/Effect").Effect<never, never, void>>;
|
|
12
|
+
/**
|
|
13
|
+
* Forks the effect into a new fiber attached to the global scope. Because the
|
|
14
|
+
* new fiber is attached to the global scope, when the fiber executing the
|
|
15
|
+
* returned effect terminates, the forked fiber will continue running.
|
|
16
|
+
*
|
|
17
|
+
* Reports errors.
|
|
18
|
+
* @tsplus getter effect/io/Effect forkDaemonReportQueue
|
|
19
|
+
* @tsplus location "@effect-app/infra/services/QueueMaker/errors"
|
|
20
|
+
*/
|
|
21
|
+
export declare function forkDaemonReportQueue<R, E, A>(self: Effect<R, E, A>): import("@effect/io/Effect").Effect<RequestContext | R, never, import("@effect/io/Fiber").RuntimeFiber<E, A>>;
|
|
22
|
+
export declare const reportFatalQueueError: (cause: import("@effect/io/Cause").Cause<unknown>, context?: Record<string, unknown> | undefined) => import("@effect/io/Effect").Effect<never, never, void>;
|
|
23
|
+
export declare function reportFailure(name: string): <R, E, A>(self: import("@effect/io/Effect").Effect<R, E, A>) => import("@effect/io/Effect").Effect<R, never, import("@effect/io/Exit").Exit<E, A>>;
|
|
24
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../_src/services/QueueMaker/errors.ts"],"names":[],"mappings":";;AACA,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAA;AAEjE,qBAAa,gBAAgB,CAAC,CAAC,CAAE,SAAQ,cAAc,CAAC,CAAC,CAAC;gBAC5C,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;CAG5B;AAED,qBAAa,mBAAmB,CAAC,CAAC,CAAE,SAAQ,cAAc,CAAC,CAAC,CAAC;gBAC/C,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;CAG5B;AAID,eAAO,MAAM,gBAAgB,UAAW,MAAM,OAAO,CAAC,YAAY,OAAO,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,sHAGlG,CAAA;;;;;;;;;;AAWH,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,gHAEnE;AAED,eAAO,MAAM,qBAAqB,6JAEjC,CAAA;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,sJAOzC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import * as tsplus_module_1 from "@effect/io/Effect";
|
|
2
|
+
import * as tsplus_module_2 from "@effect-app/infra/RequestContext";
|
|
3
|
+
import * as tsplus_module_3 from "@effect-app/core/Effect";
|
|
4
|
+
import { reportError } from "@effect-app/infra/errorReporter";
|
|
5
|
+
import { CauseException } from "@effect-app/infra/errors";
|
|
6
|
+
import "@effect-app/infra/RequestContext";
|
|
7
|
+
export class MessageException extends CauseException {
|
|
8
|
+
constructor(cause) {
|
|
9
|
+
super(cause, "Message");
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export class FatalQueueException extends CauseException {
|
|
13
|
+
constructor(cause) {
|
|
14
|
+
super(cause, "Message");
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
const reportQueueError_ = reportError(cause => new MessageException(cause));
|
|
18
|
+
export const reportQueueError = (cause, context) => tsplus_module_1.serviceWithEffect(tsplus_module_2.tag, requestContext => tsplus_module_1.sync(() => reportQueueError_(cause, { requestContext, ...context })));
|
|
19
|
+
/**
|
|
20
|
+
* Forks the effect into a new fiber attached to the global scope. Because the
|
|
21
|
+
* new fiber is attached to the global scope, when the fiber executing the
|
|
22
|
+
* returned effect terminates, the forked fiber will continue running.
|
|
23
|
+
*
|
|
24
|
+
* Reports errors.
|
|
25
|
+
*
|
|
26
|
+
* @tsplus getter effect/io/Effect forkDaemonReportQueue
|
|
27
|
+
*/
|
|
28
|
+
export function forkDaemonReportQueue(self) {
|
|
29
|
+
return tsplus_module_1.daemonChildren(tsplus_module_1.fork(tsplus_module_1.tapErrorCause(self, reportQueueError)));
|
|
30
|
+
}
|
|
31
|
+
export const reportFatalQueueError = reportError(cause => new FatalQueueException(cause));
|
|
32
|
+
export function reportFailure(name) {
|
|
33
|
+
return (self) => tsplus_module_1.tap(tsplus_module_1.exit(self), exit => exit._tag === "Failure"
|
|
34
|
+
? reportFatalQueueError(exit.cause, { name })
|
|
35
|
+
: tsplus_module_3.unit);
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZXJyb3JzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vX3NyYy9zZXJ2aWNlcy9RdWV1ZU1ha2VyL2Vycm9ycy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7QUFBQSxPQUFPLEVBQUUsV0FBVyxFQUFFLE1BQU0saUNBQWlDLENBQUE7QUFDN0QsT0FBTyxFQUFFLGNBQWMsRUFBRSxNQUFNLDBCQUEwQixDQUFBO0FBQ3pELE9BQStCLGtDQUFrQyxDQUFBO0FBRWpFLE1BQU0sT0FBTyxnQkFBb0IsU0FBUSxjQUFpQjtJQUN4RC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UUFDckIsQ0FBQyxDQUFDLHFCQUFxQixDQUFDLElBQUksQ0FBQyxLQUFLLEVBQUUsRUFBRSxJQUFJLEVBQUUsQ0FBQztRQUM3QyxDQUFDLHFCQUFZLENBQ2hCLENBQUE7QUFDTCxDQUFDIn0=
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { StringId, Parser } from "@effect-app/prelude/schema";
|
|
2
|
+
import { Effect } from "@effect/io/Effect";
|
|
3
|
+
import { Cause } from "@effect/io/Cause";
|
|
4
|
+
import { MemQueue } from "@effect-app/infra-adapters/memQueue";
|
|
5
|
+
import { RequestContext } from "@effect-app/infra/RequestContext";
|
|
6
|
+
import type { CustomSchemaException } from "@effect-app/prelude/schema";
|
|
7
|
+
/**
|
|
8
|
+
* @tsplus static QueueMaker.Ops makeMem
|
|
9
|
+
* @tsplus location "@effect-app/infra/services/QueueMaker/memQueue"
|
|
10
|
+
*/
|
|
11
|
+
export declare function makeMemQueue<DrainR, Evt, DrainEvt extends {
|
|
12
|
+
id: StringId;
|
|
13
|
+
_tag: string;
|
|
14
|
+
}, RContext, EvtE, DrainE>(queueName: string, queueDrainName: string, encoder: (e: {
|
|
15
|
+
body: Evt;
|
|
16
|
+
meta: RequestContext;
|
|
17
|
+
}) => EvtE, makeHandleEvent: Effect<DrainR, never, (ks: DrainEvt) => Effect<RContext, DrainE, void>>, provideContext: (context: RequestContext) => <R, E, A>(eff: Effect<RContext | R, E, A>) => Effect<Exclude<R, RContext>, E, A>, parseDrain: (a: unknown, env?: Parser.ParserEnv | undefined) => Effect<never, CustomSchemaException, {
|
|
18
|
+
body: DrainEvt;
|
|
19
|
+
meta: RequestContext;
|
|
20
|
+
}>): import("@effect/io/Effect").Effect<MemQueue, never, {
|
|
21
|
+
publish: (messages_0: Evt, ...messages_1: Evt[]) => import("@effect/io/Effect").Effect<RequestContext, never, import("@effect/io/Fiber").RuntimeFiber<never, import("@fp-ts/data/Chunk").Chunk<void>>>;
|
|
22
|
+
drain: import("@effect/io/Effect").Effect<import("@effect/io/Scope").Scope | DrainR, never, import("@effect/io/Fiber").RuntimeFiber<never, import("@effect/io/Exit").Exit<never, never>>>;
|
|
23
|
+
}>;
|
|
24
|
+
export declare function silence<R, E, A>(inp: Effect<R, E, A>): import("@effect/io/Effect").Effect<RequestContext | R, never, void>;
|
|
25
|
+
//# sourceMappingURL=memQueue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memQueue.d.ts","sourceRoot":"","sources":["../../../_src/services/QueueMaker/memQueue.ts"],"names":[],"mappings":";;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,qCAAqC,CAAA;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAA;AACjE,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;;;;;AAOvE,wBAAgB,YAAY,CAAC,MAAM,EAAE,GAAG,EAAE,QAAQ,SAAS;IAAE,EAAE,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAC/G,SAAS,EAAE,MAAM,EACjB,cAAc,EAAE,MAAM,EACtB,OAAO,EAAE,CAAC,CAAC,EAAE;IAAE,IAAI,EAAE,GAAG,CAAC;IAAC,IAAI,EAAE,cAAc,CAAA;CAAE,KAAK,IAAI,EACzD,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,QAAQ,KAAK,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,EACxF,cAAc,EAAE,CAAC,OAAO,EAAE,cAAc,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EACnD,GAAG,EAAE,MAAM,CAAC,QAAQ,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAC5B,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EACvC,UAAU,EAAE,CACV,CAAC,EAAE,OAAO,EACV,GAAG,CAAC,EAAE,MAAM,CAAC,SAAS,GAAG,SAAS,KAC/B,MAAM,CAAC,KAAK,EAAE,qBAAqB,EAAE;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,IAAI,EAAE,cAAc,CAAA;CAAE,CAAC;;;GA2DpF;AAID,wBAAgB,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,uEAkBpD"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import * as tsplus_module_1 from "@effect/io/Effect";
|
|
2
|
+
import * as tsplus_module_2 from "@effect-app/infra/RequestContext";
|
|
3
|
+
import * as tsplus_module_3 from "@effect-app/core/_ext/Iterable";
|
|
4
|
+
import * as tsplus_module_4 from "@effect-app/infra/services/QueueMaker/errors";
|
|
5
|
+
import * as tsplus_module_5 from "@effect-app/prelude/utils";
|
|
6
|
+
import * as tsplus_module_6 from "@effect-app/prelude/_ext/misc";
|
|
7
|
+
import * as tsplus_module_7 from "@effect-app/prelude/schema";
|
|
8
|
+
import * as tsplus_module_8 from "@effect-app/infra/api/setupRequest";
|
|
9
|
+
import * as tsplus_module_9 from "@effect/io/Cause";
|
|
10
|
+
import * as tsplus_module_10 from "@effect-app/core/Effect";
|
|
11
|
+
import * as tsplus_module_11 from "@effect/io/Exit";
|
|
12
|
+
import { MemQueue } from "@effect-app/infra-adapters/memQueue";
|
|
13
|
+
import { RequestContext } from "@effect-app/infra/RequestContext";
|
|
14
|
+
import { reportFailure, reportQueueError } from "./errors.js";
|
|
15
|
+
/**
|
|
16
|
+
* @tsplus static QueueMaker.Ops makeMem
|
|
17
|
+
*/
|
|
18
|
+
export function makeMemQueue(queueName, queueDrainName, encoder, makeHandleEvent, provideContext, parseDrain) {
|
|
19
|
+
return tsplus_module_1.gen(function* ($) {
|
|
20
|
+
const mem = yield* $(tsplus_module_1.service(MemQueue));
|
|
21
|
+
const q = yield* $(mem.getOrCreateQueue(queueName));
|
|
22
|
+
const qReply = yield* $(mem.getOrCreateQueue(queueDrainName));
|
|
23
|
+
return {
|
|
24
|
+
publish: (...messages) => tsplus_module_1.gen(function* ($) {
|
|
25
|
+
const requestContext = yield* $(tsplus_module_1.service(tsplus_module_2.tag));
|
|
26
|
+
return yield* $(tsplus_module_4.forkDaemonReportQueue(tsplus_module_3.ext_forEach(messages, m => tsplus_module_1.asUnit(
|
|
27
|
+
// we JSON encode, because that is what the wire also does, and it reveals holes in e.g unknown encoders (Date->String)
|
|
28
|
+
tsplus_module_1.flatMap(tsplus_module_1.sync(() => JSON.stringify(encoder({ body: m, meta: requestContext })))
|
|
29
|
+
// .tap((msg) => info("Publishing Mem Message: " + utils.inspect(msg)))
|
|
30
|
+
, _ => q.offer(_))))));
|
|
31
|
+
}),
|
|
32
|
+
drain: tsplus_module_1.gen(function* ($) {
|
|
33
|
+
const handleEvent = yield* $(makeHandleEvent);
|
|
34
|
+
const processMessage = (msg) =>
|
|
35
|
+
// we JSON parse, because that is what the wire also does, and it reveals holes in e.g unknown encoders (Date->String)
|
|
36
|
+
tsplus_module_1.flatMap(tsplus_module_1.orDie(tsplus_module_1.flatMap(tsplus_module_1.sync(() => JSON.parse(msg)), parseDrain)), ({ body, meta }) => provideContext(RequestContext.inherit(meta, {
|
|
37
|
+
id: body.id,
|
|
38
|
+
locale: "en",
|
|
39
|
+
name: tsplus_module_7.ReasonableString(body._tag)
|
|
40
|
+
}))(tsplus_module_1.zipRight(tsplus_module_6.logAnnotates({ body: tsplus_module_5.RecordPretty(tsplus_module_5.object$(body)), meta: tsplus_module_5.RecordPretty(tsplus_module_5.object$(meta)) })(tsplus_module_1.logDebug(`$$ [${queueDrainName}] Processing incoming message`)), silence(handleEvent(body)))));
|
|
41
|
+
return yield* $(tsplus_module_1.forkScoped(tsplus_module_8.setupReq3(reportFailure("drain")(tsplus_module_1.forever(tsplus_module_1.flatMap(qReply.take(), x => tsplus_module_1.uninterruptible(processMessage(x))))), "Queue.ReceiveMessage")));
|
|
42
|
+
})
|
|
43
|
+
};
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
// We want the Queue to continue processing even on errors per messages
|
|
47
|
+
// must make sure that the errors are processed/handled beforehand.
|
|
48
|
+
export function silence(inp) {
|
|
49
|
+
return tsplus_module_1.flatMap(tsplus_module_1.exit(inp), result => tsplus_module_1.gen(function* ($) {
|
|
50
|
+
const requestContext = yield* $(tsplus_module_1.service(tsplus_module_2.tag));
|
|
51
|
+
return yield* $(tsplus_module_11.match(result, cause => {
|
|
52
|
+
if (tsplus_module_9.isInterrupted(cause)) {
|
|
53
|
+
return tsplus_module_1.failCause(cause);
|
|
54
|
+
}
|
|
55
|
+
reportQueueError(cause, { requestContext });
|
|
56
|
+
return tsplus_module_10.unit;
|
|
57
|
+
}, () => tsplus_module_10.unit));
|
|
58
|
+
}));
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWVtUXVldWUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9fc3JjL3NlcnZpY2VzL1F1ZXVlTWFrZXIvbWVtUXVldWUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7Ozs7Ozs7QUFBQSxPQUFPLEVBQUUsUUFBUSxFQUFFLE1BQU0scUNBQXFDLENBQUE7QUFDOUQsT0FBTyxFQUFFLGNBQWMsRUFBRSxNQUFNLGtDQUFrQyxDQUFBO0FBRWpFLE9BQU8sRUFBRSxhQUFhLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxhQUFhLENBQUE7QUFHN0Q7O0dBRUc7QUFDSCxNQUFNLFVBQVUsWUFBWSxDQUMxQixTQUFpQixFQUNqQixjQUFzQixFQUN0QixPQUF5RCxFQUN6RCxlQUF3RixFQUN4RixjQUV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zFCLHNCQUFzQixDQUFDLEVBRWhELENBQUE7WUFDSCxDQUFDLENBQUM7U0FDOEIsQ0FBQTtJQUNwQyxDQUFDLENBQUMsQ0FBQTtBQUNKLENBQUM7QUFFRCx1RUFBdUU7QUFDdkUsbUVBQW1FO0FBQ25FLE1BQU0sVUFBVSxPQUFPLENBQVUsR0FBb0I7SUFDbkQsT0FBTyw2Q0FBQSxHQUFHLEdBQWMsTUFBTSxDQUFDLEVBQUUsQ0FDL0Isb0JBQVcsUUFBUSxDQUFDLEVBQUMsQ0FBQztRQUNwQixNQUFNLGNBQWMsR0FBRyxLQUFLLENBQUMsQ0FBQyxDQUFDLDhDQUEyQixDQUFBO1FBQzFELE9BQU8sS0FBSyxDQUFDLENBQUMsQ0FBQyxDQUNiLHVCQUFBLE1BQU0sRUFDSixLQUFLLENBQUMsRUFBRTtZQUNOLElBQUksOEJBQUEsS0FBSyxDQUFnQixFQUFFO2dCQUN6QixpQ0FBUSxLQUFzQixFQUFVO2FBQ3pDO1lBQ0QsZ0JBQWdCLENBQUMsS0FBSyxFQUFFLEVBQUUsY0FBYyxFQUFFLENBQUMsQ0FBQTtZQUMzQyw2QkFBa0I7UUFDcEIsQ0FBQyxFQUNELEdBQUcsRUFBRSxzQkFBWSxDQUNsQixDQUNGLENBQUE7SUFDSCxDQUFDLENBQUMsQ0FDSCxDQUFBO0FBQ0gsQ0FBQyJ9
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { StringId, Parser } from "@effect-app/prelude/schema";
|
|
2
|
+
import { Effect } from "@effect/io/Effect";
|
|
3
|
+
import { Cause } from "@effect/io/Cause";
|
|
4
|
+
import { RequestContext } from "@effect-app/infra/RequestContext";
|
|
5
|
+
import type { CustomSchemaException } from "@effect-app/prelude/schema";
|
|
6
|
+
/**
|
|
7
|
+
* @tsplus static QueueMaker.Ops makeServiceBus
|
|
8
|
+
* @tsplus location "@effect-app/infra/services/QueueMaker/sbqueue"
|
|
9
|
+
*/
|
|
10
|
+
export declare function makeServiceBusQueue<DrainR, Evt extends {
|
|
11
|
+
id: StringId;
|
|
12
|
+
_tag: string;
|
|
13
|
+
}, DrainEvt extends {
|
|
14
|
+
id: StringId;
|
|
15
|
+
_tag: string;
|
|
16
|
+
}, RContext, EvtE, DrainE>(_queueName: string, queueDrainName: string, encoder: (e: {
|
|
17
|
+
body: Evt;
|
|
18
|
+
meta: RequestContext;
|
|
19
|
+
}) => EvtE, makeHandleEvent: Effect<DrainR, never, (ks: DrainEvt) => Effect<RContext, DrainE, void>>, provideContext: (context: RequestContext) => <R, E, A>(eff: Effect<RContext | R, E, A>) => Effect<Exclude<R, RContext>, E, A>, parseDrain: (a: unknown, env?: Parser.ParserEnv | undefined) => Effect<never, CustomSchemaException, {
|
|
20
|
+
body: DrainEvt;
|
|
21
|
+
meta: RequestContext;
|
|
22
|
+
}>): import("@effect/io/Effect").Effect<import("@azure/service-bus").ServiceBusReceiver | import("@azure/service-bus").ServiceBusSender, never, {
|
|
23
|
+
drain: import("@effect/io/Effect").Effect<import("@effect/io/Scope").Scope | DrainR, never, void>;
|
|
24
|
+
publish: (messages_0: Evt, ...messages_1: Evt[]) => import("@effect/io/Effect").Effect<RequestContext, never, import("@effect/io/Fiber").RuntimeFiber<never, void>>;
|
|
25
|
+
}>;
|
|
26
|
+
/**
|
|
27
|
+
* @tsplus static QueueMaker.Ops makeServiceBusLayers
|
|
28
|
+
* @tsplus location "@effect-app/infra/services/QueueMaker/sbqueue"
|
|
29
|
+
*/
|
|
30
|
+
export declare function makeServiceBusLayers(url: string, queueName: string, queueDrainName: string): import("@effect/io/Layer").Layer<never, never, import("@azure/service-bus").ServiceBusReceiver | import("@azure/service-bus").ServiceBusSender>;
|
|
31
|
+
//# sourceMappingURL=sbqueue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sbqueue.d.ts","sourceRoot":"","sources":["../../../_src/services/QueueMaker/sbqueue.ts"],"names":[],"mappings":";;;AAUA,OAAO,EAAE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
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import * as tsplus_module_1 from "@effect/io/Effect";
|
|
2
|
+
import * as tsplus_module_2 from "@effect-app/core/Tag";
|
|
3
|
+
import * as tsplus_module_3 from "@effect-app/prelude/utils";
|
|
4
|
+
import * as tsplus_module_4 from "@effect-app/prelude/_ext/misc";
|
|
5
|
+
import * as tsplus_module_5 from "@effect-app/prelude/schema";
|
|
6
|
+
import * as tsplus_module_6 from "@effect-app/infra/api/setupRequest";
|
|
7
|
+
import * as tsplus_module_7 from "@effect-app/infra/RequestContext";
|
|
8
|
+
import * as tsplus_module_8 from "@effect-app/infra/services/QueueMaker/errors";
|
|
9
|
+
import * as tsplus_module_9 from "@effect/io/Layer";
|
|
10
|
+
import { LiveReceiver, LiveSender, LiveServiceBusClient, Receiver, Sender, subscribe } from "@effect-app/infra-adapters/ServiceBus";
|
|
11
|
+
import { captureException } from "@effect-app/infra/errorReporter";
|
|
12
|
+
import { RequestContext } from "@effect-app/infra/RequestContext";
|
|
13
|
+
import { reportQueueError } from "./errors.js";
|
|
14
|
+
/**
|
|
15
|
+
* @tsplus static QueueMaker.Ops makeServiceBus
|
|
16
|
+
*/
|
|
17
|
+
export function makeServiceBusQueue(_queueName, queueDrainName, encoder, makeHandleEvent, provideContext, parseDrain) {
|
|
18
|
+
return tsplus_module_1.gen(function* ($) {
|
|
19
|
+
const s = yield* $(tsplus_module_1.service(Sender));
|
|
20
|
+
const receiver = yield* $(tsplus_module_1.service(Receiver));
|
|
21
|
+
const receiverLayer = tsplus_module_2.makeLayer(Receiver, receiver);
|
|
22
|
+
return {
|
|
23
|
+
drain: tsplus_module_1.gen(function* ($) {
|
|
24
|
+
const handleEvent = yield* $(makeHandleEvent);
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
|
+
function processMessage(messageBody) {
|
|
27
|
+
return tsplus_module_1.asUnit(tsplus_module_1.orDie(tsplus_module_6.setupReq3(tsplus_module_1.flatMap(tsplus_module_1.tapErrorCause(tsplus_module_1.orDie(tsplus_module_1.flatMap(tsplus_module_1.sync(() => JSON.parse(messageBody)), x => parseDrain(x))), report), ({ body, meta }) => provideContext(RequestContext.inherit(meta, {
|
|
28
|
+
id: body.id,
|
|
29
|
+
locale: "en",
|
|
30
|
+
name: tsplus_module_5.ReasonableString(body._tag)
|
|
31
|
+
}))(tsplus_module_1.tapErrorCause(tsplus_module_1.zipRight(tsplus_module_4.logAnnotates({ body: tsplus_module_3.RecordPretty(tsplus_module_3.object$(body)), meta: tsplus_module_3.RecordPretty(tsplus_module_3.object$(meta)) })(tsplus_module_1.logDebug(`$$ [${queueDrainName}] Processing incoming message`)), handleEvent(body)), report))), "Queue.ReceiveMessage")));
|
|
32
|
+
}
|
|
33
|
+
return yield* $(tsplus_module_1.provideSomeLayer(subscribe({
|
|
34
|
+
processMessage: x => tsplus_module_1.uninterruptible(processMessage(x.body)),
|
|
35
|
+
processError: err => tsplus_module_1.sync(() => captureException(err.error))
|
|
36
|
+
}), receiverLayer));
|
|
37
|
+
}),
|
|
38
|
+
publish: (...messages) => tsplus_module_1.gen(function* ($) {
|
|
39
|
+
const requestContext = yield* $(tsplus_module_1.service(tsplus_module_7.tag));
|
|
40
|
+
return yield* $(tsplus_module_8.forkDaemonReportQueue(tsplus_module_1.promise(() => s.sendMessages(messages.map(x => ({
|
|
41
|
+
body: JSON.stringify(encoder({ body: x, meta: requestContext })),
|
|
42
|
+
messageId: x.id,
|
|
43
|
+
contentType: "application/json"
|
|
44
|
+
}))))));
|
|
45
|
+
})
|
|
46
|
+
};
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* @tsplus static QueueMaker.Ops makeServiceBusLayers
|
|
51
|
+
*/
|
|
52
|
+
export function makeServiceBusLayers(url, queueName, queueDrainName) {
|
|
53
|
+
return tsplus_module_9.provide((tsplus_module_9.merge(LiveSender(queueName))(LiveReceiver(queueDrainName))))(LiveServiceBusClient(url));
|
|
54
|
+
}
|
|
55
|
+
function report(cause) {
|
|
56
|
+
return tsplus_module_1.gen(function* ($) {
|
|
57
|
+
const requestContext = yield* $(tsplus_module_1.service(tsplus_module_7.tag));
|
|
58
|
+
return reportQueueError(cause, { requestContext });
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2JxdWV1ZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL19zcmMvc2VydmljZXMvUXVldWVNYWtlci9zYnF1ZXVlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7Ozs7OztBQUFBLE9BQU8sRUFDTCxZQUFZLEVBQ1osVUFBVSxFQUNWLG9CQUFvQixFQUNwQixRQUFRLEVBQ1IsTUFBTSxFQUNOLFNBQVMsRUFDVixNQUFNLHVDQUF1QyxDQUFBO0FBRTlDLE9BQU8sRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLGlDQUFpQyxDQUFBO0FBQ2xFLE9BQU8sRUFBRSxjQUFjLEVBQUUsTUFBTSxrQ0FBa0MsQ0FBQTtBQUVqRSxPQUFPLEVBQUUsZ0JBQWdCLEVBQUUsTUFBTSxhQUFhLENBQUE7QUFHOUM7O0dBRUc7QUFDSCxNQUFNLFVBQVUsbUJBQW1CLENBUWpDLFVBQWtCLEVBQ2xCLGNBQXNCLEVBQ3RCLE9BQXlELEVBQ3pELGVBQXdGLEVBQ3hGLGNBRXVDLEVBQ3ZDLFVBR21GO0lBRW5GLE9BQU8sb0JBQVcsUUFBUSxDQUFDLEVBQUMsQ0FBQztRQUMzQixNQUFNLENBQUMsR0FBRyxLQUFLLENBQUMsQ0FBQyxDQUFDLHlCQUFDLE1BQU0sRUFBUSxDQUFBO1FBQ2pDLE1BQU0sUUFBUSxHQUFHLEtBQUssQ0FBQyxDQUFDLENBQUMseUJBQUMsUUFBUSxFQUFRLENBQUE7UUFDMUMsTU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R0FFRztBQUNILE1BQU0sVUFBVSxvQkFBb0IsQ0FBQyxHQUFXLEVBQUUsU0FBaUIsRUFBRSxjQUFzQjtJQUN6RiwrQkFDSyx1QkFBZ0MsVUFBVSxDQUFDLFNBQVMsQ0FBQyxFQUFwRCxZQUFZLENBQUMsY0FBYyxDQUFDLEVBQXlCLEVBRHBELG9CQUFvQixDQUFDLEdBQUcsQ0FBQyxFQUMyQjtBQUM3RCxDQUFDO0FBRUQsU0FBUyxNQUFNLENBQUksS0FBZTtJQUNoQyxPQUFPLG9CQUFXLFFBQVEsQ0FBQyxFQUFDLENBQUM7UUFDM0IsTUFBTSxjQUFjLEdBQUcsS0FBSyxDQUFDLENBQUMsQ0FBQyw4Q0FBMkIsQ0FBQTtRQUMxRCxPQUFPLGdCQUFnQixDQUFDLEtBQUssRUFBRSxFQUFFLGNBQWMsRUFBRSxDQUFDLENBQUE7SUFDcEQsQ0FBQyxDQUFDLENBQUE7QUFDSixDQUFDIn0=
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Effect } from "@effect/io/Effect";
|
|
2
|
+
import { Scope } from "@effect/io/Scope";
|
|
3
|
+
import { NonEmptyReadonlyArray } from "@fp-ts/core/ReadonlyArray";
|
|
4
|
+
import type { RequestContext } from "@effect-app/infra/RequestContext";
|
|
5
|
+
export interface QueueBase<RContext, Evt> {
|
|
6
|
+
drain: Effect<Scope | RContext, never, void>;
|
|
7
|
+
publish: (...messages: NonEmptyReadonlyArray<Evt>) => Effect<RequestContext, never, void>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* @tsplus type QueueMaker.Ops
|
|
11
|
+
*/
|
|
12
|
+
export interface QueueMakerOps {
|
|
13
|
+
}
|
|
14
|
+
export declare const QueueMaker: QueueMakerOps;
|
|
15
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../_src/services/QueueMaker/service.ts"],"names":[],"mappings":";;;AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAA;AAEtE,MAAM,WAAW,SAAS,CAAC,QAAQ,EAAE,GAAG;IACtC,KAAK,EAAE,MAAM,CAAC,KAAK,GAAG,QAAQ,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;IAC5C,OAAO,EAAE,CACP,GAAG,QAAQ,EAAE,qBAAqB,CAAC,GAAG,CAAC,KACpC,MAAM,CAAC,cAAc,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;CACzC;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;CAAG;AACjC,eAAO,MAAM,UAAU,EAAE,aAAkB,CAAA"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export const QueueMaker = {};
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2VydmljZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL19zcmMvc2VydmljZXMvUXVldWVNYWtlci9zZXJ2aWNlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQWFBLE1BQU0sQ0FBQyxNQUFNLFVBQVUsR0FBa0IsRUFBRSxDQUFBIn0=
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@effect-app/infra",
|
|
3
|
-
"version": "0.17.
|
|
3
|
+
"version": "0.17.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@azure/cosmos": "^3.17.2",
|
|
8
|
+
"@azure/service-bus": "^7.7.3",
|
|
8
9
|
"@effect/io": "^0.1.2",
|
|
9
10
|
"@fp-ts/core": "^0.1.1",
|
|
10
11
|
"@fp-ts/data": "^0.1.0",
|
|
@@ -19,10 +20,10 @@
|
|
|
19
20
|
"proper-lockfile": "^4.1.2",
|
|
20
21
|
"pure-rand": "^6.0.0",
|
|
21
22
|
"redlock": "^4.2.0",
|
|
22
|
-
"@effect-app/core": "0.16.0",
|
|
23
23
|
"@effect-app/prelude": "0.16.0",
|
|
24
|
-
"@effect-app/
|
|
25
|
-
"@effect-app/schema": "0.14.0"
|
|
24
|
+
"@effect-app/core": "0.16.0",
|
|
25
|
+
"@effect-app/schema": "0.14.0",
|
|
26
|
+
"@effect-app/infra-adapters": "0.14.0"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
28
29
|
"@babel/cli": "^7.20.7",
|
|
@@ -452,6 +453,46 @@
|
|
|
452
453
|
"default": "./_cjs/services/Operations/service.cjs"
|
|
453
454
|
}
|
|
454
455
|
},
|
|
456
|
+
"./services/QueueMaker/errors": {
|
|
457
|
+
"import": {
|
|
458
|
+
"types": "./dist/services/QueueMaker/errors.d.ts",
|
|
459
|
+
"default": "./dist/services/QueueMaker/errors.js"
|
|
460
|
+
},
|
|
461
|
+
"require": {
|
|
462
|
+
"types": "./dist/services/QueueMaker/errors.d.ts",
|
|
463
|
+
"default": "./_cjs/services/QueueMaker/errors.cjs"
|
|
464
|
+
}
|
|
465
|
+
},
|
|
466
|
+
"./services/QueueMaker/memQueue": {
|
|
467
|
+
"import": {
|
|
468
|
+
"types": "./dist/services/QueueMaker/memQueue.d.ts",
|
|
469
|
+
"default": "./dist/services/QueueMaker/memQueue.js"
|
|
470
|
+
},
|
|
471
|
+
"require": {
|
|
472
|
+
"types": "./dist/services/QueueMaker/memQueue.d.ts",
|
|
473
|
+
"default": "./_cjs/services/QueueMaker/memQueue.cjs"
|
|
474
|
+
}
|
|
475
|
+
},
|
|
476
|
+
"./services/QueueMaker/sbqueue": {
|
|
477
|
+
"import": {
|
|
478
|
+
"types": "./dist/services/QueueMaker/sbqueue.d.ts",
|
|
479
|
+
"default": "./dist/services/QueueMaker/sbqueue.js"
|
|
480
|
+
},
|
|
481
|
+
"require": {
|
|
482
|
+
"types": "./dist/services/QueueMaker/sbqueue.d.ts",
|
|
483
|
+
"default": "./_cjs/services/QueueMaker/sbqueue.cjs"
|
|
484
|
+
}
|
|
485
|
+
},
|
|
486
|
+
"./services/QueueMaker/service": {
|
|
487
|
+
"import": {
|
|
488
|
+
"types": "./dist/services/QueueMaker/service.d.ts",
|
|
489
|
+
"default": "./dist/services/QueueMaker/service.js"
|
|
490
|
+
},
|
|
491
|
+
"require": {
|
|
492
|
+
"types": "./dist/services/QueueMaker/service.d.ts",
|
|
493
|
+
"default": "./_cjs/services/QueueMaker/service.cjs"
|
|
494
|
+
}
|
|
495
|
+
},
|
|
455
496
|
"./services/Repository": {
|
|
456
497
|
"import": {
|
|
457
498
|
"types": "./dist/services/Repository.d.ts",
|