@webda/azure 0.0.0-stage → 4.0.0-beta.14
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 +166 -0
- package/README.md +248 -2
- package/lib/auth.d.ts +36 -0
- package/lib/auth.d.ts.map +1 -0
- package/lib/auth.js +70 -0
- package/lib/auth.js.map +1 -0
- package/lib/deployers/arm.service.d.ts +177 -0
- package/lib/deployers/arm.service.d.ts.map +1 -0
- package/lib/deployers/arm.service.js +307 -0
- package/lib/deployers/arm.service.js.map +1 -0
- package/lib/deployers/containerapps.service.d.ts +186 -0
- package/lib/deployers/containerapps.service.d.ts.map +1 -0
- package/lib/deployers/containerapps.service.js +482 -0
- package/lib/deployers/containerapps.service.js.map +1 -0
- package/lib/deployers/functions-entrypoint.d.ts +60 -0
- package/lib/deployers/functions-entrypoint.d.ts.map +1 -0
- package/lib/deployers/functions-entrypoint.js +78 -0
- package/lib/deployers/functions-entrypoint.js.map +1 -0
- package/lib/deployers/functions.service.d.ts +96 -0
- package/lib/deployers/functions.service.d.ts.map +1 -0
- package/lib/deployers/functions.service.js +340 -0
- package/lib/deployers/functions.service.js.map +1 -0
- package/lib/deployers/functionspackager.service.d.ts +82 -0
- package/lib/deployers/functionspackager.service.d.ts.map +1 -0
- package/lib/deployers/functionspackager.service.js +157 -0
- package/lib/deployers/functionspackager.service.js.map +1 -0
- package/lib/index.d.ts +15 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +18 -0
- package/lib/index.js.map +1 -0
- package/lib/services/azure-parameters.d.ts +56 -0
- package/lib/services/azure-parameters.d.ts.map +1 -0
- package/lib/services/azure-parameters.js +43 -0
- package/lib/services/azure-parameters.js.map +1 -0
- package/lib/services/blob.service.d.ts +196 -0
- package/lib/services/blob.service.d.ts.map +1 -0
- package/lib/services/blob.service.js +450 -0
- package/lib/services/blob.service.js.map +1 -0
- package/lib/services/contributors.d.ts +50 -0
- package/lib/services/contributors.d.ts.map +1 -0
- package/lib/services/contributors.js +2 -0
- package/lib/services/contributors.js.map +1 -0
- package/lib/services/cosmos.service.d.ts +253 -0
- package/lib/services/cosmos.service.d.ts.map +1 -0
- package/lib/services/cosmos.service.js +566 -0
- package/lib/services/cosmos.service.js.map +1 -0
- package/lib/services/functionserver.service.d.ts +51 -0
- package/lib/services/functionserver.service.d.ts.map +1 -0
- package/lib/services/functionserver.service.js +232 -0
- package/lib/services/functionserver.service.js.map +1 -0
- package/lib/services/keyvault.service.d.ts +106 -0
- package/lib/services/keyvault.service.d.ts.map +1 -0
- package/lib/services/keyvault.service.js +228 -0
- package/lib/services/keyvault.service.js.map +1 -0
- package/lib/services/monitorlogger.service.d.ts +117 -0
- package/lib/services/monitorlogger.service.d.ts.map +1 -0
- package/lib/services/monitorlogger.service.js +149 -0
- package/lib/services/monitorlogger.service.js.map +1 -0
- package/lib/services/servicebus.service.d.ts +224 -0
- package/lib/services/servicebus.service.d.ts.map +1 -0
- package/lib/services/servicebus.service.js +351 -0
- package/lib/services/servicebus.service.js.map +1 -0
- package/lib/template.d.ts +68 -0
- package/lib/template.d.ts.map +1 -0
- package/lib/template.js +74 -0
- package/lib/template.js.map +1 -0
- package/package.json +77 -3
- package/webda.module.json +1891 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { LogsIngestionClient } from "@azure/monitor-ingestion";
|
|
2
|
+
import { Service } from "@webda/core";
|
|
3
|
+
import { WorkerLogLevel, WorkerMessage } from "@webda/workout";
|
|
4
|
+
import { AzureParameters } from "./azure-parameters.js";
|
|
5
|
+
/** Azure Monitor Logs Ingestion settings. */
|
|
6
|
+
export declare class AzureMonitorLoggerParameters extends AzureParameters {
|
|
7
|
+
/**
|
|
8
|
+
* Endpoint
|
|
9
|
+
*/
|
|
10
|
+
endpoint: string;
|
|
11
|
+
/**
|
|
12
|
+
* Rule ID
|
|
13
|
+
*/
|
|
14
|
+
ruleId: string;
|
|
15
|
+
/**
|
|
16
|
+
* Stream name
|
|
17
|
+
*/
|
|
18
|
+
streamName: string;
|
|
19
|
+
/**
|
|
20
|
+
* Log level
|
|
21
|
+
*/
|
|
22
|
+
logLevel: WorkerLogLevel;
|
|
23
|
+
/**
|
|
24
|
+
* Batch size
|
|
25
|
+
*/
|
|
26
|
+
batchSize: number;
|
|
27
|
+
/**
|
|
28
|
+
* Flush interval
|
|
29
|
+
*/
|
|
30
|
+
flushInterval: number;
|
|
31
|
+
/**
|
|
32
|
+
* Max buffered logs
|
|
33
|
+
*/
|
|
34
|
+
maxBufferedLogs: number;
|
|
35
|
+
}
|
|
36
|
+
/** Columns declared in the Data Collection Rule's stream. */
|
|
37
|
+
export interface AzureLogRecord extends Record<string, unknown> {
|
|
38
|
+
/**
|
|
39
|
+
* Time generated
|
|
40
|
+
*/
|
|
41
|
+
TimeGenerated: string;
|
|
42
|
+
/**
|
|
43
|
+
* Level
|
|
44
|
+
*/
|
|
45
|
+
Level: WorkerLogLevel;
|
|
46
|
+
/**
|
|
47
|
+
* Message
|
|
48
|
+
*/
|
|
49
|
+
Message: string;
|
|
50
|
+
}
|
|
51
|
+
/** Forward Webda logs to a custom Azure Monitor table.
|
|
52
|
+
* @WebdaModda
|
|
53
|
+
*/
|
|
54
|
+
export declare class AzureMonitorLogger extends Service<AzureMonitorLoggerParameters> {
|
|
55
|
+
/**
|
|
56
|
+
* Parameters
|
|
57
|
+
*/
|
|
58
|
+
static Parameters: typeof AzureMonitorLoggerParameters;
|
|
59
|
+
/**
|
|
60
|
+
* Client
|
|
61
|
+
*/
|
|
62
|
+
protected client: LogsIngestionClient;
|
|
63
|
+
/**
|
|
64
|
+
* Buffer
|
|
65
|
+
*/
|
|
66
|
+
protected buffer: AzureLogRecord[];
|
|
67
|
+
/**
|
|
68
|
+
* Sending
|
|
69
|
+
*/
|
|
70
|
+
protected sending?: Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* Timer
|
|
73
|
+
*/
|
|
74
|
+
protected timer?: ReturnType<typeof setInterval>;
|
|
75
|
+
/**
|
|
76
|
+
* Message listener
|
|
77
|
+
*/
|
|
78
|
+
protected messageListener?: (message: WorkerMessage) => void;
|
|
79
|
+
/**
|
|
80
|
+
* Result listener off
|
|
81
|
+
*/
|
|
82
|
+
protected resultListenerOff?: () => void;
|
|
83
|
+
/** Number of records dropped because the bounded buffer was full. */
|
|
84
|
+
droppedLogs: number;
|
|
85
|
+
/** Last delivery error, available to health checks without recursively logging it. */
|
|
86
|
+
lastDeliveryFailed: boolean;
|
|
87
|
+
/**
|
|
88
|
+
* Perform init.
|
|
89
|
+
* @override
|
|
90
|
+
*/
|
|
91
|
+
init(): Promise<this>;
|
|
92
|
+
/**
|
|
93
|
+
* Buffer one record. SecretString values retain their masked representation.
|
|
94
|
+
* @param level - Worker log level
|
|
95
|
+
* @param args - Log arguments
|
|
96
|
+
*/
|
|
97
|
+
_log(level: WorkerLogLevel, ...args: unknown[]): void;
|
|
98
|
+
/**
|
|
99
|
+
* Serialize flushes; failed records stay at the front for the next scheduled retry.
|
|
100
|
+
* @returns Completion of the current flush attempt
|
|
101
|
+
*/
|
|
102
|
+
sendLogs(): Promise<void>;
|
|
103
|
+
/**
|
|
104
|
+
* Deliver buffered records in bounded batches.
|
|
105
|
+
*/
|
|
106
|
+
protected flush(): Promise<void>;
|
|
107
|
+
/**
|
|
108
|
+
* Detach log forwarding and stop scheduled flushing.
|
|
109
|
+
*/
|
|
110
|
+
protected removeListeners(): void;
|
|
111
|
+
/**
|
|
112
|
+
* Perform stop.
|
|
113
|
+
* @override
|
|
114
|
+
*/
|
|
115
|
+
stop(): Promise<void>;
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=monitorlogger.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monitorlogger.service.d.ts","sources":["../../src/services/monitorlogger.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,OAAO,EAA6B,MAAM,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ACrE,WAAW,SAAK;IAChB,sFAAsF;IACtF,kBAAkB,UAAS;IAE3B;;;OAGG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CA+B1B;IAED;;;;OAIG;IACH,IAAI,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAOpD;IAED;;;OAGG;IACH,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAMxB;IAED;;OAEG;IACH,UAAgB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAerC;IAED;;OAEG;IACH,SAAS,CAAC,eAAe,IAAI,IAAI,CAOhC;IAED;;;OAGG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAK1B;CACF"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { LogsIngestionClient } from "@azure/monitor-ingestion";
|
|
2
|
+
import { Service, useCoreEvents, WebdaError } from "@webda/core";
|
|
3
|
+
import { LogFilter, useWorkerOutput } from "@webda/workout";
|
|
4
|
+
import { format } from "node:util";
|
|
5
|
+
import { AzureParameters, getAzureCredential } from "./azure-parameters.js";
|
|
6
|
+
/** Azure Monitor Logs Ingestion settings. */
|
|
7
|
+
export class AzureMonitorLoggerParameters extends AzureParameters {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(...arguments);
|
|
10
|
+
/**
|
|
11
|
+
* Log level
|
|
12
|
+
*/
|
|
13
|
+
this.logLevel = "INFO";
|
|
14
|
+
/**
|
|
15
|
+
* Batch size
|
|
16
|
+
*/
|
|
17
|
+
this.batchSize = 100;
|
|
18
|
+
/**
|
|
19
|
+
* Flush interval
|
|
20
|
+
*/
|
|
21
|
+
this.flushInterval = 5000;
|
|
22
|
+
/**
|
|
23
|
+
* Max buffered logs
|
|
24
|
+
*/
|
|
25
|
+
this.maxBufferedLogs = 10000;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/** Forward Webda logs to a custom Azure Monitor table.
|
|
29
|
+
* @WebdaModda
|
|
30
|
+
*/
|
|
31
|
+
export class AzureMonitorLogger extends Service {
|
|
32
|
+
constructor() {
|
|
33
|
+
super(...arguments);
|
|
34
|
+
/**
|
|
35
|
+
* Buffer
|
|
36
|
+
*/
|
|
37
|
+
this.buffer = [];
|
|
38
|
+
/** Number of records dropped because the bounded buffer was full. */
|
|
39
|
+
this.droppedLogs = 0;
|
|
40
|
+
/** Last delivery error, available to health checks without recursively logging it. */
|
|
41
|
+
this.lastDeliveryFailed = false;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Perform init.
|
|
45
|
+
* @override
|
|
46
|
+
*/
|
|
47
|
+
async init() {
|
|
48
|
+
await super.init();
|
|
49
|
+
const p = this.parameters;
|
|
50
|
+
if (!p.endpoint ||
|
|
51
|
+
!p.ruleId ||
|
|
52
|
+
!p.streamName ||
|
|
53
|
+
!Number.isInteger(p.batchSize) ||
|
|
54
|
+
p.batchSize < 1 ||
|
|
55
|
+
!Number.isInteger(p.maxBufferedLogs) ||
|
|
56
|
+
p.maxBufferedLogs < p.batchSize ||
|
|
57
|
+
p.flushInterval < 1) {
|
|
58
|
+
throw new WebdaError.BadRequest("Azure Monitor requires endpoint, ruleId, streamName and positive buffer settings");
|
|
59
|
+
}
|
|
60
|
+
this.removeListeners();
|
|
61
|
+
this.client = new LogsIngestionClient(p.endpoint, getAzureCredential(p));
|
|
62
|
+
this.messageListener = message => {
|
|
63
|
+
if (message.type === "log" && message.log && LogFilter(message.log.level, p.logLevel)) {
|
|
64
|
+
this._log(message.log.level, ...message.log.args);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
useWorkerOutput().on("message", this.messageListener);
|
|
68
|
+
this.resultListenerOff = useCoreEvents("Webda.Result", () => this.sendLogs());
|
|
69
|
+
this.timer = setInterval(() => {
|
|
70
|
+
void this.sendLogs();
|
|
71
|
+
}, p.flushInterval);
|
|
72
|
+
this.timer.unref();
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Buffer one record. SecretString values retain their masked representation.
|
|
77
|
+
* @param level - Worker log level
|
|
78
|
+
* @param args - Log arguments
|
|
79
|
+
*/
|
|
80
|
+
_log(level, ...args) {
|
|
81
|
+
if (this.buffer.length >= this.parameters.maxBufferedLogs) {
|
|
82
|
+
this.droppedLogs++;
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
this.buffer.push({ TimeGenerated: new Date().toISOString(), Level: level, Message: format(...args) });
|
|
86
|
+
if (this.buffer.length >= this.parameters.batchSize)
|
|
87
|
+
void this.sendLogs();
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Serialize flushes; failed records stay at the front for the next scheduled retry.
|
|
91
|
+
* @returns Completion of the current flush attempt
|
|
92
|
+
*/
|
|
93
|
+
sendLogs() {
|
|
94
|
+
if (this.sending)
|
|
95
|
+
return this.sending;
|
|
96
|
+
this.sending = this.flush().finally(() => {
|
|
97
|
+
this.sending = undefined;
|
|
98
|
+
});
|
|
99
|
+
return this.sending;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Deliver buffered records in bounded batches.
|
|
103
|
+
*/
|
|
104
|
+
async flush() {
|
|
105
|
+
while (this.buffer.length) {
|
|
106
|
+
const records = this.buffer.splice(0, this.parameters.batchSize);
|
|
107
|
+
try {
|
|
108
|
+
await this.client.upload(this.parameters.ruleId, this.parameters.streamName, records);
|
|
109
|
+
this.lastDeliveryFailed = false;
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
this.lastDeliveryFailed = true;
|
|
113
|
+
this.buffer.unshift(...records);
|
|
114
|
+
const overflow = Math.max(0, this.buffer.length - this.parameters.maxBufferedLogs);
|
|
115
|
+
this.buffer.splice(this.parameters.maxBufferedLogs, overflow);
|
|
116
|
+
this.droppedLogs += overflow;
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Detach log forwarding and stop scheduled flushing.
|
|
123
|
+
*/
|
|
124
|
+
removeListeners() {
|
|
125
|
+
if (this.messageListener)
|
|
126
|
+
useWorkerOutput().off("message", this.messageListener);
|
|
127
|
+
this.messageListener = undefined;
|
|
128
|
+
this.resultListenerOff?.();
|
|
129
|
+
this.resultListenerOff = undefined;
|
|
130
|
+
clearInterval(this.timer);
|
|
131
|
+
this.timer = undefined;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Perform stop.
|
|
135
|
+
* @override
|
|
136
|
+
*/
|
|
137
|
+
async stop() {
|
|
138
|
+
this.removeListeners();
|
|
139
|
+
await this.sendLogs();
|
|
140
|
+
await super.stop();
|
|
141
|
+
if (this.buffer.length)
|
|
142
|
+
throw new WebdaError.ServiceUnavailable("Unable to flush remaining Azure Monitor logs");
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Parameters
|
|
147
|
+
*/
|
|
148
|
+
AzureMonitorLogger.Parameters = AzureMonitorLoggerParameters;
|
|
149
|
+
//# sourceMappingURL=monitorlogger.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"monitorlogger.service.js","sources":["../../src/services/monitorlogger.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAiC,MAAM,gBAAgB,CAAC;AAC3F,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE5E,6CAA6C;AAC7C,MAAM,OAAO,4BAA6B,SAAQ,eAAe;IAAjE;;QAaE;;WAEG;QACH,aAAQ,GAAmB,MAAM,CAAC;QAClC;;WAEG;QACH,cAAS,GAAG,GAAG,CAAC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EAAE,CAAC;QAC3B,IAAI,CAAC,iBAAiB,GAAG,SAAS,CAAC;QACnC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC1B,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;IACzB,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,IAAI;QACR,IAAI,CAAC,eAAe,EAAE,CAAC;QACvB,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;QACtB,MAAM,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM;YAAE,MAAM,IAAI,UAAU,CAAC,kBAAkB,CAAC,8CAA8C,CAAC,CAAC;IAClH,CAAC;CACF;AA1IC;;GAEG;AACI,6BAAU,GAAG,4BAA4B,AAA/B,CAAgC"}
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import { ServiceBusAdministrationClient, ServiceBusClient, ServiceBusReceivedMessage, ServiceBusReceiver, ServiceBusSender } from "@azure/service-bus";
|
|
2
|
+
import { MessageReceipt, PubSubService, Queue, QueueParameters, SecretString } from "@webda/core";
|
|
3
|
+
import { CancelablePromise } from "@webda/utils";
|
|
4
|
+
import { AzureParameters, AzureServiceParameters } from "./azure-parameters.js";
|
|
5
|
+
import { AzureContributor, AzureDeployerInfo, AzureResourceContribution } from "./contributors.js";
|
|
6
|
+
/**
|
|
7
|
+
* Service bus settings interface
|
|
8
|
+
*/
|
|
9
|
+
interface ServiceBusSettings extends AzureServiceParameters {
|
|
10
|
+
/**
|
|
11
|
+
* Namespace
|
|
12
|
+
*/
|
|
13
|
+
namespace: string;
|
|
14
|
+
/**
|
|
15
|
+
* Connection string
|
|
16
|
+
*/
|
|
17
|
+
connectionString?: string | SecretString;
|
|
18
|
+
/**
|
|
19
|
+
* Whether create if not exists is enabled
|
|
20
|
+
*/
|
|
21
|
+
createIfNotExists?: boolean;
|
|
22
|
+
}
|
|
23
|
+
/** Service Bus work queue settings. */
|
|
24
|
+
export declare class ServiceBusQueueParameters extends QueueParameters implements ServiceBusSettings {
|
|
25
|
+
/**
|
|
26
|
+
* Namespace
|
|
27
|
+
*/
|
|
28
|
+
namespace: string;
|
|
29
|
+
/**
|
|
30
|
+
* Connection string
|
|
31
|
+
*/
|
|
32
|
+
connectionString?: string | SecretString;
|
|
33
|
+
/**
|
|
34
|
+
* Create if not exists
|
|
35
|
+
*/
|
|
36
|
+
createIfNotExists: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Queue
|
|
39
|
+
*/
|
|
40
|
+
queue: string;
|
|
41
|
+
/**
|
|
42
|
+
* Tenant ID
|
|
43
|
+
*/
|
|
44
|
+
tenantId?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Client ID
|
|
47
|
+
*/
|
|
48
|
+
clientId?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Client secret
|
|
51
|
+
*/
|
|
52
|
+
clientSecret?: string | SecretString;
|
|
53
|
+
/**
|
|
54
|
+
* Subscription ID
|
|
55
|
+
*/
|
|
56
|
+
subscriptionId?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Endpoint
|
|
59
|
+
*/
|
|
60
|
+
endpoint?: string;
|
|
61
|
+
/**
|
|
62
|
+
* Max messages
|
|
63
|
+
*/
|
|
64
|
+
maxMessages: number;
|
|
65
|
+
/**
|
|
66
|
+
* Max wait time in ms
|
|
67
|
+
*/
|
|
68
|
+
maxWaitTimeInMs: number;
|
|
69
|
+
/**
|
|
70
|
+
* Max pending messages
|
|
71
|
+
*/
|
|
72
|
+
maxPendingMessages: number;
|
|
73
|
+
/**
|
|
74
|
+
* Perform load.
|
|
75
|
+
* @override
|
|
76
|
+
*/
|
|
77
|
+
load(params?: any): this;
|
|
78
|
+
}
|
|
79
|
+
/** Service Bus peek-lock queue. Receipts retain their exact SDK message until completion or expiry.
|
|
80
|
+
* @WebdaModda
|
|
81
|
+
*/
|
|
82
|
+
export declare class ServiceBusQueue<T = any> extends Queue<T, ServiceBusQueueParameters> implements AzureContributor {
|
|
83
|
+
/**
|
|
84
|
+
* Parameters
|
|
85
|
+
*/
|
|
86
|
+
static Parameters: typeof ServiceBusQueueParameters;
|
|
87
|
+
/**
|
|
88
|
+
* Client
|
|
89
|
+
*/
|
|
90
|
+
protected client: ServiceBusClient;
|
|
91
|
+
/**
|
|
92
|
+
* Admin
|
|
93
|
+
*/
|
|
94
|
+
protected admin: ServiceBusAdministrationClient;
|
|
95
|
+
/**
|
|
96
|
+
* Sender
|
|
97
|
+
*/
|
|
98
|
+
protected sender: ServiceBusSender;
|
|
99
|
+
/**
|
|
100
|
+
* Receiver
|
|
101
|
+
*/
|
|
102
|
+
protected receiver: ServiceBusReceiver;
|
|
103
|
+
/**
|
|
104
|
+
* Pending
|
|
105
|
+
*/
|
|
106
|
+
protected pending: Map<string, ServiceBusReceivedMessage>;
|
|
107
|
+
/**
|
|
108
|
+
* Perform init.
|
|
109
|
+
* @override
|
|
110
|
+
*/
|
|
111
|
+
init(): Promise<this>;
|
|
112
|
+
/**
|
|
113
|
+
* Perform send message.
|
|
114
|
+
* @override
|
|
115
|
+
*/
|
|
116
|
+
sendMessage(event: T): Promise<void>;
|
|
117
|
+
/**
|
|
118
|
+
* Perform receive message.
|
|
119
|
+
* @override
|
|
120
|
+
*/
|
|
121
|
+
receiveMessage<L>(proto?: new () => L): Promise<MessageReceipt<L>[]>;
|
|
122
|
+
/**
|
|
123
|
+
* Perform delete message.
|
|
124
|
+
* @override
|
|
125
|
+
*/
|
|
126
|
+
deleteMessage(handle: string): Promise<void>;
|
|
127
|
+
/**
|
|
128
|
+
* Perform size.
|
|
129
|
+
* @override
|
|
130
|
+
*/
|
|
131
|
+
size(): Promise<number>;
|
|
132
|
+
/**
|
|
133
|
+
* Perform stop.
|
|
134
|
+
* @override
|
|
135
|
+
*/
|
|
136
|
+
stop(): Promise<void>;
|
|
137
|
+
/**
|
|
138
|
+
* Describe the Azure resources and identity permissions required by this service.
|
|
139
|
+
* @param deployer - Deployment scope and identity helpers
|
|
140
|
+
* @returns The azure resources result
|
|
141
|
+
*/
|
|
142
|
+
getAzureResources(deployer: AzureDeployerInfo): AzureResourceContribution;
|
|
143
|
+
}
|
|
144
|
+
/** Service Bus pub/sub settings. Omit subscription to create one temporary subscription per consumer. */
|
|
145
|
+
export declare class ServiceBusPubSubParameters extends AzureParameters implements ServiceBusSettings {
|
|
146
|
+
/**
|
|
147
|
+
* Namespace
|
|
148
|
+
*/
|
|
149
|
+
namespace: string;
|
|
150
|
+
/**
|
|
151
|
+
* Connection string
|
|
152
|
+
*/
|
|
153
|
+
connectionString?: string | SecretString;
|
|
154
|
+
/**
|
|
155
|
+
* Create if not exists
|
|
156
|
+
*/
|
|
157
|
+
createIfNotExists: boolean;
|
|
158
|
+
/**
|
|
159
|
+
* Topic
|
|
160
|
+
*/
|
|
161
|
+
topic: string;
|
|
162
|
+
/**
|
|
163
|
+
* Subscription
|
|
164
|
+
*/
|
|
165
|
+
subscription?: string;
|
|
166
|
+
}
|
|
167
|
+
/** Service Bus topic with explicit completion after successful processing.
|
|
168
|
+
* @WebdaModda
|
|
169
|
+
*/
|
|
170
|
+
export declare class ServiceBusPubSub<T = any> extends PubSubService<T, ServiceBusPubSubParameters> implements AzureContributor {
|
|
171
|
+
/**
|
|
172
|
+
* Parameters
|
|
173
|
+
*/
|
|
174
|
+
static Parameters: typeof ServiceBusPubSubParameters;
|
|
175
|
+
/**
|
|
176
|
+
* Client
|
|
177
|
+
*/
|
|
178
|
+
protected client: ServiceBusClient;
|
|
179
|
+
/**
|
|
180
|
+
* Admin
|
|
181
|
+
*/
|
|
182
|
+
protected admin: ServiceBusAdministrationClient;
|
|
183
|
+
/**
|
|
184
|
+
* Sender
|
|
185
|
+
*/
|
|
186
|
+
protected sender: ServiceBusSender;
|
|
187
|
+
/**
|
|
188
|
+
* Consumers
|
|
189
|
+
*/
|
|
190
|
+
protected consumers: Set<CancelablePromise<void>>;
|
|
191
|
+
/**
|
|
192
|
+
* Perform init.
|
|
193
|
+
* @override
|
|
194
|
+
*/
|
|
195
|
+
init(): Promise<this>;
|
|
196
|
+
/**
|
|
197
|
+
* Perform send message.
|
|
198
|
+
* @override
|
|
199
|
+
*/
|
|
200
|
+
sendMessage(event: T): Promise<void>;
|
|
201
|
+
/**
|
|
202
|
+
* Perform size.
|
|
203
|
+
* @override
|
|
204
|
+
*/
|
|
205
|
+
size(): Promise<number>;
|
|
206
|
+
/**
|
|
207
|
+
* Perform consume.
|
|
208
|
+
* @override
|
|
209
|
+
*/
|
|
210
|
+
consume(callback: (event: T) => Promise<void>, proto?: new () => T, onBind?: () => void): CancelablePromise;
|
|
211
|
+
/**
|
|
212
|
+
* Perform stop.
|
|
213
|
+
* @override
|
|
214
|
+
*/
|
|
215
|
+
stop(): Promise<void>;
|
|
216
|
+
/**
|
|
217
|
+
* Describe the Azure resources and identity permissions required by this service.
|
|
218
|
+
* @param deployer - Deployment scope and identity helpers
|
|
219
|
+
* @returns The azure resources result
|
|
220
|
+
*/
|
|
221
|
+
getAzureResources(deployer: AzureDeployerInfo): AzureResourceContribution;
|
|
222
|
+
}
|
|
223
|
+
export {};
|
|
224
|
+
//# sourceMappingURL=servicebus.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"servicebus.service.d.ts","sources":["../../src/services/servicebus.service.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,8BAA8B,EAC9B,gBAAgB,EAChB,yBAAyB,EACzB,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,KAAK,EAAE,eAAe,EAAE,YAAY,EAAc,MAAM,aAAa,CAAC;AAC9G,OAAO,EAAE,iBAAiB,EAAa,MAAM,cAAc,CAAC;AAE5D,OAAO,EACL,eAAe,EACf,sBAAsB,EAGvB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAEn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