@nsshunt/stsdatamanagement 1.17.99 → 1.17.100

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.
@@ -28,7 +28,356 @@ ALTER SEQUENCE public.stsresource_oid_seq
28
28
  OWNER TO postgres;
29
29
 
30
30
 
31
- -- Table: public.stsresource
31
+ CREATE SEQUENCE public.stsmonitor_oid_seq
32
+ AS BIGINT
33
+ INCREMENT 1
34
+ START 1
35
+ MINVALUE 1
36
+ CACHE 1;
37
+
38
+ ALTER SEQUENCE public.stsmonitor_oid_seq
39
+ OWNER TO postgres;
40
+
41
+
42
+ -----[ stsmonitor ]--------------------------------
43
+
44
+ CREATE TABLE public.stsmonitor
45
+ (
46
+ oid bigint NOT NULL DEFAULT nextval('stsmonitor_oid_seq'::regclass),
47
+
48
+ -- main graph key
49
+ context character varying(512) COLLATE pg_catalog."default" NOT NULL,
50
+
51
+ -- Tree level attributes (context)
52
+ servicetype character varying(128) COLLATE pg_catalog."default" NOT NULL,
53
+ serviceid character varying(128) COLLATE pg_catalog."default" NOT NULL,
54
+ serviceinstanceid character varying(128) COLLATE pg_catalog."default" NOT NULL,
55
+ serviceidhostname character varying(128) COLLATE pg_catalog."default" NOT NULL,
56
+
57
+ serviceinstanceprocessid character varying(128) COLLATE pg_catalog."default" NOT NULL,
58
+ pid integer NOT NULL,
59
+ ppid integer NOT NULL,
60
+ ismaster boolean NOT NULL,
61
+ isworker boolean NOT NULL,
62
+ servicename character varying(128) COLLATE pg_catalog."default" NOT NULL,
63
+ serviceversion character varying(128) COLLATE pg_catalog."default" NOT NULL,
64
+
65
+ -- Leaf level attributes
66
+ -- Count based (summed in summary views)
67
+ request_count_gauge integer NULL,
68
+ error_count_gauge integer NULL,
69
+ retry_count_gauge integer NULL,
70
+ authentication_count_gauge integer NULL,
71
+ velocity_gauge integer NULL,
72
+ cpu_load_gauge integer NULL,
73
+ active_request_gauge integer NULL,
74
+ connection_count_gauge integer NULL,
75
+ connection_pool_total_gauge integer NULL,
76
+ connection_pool_idle_gauge integer NULL,
77
+ connection_pool_waiting_gauge integer NULL,
78
+ core_count_gauge integer NULL,
79
+
80
+ -- Define the gauges that provide a point in time value that conveys meaning at that point in time.
81
+ -- These values will not be aggregated (summed) in summary views.
82
+ timer_gauge integer NULL,
83
+
84
+ -- average gauges
85
+ duration_gauge integer NULL,
86
+ latency_gauge integer NULL,
87
+
88
+ -- Define the histogram gauges
89
+ duration_histogram_gauge integer ARRAY NULL,
90
+ latency_histogram_gauge integer ARRAY NULL,
91
+
92
+ -- Define logger based gauges
93
+ logger character varying(32768) COLLATE pg_catalog."default",
94
+
95
+ -- Standard STS attributes
96
+ validfrom timestamp with time zone NOT NULL,
97
+ validto timestamp with time zone,
98
+ vnum bigint NOT NULL,
99
+ dbaction smallint NOT NULL,
100
+ dbactionuser character varying(64) COLLATE pg_catalog."default" NOT NULL,
101
+ CONSTRAINT stsmonitor_pkey PRIMARY KEY (oid)
102
+ )
103
+
104
+ TABLESPACE pg_default;
105
+
106
+ ALTER TABLE public.stsmonitor
107
+ OWNER to postgres;
108
+ -- Index: stsresource_resname_vnum;
109
+
110
+ -- DROP INDEX public.stsresource_resname_vnum;
111
+
112
+ CREATE UNIQUE INDEX stsmonitor_prim_index
113
+ ON public.stsmonitor USING btree
114
+ (context COLLATE pg_catalog."default" ASC NULLS LAST,
115
+ servicetype COLLATE pg_catalog."default" ASC NULLS LAST,
116
+ serviceid COLLATE pg_catalog."default" ASC NULLS LAST,
117
+ serviceinstanceid COLLATE pg_catalog."default" ASC NULLS LAST,
118
+ serviceidhostname COLLATE pg_catalog."default" ASC NULLS LAST)
119
+ TABLESPACE pg_default;
120
+
121
+
122
+ CREATE OR REPLACE FUNCTION public.create_stsmonitor(
123
+ _dbactionuser character varying,
124
+
125
+ _context character varying,
126
+
127
+ _servicetype character varying,
128
+ _serviceid character varying,
129
+ _serviceinstanceid character varying,
130
+ _serviceidhostname character varying,
131
+
132
+ _serviceinstanceprocessid character varying,
133
+ _pid integer,
134
+ _ppid integer,
135
+ _ismaster boolean,
136
+ _isworker boolean,
137
+ _servicename character varying,
138
+ _serviceversion character varying,
139
+
140
+ -- Leaf level attributes
141
+ -- Count based (summed in summary views)
142
+ _request_count_gauge integer,
143
+ _error_count_gauge integer,
144
+ _retry_count_gauge integer,
145
+ _authentication_count_gauge integer,
146
+ _velocity_gauge integer,
147
+ _cpu_load_gauge integer,
148
+ _active_request_gauge integer,
149
+ _connection_count_gauge integer,
150
+ _connection_pool_total_gauge integer,
151
+ _connection_pool_idle_gauge integer,
152
+ _connection_pool_waiting_gauge integer,
153
+ _core_count_gauge integer,
154
+
155
+ -- Define the gauges that provide a point in time value that conveys meaning at that point in time.
156
+ -- These values will not be aggregated (summed) in summary views.
157
+ _timer_gauge integer,
158
+
159
+ -- average gauges
160
+ _duration_gauge integer,
161
+ _latency_gauge integer,
162
+
163
+ -- Define the histogram gauges
164
+ _duration_histogram_gauge integer ARRAY,
165
+ _latency_histogram_gauge integer ARRAY
166
+ )
167
+ RETURNS SETOF stsmonitor
168
+ LANGUAGE 'plpgsql'
169
+
170
+ COST 100
171
+ VOLATILE
172
+ ROWS 1000
173
+
174
+ AS $BODY$
175
+ DECLARE
176
+ __now timestamp without time zone := now();
177
+ __resoid bigint;
178
+ __vnum bigint;
179
+ __dbaction smallint;
180
+ __inserted_oid bigint;
181
+ BEGIN
182
+ begin
183
+ select oid, vnum, dbaction into __resoid, __vnum, __dbaction from stsmonitor m where m.context = _context and m.validto is null;
184
+ -- Too many records exists using the supplied data, the database is in an invalid state for this resource
185
+ exception
186
+ when sqlstate '21000' then
187
+ raise exception 'Too many stsmonitor records for current version using stsmonitor %', _context USING ERRCODE = 'cardinality_violation';
188
+ end;
189
+
190
+ if __resoid is not null then
191
+ -- We have an existing resource
192
+ if __dbaction = 3 then
193
+ -- The existing resource is deleted, update the current version
194
+ update stsmonitor
195
+
196
+ set context = _context,
197
+ servicetype = _servicetype,
198
+ serviceid = _serviceid,
199
+ serviceinstanceid = _serviceinstanceid,
200
+ serviceidhostname = _serviceidhostname,
201
+
202
+ serviceinstanceprocessid = _serviceinstanceprocessid,
203
+ pid = _pid,
204
+ ppid = _ppid,
205
+ ismaster = _ismaster,
206
+ isworker = _isworker,
207
+ servicename = _servicename,
208
+ serviceversion = _serviceversion,
209
+
210
+ request_count_gauge = _request_count_gauge,
211
+ error_count_gauge = _error_count_gauge,
212
+ retry_count_gauge = _retry_count_gauge,
213
+ authentication_count_gauge = _authentication_count_gauge,
214
+ velocity_gauge = _velocity_gauge,
215
+ cpu_load_gauge = _cpu_load_gauge,
216
+ active_request_gauge = _active_request_gauge,
217
+ connection_count_gauge = _connection_count_gauge,
218
+ connection_pool_total_gauge = _connection_pool_total_gauge,
219
+ connection_pool_idle_gauge = _connection_pool_idle_gauge,
220
+ connection_pool_waiting_gauge = _connection_pool_waiting_gauge,
221
+ core_count_gauge = _core_count_gauge,
222
+
223
+ timer_gauge = _timer_gauge,
224
+
225
+ duration_gauge = _duration_gauge,
226
+ latency_gauge = _latency_gauge,
227
+
228
+ duration_histogram_gauge = _duration_histogram_gauge,
229
+ latency_histogram_gauge = _latency_histogram_gauge,
230
+
231
+ validfrom = __now ,
232
+ dbactionuser = _dbactionuser
233
+
234
+ where oid = __resoid;
235
+
236
+ return query
237
+ select * from stsresource where oid = __resoid;
238
+ else
239
+ -- The current version is in an active state, raise unique violate condition
240
+ RAISE 'Duplicate context within stsmonitor: %', _resname USING ERRCODE = 'unique_violation';
241
+ end if;
242
+ else
243
+ /*
244
+ For some unknown reason, the below works in pg outside and inside a docker container
245
+ but does NOT work inside a docker swarm or a K3 cluster.
246
+ -- No current version exists, create a new record
247
+ return query
248
+ insert into stsresource(resname, resdesc, vnum, dbaction, dbactionuser, validfrom)
249
+ values (_resname, _resdesc, 1, 1, _dbactionuser, __now)
250
+ returning *;
251
+ */
252
+
253
+ insert into stsmonitor(
254
+ context,
255
+ servicetype,
256
+ serviceid,
257
+ serviceinstanceid,
258
+ serviceidhostname,
259
+
260
+ serviceinstanceprocessid,
261
+ pid,
262
+ ppid,
263
+ ismaster,
264
+ isworker,
265
+ servicename,
266
+ serviceversion,
267
+
268
+ request_count_gauge,
269
+ error_count_gauge,
270
+ retry_count_gauge,
271
+ authentication_count_gauge,
272
+ velocity_gauge,
273
+ cpu_load_gauge,
274
+ active_request_gauge,
275
+ connection_count_gauge,
276
+ connection_pool_total_gauge,
277
+ connection_pool_idle_gauge,
278
+ connection_pool_waiting_gauge,
279
+ core_count_gauge,
280
+
281
+ timer_gauge,
282
+
283
+ duration_gauge,
284
+ latency_gauge,
285
+
286
+ duration_histogram_gauge,
287
+ latency_histogram_gauge,
288
+
289
+ vnum, dbaction, dbactionuser, validfrom)
290
+ values (
291
+ _context,
292
+ _servicetype,
293
+ _serviceid,
294
+ _serviceinstanceid,
295
+ _serviceidhostname,
296
+
297
+ _serviceinstanceprocessid,
298
+ _pid,
299
+ _ppid,
300
+ _ismaster,
301
+ _isworker,
302
+ _servicename,
303
+ _serviceversion,
304
+
305
+ _request_count_gauge,
306
+ _error_count_gauge,
307
+ _retry_count_gauge,
308
+ _authentication_count_gauge,
309
+ _velocity_gauge,
310
+ _cpu_load_gauge,
311
+ _active_request_gauge,
312
+ _connection_count_gauge,
313
+ _connection_pool_total_gauge,
314
+ _connection_pool_idle_gauge,
315
+ _connection_pool_waiting_gauge,
316
+ _core_count_gauge,
317
+
318
+ _timer_gauge,
319
+
320
+ _duration_gauge,
321
+ _latency_gauge,
322
+
323
+ _duration_histogram_gauge,
324
+ _latency_histogram_gauge,
325
+
326
+ 1, 1, _dbactionuser, __now)
327
+ returning oid into __inserted_oid;
328
+
329
+ return query
330
+ select * from stsmonitor where oid = __inserted_oid;
331
+ end if;
332
+ END;
333
+ $BODY$;
334
+
335
+ ALTER FUNCTION public.create_stsmonitor(
336
+ character varying,
337
+
338
+ character varying,
339
+
340
+ character varying,
341
+ character varying,
342
+ character varying,
343
+ character varying,
344
+
345
+ character varying,
346
+ integer,
347
+ integer,
348
+ boolean,
349
+ boolean,
350
+ character varying,
351
+ character varying,
352
+
353
+ integer,
354
+ integer,
355
+ integer,
356
+ integer,
357
+ integer,
358
+ integer,
359
+ integer,
360
+ integer,
361
+ integer,
362
+ integer,
363
+ integer,
364
+ integer,
365
+
366
+ integer,
367
+
368
+ integer,
369
+ integer,
370
+
371
+ integer ARRAY,
372
+ integer ARRAY
373
+ )
374
+ OWNER TO postgres;
375
+
376
+
377
+
378
+
379
+
380
+ -- [ Table: public.stsresource ] ------------------------------------------------------------------------
32
381
 
