@nsshunt/stsappframework 3.0.94 → 3.0.95
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/package.json +1 -1
- package/src_new/authDefs.ts +37 -0
- package/src_new/authutilsnode.ts +375 -0
- package/src_new/commonTypes.ts +239 -0
- package/src_new/index.ts +22 -0
- package/src_new/influxdb/influxDBManager.ts +972 -0
- package/src_new/influxdb/influxDBManagerAgent.ts +316 -0
- package/src_new/influxdb/influxDBManagerBase.ts +111 -0
- package/src_new/influxdb/influxDBManagerService.ts +375 -0
- package/src_new/instrumentationsubscriber.ts +286 -0
- package/src_new/kafka/IMKafkaManager.ts +154 -0
- package/src_new/kafka/kafkaconsumer.ts +82 -0
- package/src_new/kafka/kafkamanager.ts +186 -0
- package/src_new/kafka/kafkaproducer.ts +58 -0
- package/src_new/kafkatesting/config.ts +10 -0
- package/src_new/kafkatesting/consume.ts +116 -0
- package/src_new/kafkatesting/produce.ts +155 -0
- package/src_new/masterprocessbase.ts +590 -0
- package/src_new/middleware/serverNetworkMiddleware.ts +240 -0
- package/src_new/network.ts +36 -0
- package/src_new/processbase.ts +413 -0
- package/src_new/processoptions.ts +164 -0
- package/src_new/publishertransports/publishTransportDirect.ts +45 -0
- package/src_new/publishertransports/publishTransportUtils.ts +53 -0
- package/src_new/server.ts +141 -0
- package/src_new/serverprocessbase.ts +393 -0
- package/src_new/singleprocessbase.ts +123 -0
- package/src_new/socketIoServerHelper.ts +177 -0
- package/src_new/stscontrollerbase.ts +15 -0
- package/src_new/stslatencycontroller.ts +27 -0
- package/src_new/stslatencyroute.ts +16 -0
- package/src_new/stsrouterbase.ts +22 -0
- package/src_new/tcpclient/app.ts +19 -0
- package/src_new/tcpclient/app2.ts +56 -0
- package/src_new/tcpserver/app.ts +11 -0
- package/src_new/tcpserver/appConfig.ts +65 -0
- package/src_new/tcpserver/appmaster.ts +522 -0
- package/src_new/validation/errors.ts +6 -0
- package/src_new/webworkertesting/app.ts +49 -0
- package/src_new/webworkertesting/worker.ts +24 -0
- package/src_new/workerprocessbase.test.ts +47 -0
- package/src_new/workerprocessbase.ts +187 -0
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/*
|
|
2
|
+
|
|
3
|
+
kafka example server #01 - Docker Compose File
|
|
4
|
+
----------------------------------------------
|
|
5
|
+
Note: In this example, the log retention is set to 24 hours (rather than default to 1 week)
|
|
6
|
+
https://www.conduktor.io/kafka/kafka-topic-configuration-log-retention/
|
|
7
|
+
|
|
8
|
+
version: '2'
|
|
9
|
+
services:
|
|
10
|
+
zookeeper:
|
|
11
|
+
image: wurstmeister/zookeeper
|
|
12
|
+
ports:
|
|
13
|
+
- "2181:2181"
|
|
14
|
+
restart: unless-stopped
|
|
15
|
+
|
|
16
|
+
kafka:
|
|
17
|
+
image: wurstmeister/kafka
|
|
18
|
+
ports:
|
|
19
|
+
- "9092:9092"
|
|
20
|
+
environment:
|
|
21
|
+
DOCKER_API_VERSION: 1.22
|
|
22
|
+
KAFKA_ADVERTISED_HOST_NAME: 192.168.14.92
|
|
23
|
+
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
|
|
24
|
+
KAFKA_CREATE_TOPICS: "topic-name2:3:1"
|
|
25
|
+
KAFKA_LOG_RETENTION_MS: 86400000
|
|
26
|
+
KAFKA_LOG_RETENTION_BYTES: -1
|
|
27
|
+
volumes:
|
|
28
|
+
- /var/run/docker.sock:/var/run/docker.sock
|
|
29
|
+
restart: unless-stopped
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
kafka example server #02 - Docker Compose File
|
|
33
|
+
----------------------------------------------
|
|
34
|
+
version: "3.9" # optional since v1.27.0
|
|
35
|
+
|
|
36
|
+
networks:
|
|
37
|
+
app-tier:
|
|
38
|
+
driver: bridge
|
|
39
|
+
|
|
40
|
+
services:
|
|
41
|
+
kafka:
|
|
42
|
+
image: 'bitnami/kafka:latest'
|
|
43
|
+
ports:
|
|
44
|
+
- '9092:9092'
|
|
45
|
+
networks:
|
|
46
|
+
- app-tier
|
|
47
|
+
environment:
|
|
48
|
+
- ALLOW_PLAINTEXT_LISTENER=yes
|
|
49
|
+
- KAFKA_CFG_AUTO_CREATE_TOPICS_ENABLE=true
|
|
50
|
+
- KAFKA_CFG_ADVERTISED_LISTENERS=PLAINTEXT://192.168.14.92:9092
|
|
51
|
+
|
|
52
|
+
*/
|
|
53
|
+
import { TOPIC, CLIENT_ID, BROKERS, PARTITIONS, TIMEOUT } from './config'
|
|
54
|
+
|
|
55
|
+
import { KafkaManager } from './../kafka/kafkamanager'
|
|
56
|
+
|
|
57
|
+
import 'colors'
|
|
58
|
+
|
|
59
|
+
import chalk from 'chalk';
|
|
60
|
+
|
|
61
|
+
async function Sleep(milliseconds = 1000) {
|
|
62
|
+
return new Promise(resolve => setTimeout(resolve, milliseconds))
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
const km = new KafkaManager({
|
|
66
|
+
clientId: CLIENT_ID + process.env.CLIENT_ID,
|
|
67
|
+
brokers: BROKERS,
|
|
68
|
+
adminTimeout: TIMEOUT,
|
|
69
|
+
connectionTimeout: TIMEOUT,
|
|
70
|
+
requestTimeout: TIMEOUT,
|
|
71
|
+
logLevel: 'NOTHING',
|
|
72
|
+
useSSL: false
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const runme = async () => {
|
|
76
|
+
await km.CreateTopic(TOPIC, PARTITIONS);
|
|
77
|
+
await km.CreateTopic('zzz', 1);
|
|
78
|
+
await km.CreateTopic('yyy', 1);
|
|
79
|
+
|
|
80
|
+
const producer = km.CreateProducer();
|
|
81
|
+
|
|
82
|
+
await producer.Connect();
|
|
83
|
+
|
|
84
|
+
const count = 100000;
|
|
85
|
+
const sleepTime = 1000;
|
|
86
|
+
|
|
87
|
+
process.on("SIGINT", async () => {
|
|
88
|
+
console.log('=========SIGTERM START =======================')
|
|
89
|
+
await producer.Disconnect();
|
|
90
|
+
console.log('=========SIGTERM END =======================')
|
|
91
|
+
process.exit();
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
for (let i=0; i < count; i++) {
|
|
95
|
+
if (i % 100 === 0) console.log(i);
|
|
96
|
+
const retVal = await producer.SendMessages(TOPIC, [
|
|
97
|
+
{ key: 'key1', value: chalk.green(`hello world - ${i}`) },
|
|
98
|
+
{ key: 'key2', value: 'hey hey! -2' },
|
|
99
|
+
{ key: 'key3', value: 'hey hey! -3' },
|
|
100
|
+
{ key: 'key4', value: 'hey hey! -4' },
|
|
101
|
+
{ key: 'key5', value: 'hey hey! -5' }
|
|
102
|
+
]
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
await producer.SendMessages('zzz', [
|
|
106
|
+
{ key: 'key-zzz', value: `hello world - ${i}`.yellow }
|
|
107
|
+
]
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
await producer.SendMessages('yyy', [
|
|
111
|
+
{ key: 'key-yyy', value: `hello world - ${i}`.cyan }
|
|
112
|
+
]
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
if (i % 100 === 0) {
|
|
116
|
+
console.log(retVal);
|
|
117
|
+
console.log(` ------------=================> ${i}`);
|
|
118
|
+
}
|
|
119
|
+
if (sleepTime >= 0) {
|
|
120
|
+
await Sleep(sleepTime);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
await producer.Disconnect();
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/*
|
|
128
|
+
const errorTypes = ['unhandledRejection', 'uncaughtException']
|
|
129
|
+
const signalTraps = ['SIGTERM', 'SIGINT', 'SIGUSR2']
|
|
130
|
+
|
|
131
|
+
errorTypes.forEach(type => {
|
|
132
|
+
process.on(type, async () => {
|
|
133
|
+
try {
|
|
134
|
+
console.log(`process.on ${type}`)
|
|
135
|
+
await producer.disconnect()
|
|
136
|
+
process.exit(0)
|
|
137
|
+
} catch (_) {
|
|
138
|
+
process.exit(1)
|
|
139
|
+
}
|
|
140
|
+
})
|
|
141
|
+
})
|
|
142
|
+
|
|
143
|
+
signalTraps.forEach(type => {
|
|
144
|
+
process.once(type, async () => {
|
|
145
|
+
try {
|
|
146
|
+
await producer.disconnect()
|
|
147
|
+
} finally {
|
|
148
|
+
process.kill(process.pid, type)
|
|
149
|
+
}
|
|
150
|
+
})
|
|
151
|
+
})
|
|
152
|
+
*/
|
|
153
|
+
|
|
154
|
+
runme().catch(e => console.error(`[example/producer] ${e.message}`, e))
|
|
155
|
+
|