Skip to content

Commit

Permalink
introduced connection and instance uuid for ris live
Browse files Browse the repository at this point in the history
  • Loading branch information
massimocandela committed Oct 25, 2021
1 parent 5dd90db commit a2ecdf4
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 10 deletions.
30 changes: 22 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
"rpki-validator": "^2.7.4",
"semver": "^7.3.5",
"syslog-client": "^1.1.1",
"uuid": "^8.3.2",
"ws": "^8.2.3",
"yargs": "^17.2.1"
},
Expand Down
3 changes: 2 additions & 1 deletion src/connectors/connectorRIS.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ export default class ConnectorRIS extends Connector {

this.url = brembo.build(this.params.url, {
params: {
client: env.clientId
client: env.clientId,
instance: env.instanceId
}
});
if (this.environment !== "research") { // The canary feature may impact performance if you are planning to get all the possible updates of RIS
Expand Down
2 changes: 2 additions & 0 deletions src/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import url from 'url';
import RpkiUtils from './utils/rpkiUtils';
import ConfigYml from './config/configYml';
import Config from "./config/config";
import { v4 as uuidv4 } from 'uuid';

const configConnector = new (global.EXTERNAL_CONFIG_CONNECTOR || ConfigYml);
const vector = {
Expand Down Expand Up @@ -192,5 +193,6 @@ vector.config = config;
vector.logger = wlogger;
vector.pubSub = new PubSub();
vector.rpki = new RpkiUtils(vector);
vector.instanceId = uuidv4();

module.exports = vector;
11 changes: 10 additions & 1 deletion src/utils/WebSocket.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import _ws from "ws";
import PubSub from "../utils/pubSub";
import brembo from "brembo";
import { v4 as uuidv4 } from 'uuid';

export default class WebSocket {
constructor(host, options) {
Expand Down Expand Up @@ -53,7 +55,14 @@ export default class WebSocket {
};

_connect = () => {
this.ws = new _ws(this.host, this.options);
const url = brembo.build(this.host.split("?")[0], {
params: {
...brembo.parse(this.host).params,
connection: uuidv4()
}
});

this.ws = new _ws(url, this.options);

this.ws.on('message', (data) => {
this.pubsub.publish("message", data);
Expand Down

0 comments on commit a2ecdf4

Please sign in to comment.