33
382
  -- DROP TABLE public.stsresource;
34
383
 
@@ -204,7 +553,7 @@ BEGIN
204
553
  else
205
554
  /*
206
555
  For some unknown reason, the below works in pg outside and inside a docker container
207
- but does NOT work inside a docker swarm of a K3 cluster.
556
+ but does NOT work inside a docker swarm or a K3 cluster.
208
557
  -- No current version exists, create a new record
209
558
  return query
210
559
  insert into stsresource(resname, resdesc, vnum, dbaction, dbactionuser, validfrom)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nsshunt/stsdatamanagement",
3
- "version": "1.17.99",
3
+ "version": "1.17.100",
4
4
  "description": "STS Data Management Modules, Utilities and Services",
5
5
  "main": "./dist/dbaccess.js",
6
6
  "types": "./types/dbaccess.d.ts",
@@ -32,20 +32,20 @@
32
32
  "@tsconfig/node20": "^1.0.2",
33
33
  "@types/cli-progress": "^3.11.0",
34
34
  "@types/debug": "^4.1.8",
35
- "@types/node": "^20.3.2",
35
+ "@types/node": "^20.3.3",
36
36
  "@types/pg": "^8.10.2",
37
37
  "@types/pg-copy-streams": "^1.2.2",
38
38
  "@types/prompts": "^2.4.4",
39
39
  "@types/uuid": "^9.0.2",
40
- "@typescript-eslint/eslint-plugin": "^5.60.1",
41
- "@typescript-eslint/parser": "^5.60.1",
42
- "eslint": "^8.43.0",
40
+ "@typescript-eslint/eslint-plugin": "^5.61.0",
41
+ "@typescript-eslint/parser": "^5.61.0",
42
+ "eslint": "^8.44.0",
43
43
  "rollup-plugin-polyfill-node": "^0.12.0",
44
44
  "rollup-plugin-visualizer": "^5.9.2",
45
45
  "testcontainers": "^9.9.1",
46
46
  "typescript": "^5.1.6",
47
47
  "vite": "^4.3.2",
48
- "vitest": "^0.32.2"
48
+ "vitest": "^0.32.4"
49
49
  },
50
50
  "scripts": {
51
51
  "lint": "eslint . --ext js,jsx,ts,tsx",