Skip to content

Commit 8a7a75f

Browse files
author
root
committed
env changes
1 parent 3e8f23f commit 8a7a75f

File tree

6 files changed

+92
-7
lines changed

6 files changed

+92
-7
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
node_modules
33
*.log
44
env_producer.sh
5+
package-lock.json
56
env_consumer.sh

config/default.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
const path = require('path')
2+
3+
module.exports = {
4+
LOG_LEVEL: process.env.LOG_LEVEL || 'debug', // Winston log level
5+
LOG_FILE: path.join(__dirname, '../app.log'), // File to write logs to
6+
INFORMIX: { // Informix connection options
7+
host: process.env.INFORMIX_HOST || 'localhost',
8+
port: parseInt(process.env.INFORMIX_PORT, 10) || 2021,
9+
user: process.env.INFORMIX_USER || 'informix',
10+
password: process.env.INFORMIX_PASSWORD || '1nf0rm1x',
11+
database: process.env.INFORMIX_DATABASE || 'tcs_catalog',
12+
server: process.env.INFORMIX_SERVER || 'informixoltp_tcp',
13+
minpool: parseInt(process.env.MINPOOL, 10) || 1,
14+
maxpool: parseInt(process.env.MAXPOOL, 10) || 60,
15+
maxsize: parseInt(process.env.MAXSIZE, 10) || 0,
16+
idleTimeout: parseInt(process.env.IDLETIMEOUT, 10) || 3600,
17+
timeout: parseInt(process.env.TIMEOUT, 10) || 30000
18+
},
19+
POSTGRES: { // Postgres connection options
20+
user: process.env.PG_USER || 'mayur',
21+
host: process.env.PG_HOST || 'localhost',
22+
database: process.env.PG_DATABASE || 'postgres', // database must exist before running the tool
23+
password: process.env.PG_PASSWORD || 'password',
24+
port: parseInt(process.env.PG_PORT, 10) || 5432,
25+
triggerFunctions: process.env.TRIGGER_FUNCTIONS || ['db_notifications'], // List of trigger functions to listen to
26+
triggerTopics: process.env.TRIGGER_TOPICS || ['db.postgres.sync'], // Names of the topic in the trigger payload
27+
triggerOriginators: process.env.TRIGGER_ORIGINATORS || ['tc-postgres-delta-processor'] // Names of the originator in the trigger payload
28+
},
29+
KAFKA: { // Kafka connection options
30+
brokers_url: process.env.KAFKA_URL || 'localhost:9092', // comma delimited list of initial brokers list
31+
SSL: {
32+
cert: process.env.KAFKA_SSL_CERT || null, // SSL client certificate file path
33+
key: process.env.KAFKA_SSL_KEY || null // SSL client key file path
34+
},
35+
topic: process.env.KAFKA_TOPIC || 'db.postgres.sync', // Kafka topic to push and receive messages
36+
partition: process.env.partition || [0] // Kafka partitions to use
37+
},
38+
39+
AUTH0_URL: process.env.AUTH0_URL ,
40+
AUTH0_AUDIENCE: process.env.AUTH0_AUDIENCE ,
41+
TOKEN_CACHE_TIME: process.env.TOKEN_CACHE_TIME ,
42+
AUTH0_CLIENT_ID: process.env.AUTH0_CLIENT_ID ,
43+
AUTH0_CLIENT_SECRET: process.env.AUTH0_CLIENT_SECRET ,
44+
BUSAPI_URL : process.env.BUSAPI_URL ,
45+
KAFKA_ERROR_TOPIC : process.env.KAFKA_ERROR_TOPIC ,
46+
AUTH0_PROXY_SERVER_URL: process.env.AUTH0_PROXY_SERVER_URL
47+
}

config/test.js

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
const path = require('path')
2+
3+
module.exports = {
4+
LOG_LEVEL: process.env.LOG_LEVEL || 'debug', // Winston log level
5+
LOG_FILE: path.join(__dirname, '../app.log'), // File to write logs to
6+
INFORMIX: { // Informix connection options
7+
host: process.env.INFORMIX_HOST || 'localhost',
8+
port: parseInt(process.env.INFORMIX_PORT, 10) || 2021,
9+
user: process.env.INFORMIX_USER || 'informix',
10+
password: process.env.INFORMIX_PASSWORD || '1nf0rm1x',
11+
database: process.env.INFORMIX_DATABASE || 'tcs_catalog',
12+
server: process.env.INFORMIX_SERVER || 'informixoltp_tcp',
13+
minpool: parseInt(process.env.MINPOOL, 10) || 1,
14+
maxpool: parseInt(process.env.MAXPOOL, 10) || 60,
15+
maxsize: parseInt(process.env.MAXSIZE, 10) || 0,
16+
idleTimeout: parseInt(process.env.IDLETIMEOUT, 10) || 3600,
17+
timeout: parseInt(process.env.TIMEOUT, 10) || 30000
18+
},
19+
POSTGRES: { // Postgres connection options
20+
user: process.env.PG_USER || 'mayur',
21+
host: process.env.PG_HOST || 'localhost',
22+
database: process.env.PG_DATABASE || 'postgres', // database must exist before running the tool
23+
password: process.env.PG_PASSWORD || 'password',
24+
port: parseInt(process.env.PG_PORT, 10) || 5432,
25+
triggerFunctions: process.env.triggerFunctions || ['db_notifications'], // List of trigger functions to listen to
26+
triggerTopics: process.env.TRIGGER_TOPICS || ['db.postgres.sync'], // Names of the topic in the trigger payload
27+
triggerOriginators: process.env.TRIGGER_ORIGINATORS || ['tc-postgres-delta-processor'] // Names of the originator in the trigger payload
28+
},
29+
KAFKA: { // Kafka connection options
30+
brokers_url: process.env.KAFKA_URL || 'localhost:9092', // comma delimited list of initial brokers list
31+
SSL: {
32+
cert: process.env.KAFKA_SSL_CERT || null, // SSL client certificate file path
33+
key: process.env.KAFKA_SSL_KEY || null // SSL client key file path
34+
},
35+
topic: process.env.KAFKA_TOPIC || 'db.postgres.sync', // Kafka topic to push and receive messages
36+
partition: process.env.partition || [0] // Kafka partitions to use
37+
},
38+
TEST_TABLE: 'scorecard', // Name of test table to use. Triggers for this table must exist
39+
TEST_SCHEMA: 'tcs_catalog', // Name of schema "TEST_TABLE" belongs to
40+
TEST_INTERVAL: 5000 // 5s interval to wait for postgres DML updates to be propagated to informix
41+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"winston": "^3.2.1",
2323
"lodash": "^4.17.15",
2424
"topcoder-bus-api-wrapper": "^1.0.1",
25-
"topcoder-healthcheck-dropin": "^1.0.3",
25+
"topcoder-healthcheck-dropin": "^1.0.3"
2626
},
2727
"devDependencies": {
2828
"chai": "^4.2.0",

src/consumer.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const config = require('config')
55
const Kafka = require('no-kafka')
66
const logger = require('./common/logger')
77
const informix = require('./common/informixWrapper.js')
8-
8+
const healthcheck = require('topcoder-healthcheck-dropin');
99
const kafkaOptions = config.get('KAFKA')
1010
const isSslEnabled = kafkaOptions.SSL && kafkaOptions.SSL.cert && kafkaOptions.SSL.key
1111
const consumer = new Kafka.SimpleConsumer({
@@ -63,8 +63,6 @@ async function updateInformix (payload) {
6363
break
6464
case 'delete':
6565
{
66-
// const columns = payload.data
67-
//const primaryKey = payload.Uniquecolumn
6866
sql = `delete from ${payload.payload.schema}:${payload.payload.table} where ${primaryKey}=${columns[primaryKey]};` // ""delete from <schema>:<table> where primary_key_col=primary_key_val"
6967
}
7068
break

src/producer.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@ const express = require('express')
1616
const app = express()
1717
const port = 3000
1818

19-
2019
const busApiClient = busApi(_.pick(config,
2120
['AUTH0_URL', 'AUTH0_AUDIENCE', 'TOKEN_CACHE_TIME',
2221
'AUTH0_CLIENT_ID', 'AUTH0_CLIENT_SECRET', 'BUSAPI_URL',
2322
'KAFKA_ERROR_TOPIC', 'AUTH0_PROXY_SERVER_URL']))
24-
2523
busApiClient
2624
.getHealth()
2725
.then(result => console.log(result.body, result.status))
@@ -78,6 +76,6 @@ run()
7876

7977
app.get('/health', (req, res) => {
8078
//console.log('pgClient', pgClient)
81-
res.send('ok')
79+
res.send('health ok')
8280
})
8381
app.listen(port, () => console.log(`Example app listening on port ${port}!`))

0 commit comments

Comments
 (0)