@deployagram/logger-client 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/dist/diagram-logger-client.d.ts +16 -0
- package/dist/diagram-logger-client.js +21 -0
- package/dist/diagram-logger-client.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/kafka.d.ts +11 -0
- package/dist/kafka.js +2 -0
- package/dist/kafka.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -34,12 +34,17 @@ await logger.flushToCloud('Emailer', 'run-1'); // POST /run/markTestRunEnd/{cont
|
|
|
34
34
|
| `read(id)` | `GET /log/read/{id}` |
|
|
35
35
|
| `markEnd(id)` | `POST /log/markEnd/{id}` |
|
|
36
36
|
| `flushToCloud(container, run)` | `POST /run/markTestRunEnd/{container}/{run}` |
|
|
37
|
+
| `configureKafkaBroker(bootstrapServers)` | `PUT /kafka/configuration` |
|
|
38
|
+
| `configureSchemaRegistry(url)` | `PUT /schemaRegistry/configuration` |
|
|
39
|
+
| `kafkaConsumerRead(read)` | `POST /kafka/consumer` |
|
|
37
40
|
|
|
38
41
|
Differences from the Java client:
|
|
39
42
|
|
|
40
43
|
* A non-2xx response throws `CollectorError`, which has `status` and `responseBody`. The Java
|
|
41
44
|
client ignores the status.
|
|
42
45
|
* Every method returns a Promise.
|
|
46
|
+
* The configure calls need the Collector in runtime configuration mode. In static mode the Collector
|
|
47
|
+
answers `409`, which throws, so a test never silently reads from the wrong broker.
|
|
43
48
|
* `flushToCloud` calls `markTestRunEnd`, as the Java client does. On a Collector with a Central
|
|
44
49
|
Logger configured, that also sends the run to the cloud.
|
|
45
50
|
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DiagramLogger, Log, Logs } from '@deployagram/api';
|
|
2
|
+
import type { KafkaConsumerRead } from './kafka.js';
|
|
2
3
|
export interface DiagramLoggerClientOptions {
|
|
3
4
|
/** Base URL of the Collector, for example "http://localhost:1152". */
|
|
4
5
|
baseUrl: string;
|
|
@@ -26,5 +27,20 @@ export declare class DiagramLoggerClient implements DiagramLogger {
|
|
|
26
27
|
* that ends a test run and, when a Central Logger is configured on the Collector, flushes it.
|
|
27
28
|
*/
|
|
28
29
|
flushToCloud(containerId: string, testRunId: string): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* PUT /kafka/configuration: the broker the Collector reads Kafka records from. Needs the Collector
|
|
32
|
+
* in runtime configuration mode; otherwise it answers 409, which throws.
|
|
33
|
+
*/
|
|
34
|
+
configureKafkaBroker(bootstrapServers: string): Promise<void>;
|
|
35
|
+
/**
|
|
36
|
+
* PUT /schemaRegistry/configuration: the registry the Collector decodes Avro and JSON-schema
|
|
37
|
+
* records with. Needs runtime mode, as configureKafkaBroker does.
|
|
38
|
+
*/
|
|
39
|
+
configureSchemaRegistry(url: string): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* POST /kafka/consumer: tell the Collector a record was consumed. The Collector answers 204 and
|
|
42
|
+
* reads the record in the background.
|
|
43
|
+
*/
|
|
44
|
+
kafkaConsumerRead(read: KafkaConsumerRead): Promise<void>;
|
|
29
45
|
private request;
|
|
30
46
|
}
|
|
@@ -29,6 +29,27 @@ export class DiagramLoggerClient {
|
|
|
29
29
|
async flushToCloud(containerId, testRunId) {
|
|
30
30
|
await this.request('POST', `/run/markTestRunEnd/${encodeURIComponent(containerId)}/${encodeURIComponent(testRunId)}`);
|
|
31
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* PUT /kafka/configuration: the broker the Collector reads Kafka records from. Needs the Collector
|
|
34
|
+
* in runtime configuration mode; otherwise it answers 409, which throws.
|
|
35
|
+
*/
|
|
36
|
+
async configureKafkaBroker(bootstrapServers) {
|
|
37
|
+
await this.request('PUT', '/kafka/configuration', { bootstrapServers });
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* PUT /schemaRegistry/configuration: the registry the Collector decodes Avro and JSON-schema
|
|
41
|
+
* records with. Needs runtime mode, as configureKafkaBroker does.
|
|
42
|
+
*/
|
|
43
|
+
async configureSchemaRegistry(url) {
|
|
44
|
+
await this.request('PUT', '/schemaRegistry/configuration', { url });
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* POST /kafka/consumer: tell the Collector a record was consumed. The Collector answers 204 and
|
|
48
|
+
* reads the record in the background.
|
|
49
|
+
*/
|
|
50
|
+
async kafkaConsumerRead(read) {
|
|
51
|
+
await this.request('POST', '/kafka/consumer', read);
|
|
52
|
+
}
|
|
32
53
|
async request(method, path, body) {
|
|
33
54
|
const init = { method, headers: { Accept: 'application/json' } };
|
|
34
55
|
if (body !== undefined) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagram-logger-client.js","sourceRoot":"","sources":["../src/diagram-logger-client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"diagram-logger-client.js","sourceRoot":"","sources":["../src/diagram-logger-client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAU7C;;;GAGG;AACH,MAAM,OAAO,mBAAmB;IACb,OAAO,CAAS;IAChB,SAAS,CAAe;IAEzC,YAAY,OAAmC;QAC7C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QACnD,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,KAAK,IAAI,KAAK,CAAC;IAC1C,CAAC;IAED,wCAAwC;IACxC,KAAK,CAAC,GAAG,CAAC,GAAQ;QAChB,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;IAC1C,CAAC;IAMD,KAAK,CAAC,IAAI,CAAC,KAAc;QACvB,MAAM,IAAI,GAAG,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,WAAW,C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AAE,GAAG,IAAI,CAAC,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,CAAC;YACvE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QACnC,CAAC;QAED,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,GAAG,IAAI,EAAE,IAAI,CAAC,CAAC;QACjE,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACnC,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,cAAc,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QAChE,CAAC;QACD,OAAO,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC7C,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
package/dist/kafka.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Kafka record a test observed being consumed. The Collector reads the record's key and value
|
|
3
|
+
* from the broker itself, so only its coordinates are sent. Mirrors the Java consumer interceptor.
|
|
4
|
+
*/
|
|
5
|
+
export interface KafkaConsumerRead {
|
|
6
|
+
nameOfConsumingApp: string;
|
|
7
|
+
protocol: 'KAFKA Consumer';
|
|
8
|
+
topic: string;
|
|
9
|
+
partition: number;
|
|
10
|
+
offset: number;
|
|
11
|
+
}
|
package/dist/kafka.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kafka.js","sourceRoot":"","sources":["../src/kafka.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED