ServerSig - very lightweight and efficient websocket server connected to a database layer
92
If you want changes to any database table to be sent as a stream to a websocket recipient, you need to create an event table. The server, based on the event table, monitors whether changes have occurred in the source table and, if so, sends them to the server's buffers and from there to connected clients. The server allows you to define the fields that will be sent in the stream. Multiple source tables can be defined in the server (as DSN). The server is very efficient - it can handle up to tens of thousands of connections.
DSN is defined as one line with fields separated && where the individual fields represent the following:
Name - name of DSNJDBC URL - connect string to databaseUser - user in databasePassword - password for user (you can encrypt password - script runenc.sh - then you must enter the password in the format [encrypted]<encrypted password>)
level - 0 - only one row is store in buffor (the index is the first field in the field definition for a given DSN), N - in buffor is stored N rowsnumber of skip messages - default is 0 (this parameter allows you to skip some messages when the table is changing very quickly and the above parameter is set to 0 or a low value (this value should be calculated as (1 or N) * number of unique values in the first field defining the DSN * 2)source table - table with dataevent table - table to check if there were changes to the source table (based on the number field)event time - sleep time before next check when check showed changescontrol buffer - not usedcount time - sleep time before next check when previous check showed no changeswhere - fragment of an SQL query returning data from the source tableSource table:
CREATE TABLE ws_counter1
( id BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 1),
name character varying (20),
value1 int,
value2 DECIMAL(21,2),
reg_time character varying (40));
Event table:
CREATE TABLE ews_counter1 (
number BIGINT GENERATED BY DEFAULT AS IDENTITY(START WITH 1),
reg_time character varying (40));
And of course triggers:
CREATE TRIGGER i_ews_counter1 AFTER INSERT ON ws_counter1
FOR EACH ROW
BEGIN ATOMIC
DELETE FROM ews_counter1 WHERE 1 = 1;
INSERT INTO ews_counter1 (reg_time) VALUES (CURRENT_TIMESTAMP);
END;
CREATE TRIGGER u_ews_counter1 AFTER UPDATE ON ws_counter1
FOR EACH ROW
BEGIN ATOMIC
DELETE FROM ews_counter1 WHERE 1 = 1;
INSERT INTO ews_counter1 (reg_time) VALUES (CURRENT_TIMESTAMP);
END;
Definition of fields:
DSN10=counter1_a&&jdbc:hsqldb:hsql://localhost:9001/baseA&&SA&&-1000&&0&&0&&ws_counter1&&ews_counter1&&2000&&0&&2000&& id>%s order by id
Field10=ws_counter1,name,%s
Field20=ws_counter1,value1,%s
Field30=ws_counter1,value2,%s
Field40=ws_counter1,reg_time,%s
Field50=ws_counter1,id,%s
You can run the default serversig command simply:
docker run -itd -p 8089:8089 -p 8791:8791 -p 8086:8086 -e ENV_STR_LICENSE=<license_string> --name serversig gemail/serversig
or for demo:
docker run -itd -p 8089:8089 -p 8791:8791 -p 8086:8086 --name serversig gemail/serversig
Where port:
Without ENV_STR_LICENSE server allows to connect 5 clients per DSN.
If you want see example:
https://<address_ip_docker_host>:8089/serversig.html
You should see something like this (example of two tables with automatic data change):

if you want metrics for prometheus:
http://<address_ip_docker_host>:8086/metrics
or another command:
http://<address_ip_docker_host>:8086/servers
http://<address_ip_docker_host>:8086/connections
http://<address_ip_docker_host>:8086/workers
or check healthy:
http://<address_ip_docker_host>:8086/health
For a proper understanding of the operation of the ServerSIG , it is recommended to log in to the running container:
docker exec -it serversig bash
nonopresentation of stock quotes
presentation of sports results
presentation of currency prices
Content type
Image
Digest
sha256:8be7bb4dd…
Size
152.8 MB
Last updated
7 days ago
docker pull gemail/serversig