Skip to content

Commit 7a54343

Browse files
committed
Add function comments for gRPC
1 parent d02272b commit 7a54343

File tree

2 files changed

+29
-10
lines changed

2 files changed

+29
-10
lines changed

chronos_npm_package/chronos.js

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,15 @@ chronos.track = () => {
101101
}
102102
return null;
103103
};
104-
/** ServerWrapper
104+
/**
105+
* Wraps the gRPC server object to automatically write logs to user configed DB
106+
*
105107
* If the provided database is MongoDB, connection will be made to the Mongodb Atlas
108+
*
106109
* If the provided database is PostgreSQL, connection will be made to PostgreSQL client
107-
* Passes userConfig
108-
* @param {*} server
109-
* @param {*} proto
110-
* @param {*} methods
110+
* @param {*} server
111+
* @param {*} proto
112+
* @param {*} methods
111113
*/
112114
chronos.ServerWrapper = (server, proto, methods) => {
113115
const { database } = userConfig;
@@ -119,7 +121,16 @@ chronos.ServerWrapper = (server, proto, methods) => {
119121
}
120122
return null;
121123
};
122-
124+
/**
125+
* Wraps the gRPC client to automatically write logs to user configed DB
126+
*
127+
* If the provided database is MongoDB, connection will be made to the Mongodb Atlas
128+
*
129+
* If the provided database is PostgreSQL, connection will be made to PostgreSQL client
130+
*
131+
* @param {*} client
132+
* @param {*} service
133+
*/
123134
chronos.ClientWrapper = (client, service) => {
124135
const { database } = userConfig;
125136
if (database.type === 'MongoDB') {
@@ -131,6 +142,12 @@ chronos.ClientWrapper = (client, service) => {
131142
return null;
132143
};
133144

145+
/**
146+
* Allows the passthrough of metadata from gRPC server to gRPC client
147+
*
148+
* @param {*} client
149+
* @param {*} servere
150+
*/
134151
chronos.link = (client, server) => {
135152
client.metadata = server.metadataHolder;
136153
};

chronos_npm_package/controllers/helpers.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const helpers = {
55
* Sets the default interval to 5 seconds and dockerized to false
66
*/
77
validateInput(config) {
8-
let { microservice, database, interval, dockerized, connection } = config;
8+
const { microservice, database, interval, dockerized, connection } = config;
99

1010
// Validate all required fields exist and are valid input types
1111
if (!microservice || typeof microservice !== 'string') {
@@ -20,7 +20,9 @@ const helpers = {
2020
throw new Error('Invalid input "database URI": Please provide the URI to your database');
2121
}
2222
if (!database.connection || typeof database.connection !== 'string') {
23-
throw new Error('Invalid input "database connection type: Please provide the type of connection');
23+
throw new Error(
24+
'Invalid input "database connection type: Please provide the type of connection'
25+
);
2426
}
2527

2628
// Validate database type
@@ -32,7 +34,7 @@ const helpers = {
3234
if (database.connection !== 'REST' && database.connection !== 'gRPC') {
3335
throw new Error(
3436
`Invalid database connection "${database.connection}". Chronos only supports REST and gRPC.`
35-
)
37+
);
3638
}
3739

3840
// Default interval to one minute
@@ -55,7 +57,7 @@ const helpers = {
5557

5658
// Setup notifications for user
5759
notifications.forEach(obj => {
58-
const type = obj.type;
60+
const { type } = obj;
5961

6062
// Throw errors on unsupported notification methods
6163
if (!features.includes(type)) {

0 commit comments

Comments
 (0)