refactored
This commit is contained in:
parent
b8a305ec57
commit
9ef3445b77
@ -14,7 +14,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
service-type: "TB_SERVICE_TYPE" #kafka (Apache Kafka) or aws-sqs (AWS SQS) or pubsub (PubSub) or service-bus (Azure Service Bus) or rabbitmq (RabbitMQ)
|
queue_type: "TB_QUEUE_TYPE" #kafka (Apache Kafka) or aws-sqs (AWS SQS) or pubsub (PubSub) or service-bus (Azure Service Bus) or rabbitmq (RabbitMQ)
|
||||||
request_topic: "REMOTE_JS_EVAL_REQUEST_TOPIC"
|
request_topic: "REMOTE_JS_EVAL_REQUEST_TOPIC"
|
||||||
|
|
||||||
js:
|
js:
|
||||||
@ -25,18 +25,18 @@ kafka:
|
|||||||
# Kafka Bootstrap Servers
|
# Kafka Bootstrap Servers
|
||||||
servers: "TB_KAFKA_SERVERS"
|
servers: "TB_KAFKA_SERVERS"
|
||||||
replication_factor: "TB_QUEUE_KAFKA_REPLICATION_FACTOR"
|
replication_factor: "TB_QUEUE_KAFKA_REPLICATION_FACTOR"
|
||||||
topic-properties: "TB_QUEUE_KAFKA_JE_TOPIC_PROPERTIES"
|
topic_properties: "TB_QUEUE_KAFKA_JE_TOPIC_PROPERTIES"
|
||||||
|
|
||||||
pubsub:
|
pubsub:
|
||||||
project_id: "TB_QUEUE_PUBSUB_PROJECT_ID"
|
project_id: "TB_QUEUE_PUBSUB_PROJECT_ID"
|
||||||
service_account: "TB_QUEUE_PUBSUB_SERVICE_ACCOUNT"
|
service_account: "TB_QUEUE_PUBSUB_SERVICE_ACCOUNT"
|
||||||
queue-properties: "TB_QUEUE_PUBSUB_JE_QUEUE_PROPERTIES"
|
queue_properties: "TB_QUEUE_PUBSUB_JE_QUEUE_PROPERTIES"
|
||||||
|
|
||||||
aws_sqs:
|
aws_sqs:
|
||||||
access_key_id: "TB_QUEUE_AWS_SQS_ACCESS_KEY_ID"
|
access_key_id: "TB_QUEUE_AWS_SQS_ACCESS_KEY_ID"
|
||||||
secret_access_key: "TB_QUEUE_AWS_SQS_SECRET_ACCESS_KEY"
|
secret_access_key: "TB_QUEUE_AWS_SQS_SECRET_ACCESS_KEY"
|
||||||
region: "TB_QUEUE_AWS_SQS_REGION"
|
region: "TB_QUEUE_AWS_SQS_REGION"
|
||||||
queue-properties: "TB_QUEUE_AWS_SQS_JE_QUEUE_PROPERTIES"
|
queue_properties: "TB_QUEUE_AWS_SQS_JE_QUEUE_PROPERTIES"
|
||||||
|
|
||||||
rabbitmq:
|
rabbitmq:
|
||||||
host: "TB_QUEUE_RABBIT_MQ_HOST"
|
host: "TB_QUEUE_RABBIT_MQ_HOST"
|
||||||
@ -44,14 +44,14 @@ rabbitmq:
|
|||||||
virtual_host: "TB_QUEUE_RABBIT_MQ_VIRTUAL_HOST"
|
virtual_host: "TB_QUEUE_RABBIT_MQ_VIRTUAL_HOST"
|
||||||
username: "TB_QUEUE_RABBIT_MQ_USERNAME"
|
username: "TB_QUEUE_RABBIT_MQ_USERNAME"
|
||||||
password: "TB_QUEUE_RABBIT_MQ_PASSWORD"
|
password: "TB_QUEUE_RABBIT_MQ_PASSWORD"
|
||||||
queue-properties: "TB_QUEUE_RABBIT_MQ_JE_QUEUE_PROPERTIES"
|
queue_properties: "TB_QUEUE_RABBIT_MQ_JE_QUEUE_PROPERTIES"
|
||||||
|
|
||||||
service_bus:
|
service_bus:
|
||||||
namespace_name: "TB_QUEUE_SERVICE_BUS_NAMESPACE_NAME"
|
namespace_name: "TB_QUEUE_SERVICE_BUS_NAMESPACE_NAME"
|
||||||
sas_key_name: "TB_QUEUE_SERVICE_BUS_SAS_KEY_NAME"
|
sas_key_name: "TB_QUEUE_SERVICE_BUS_SAS_KEY_NAME"
|
||||||
sas_key: "TB_QUEUE_SERVICE_BUS_SAS_KEY"
|
sas_key: "TB_QUEUE_SERVICE_BUS_SAS_KEY"
|
||||||
max_messages: "TB_QUEUE_SERVICE_BUS_MAX_MESSAGES"
|
max_messages: "TB_QUEUE_SERVICE_BUS_MAX_MESSAGES"
|
||||||
queue-properties: "TB_QUEUE_SERVICE_BUS_JE_QUEUE_PROPERTIES"
|
queue_properties: "TB_QUEUE_SERVICE_BUS_JE_QUEUE_PROPERTIES"
|
||||||
|
|
||||||
logger:
|
logger:
|
||||||
level: "LOGGER_LEVEL"
|
level: "LOGGER_LEVEL"
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
#
|
#
|
||||||
|
|
||||||
service-type: "kafka"
|
queue_type: "kafka"
|
||||||
request_topic: "js_eval.requests"
|
request_topic: "js_eval.requests"
|
||||||
|
|
||||||
js:
|
js:
|
||||||
@ -25,13 +25,13 @@ kafka:
|
|||||||
# Kafka Bootstrap Servers
|
# Kafka Bootstrap Servers
|
||||||
servers: "localhost:9092"
|
servers: "localhost:9092"
|
||||||
replication_factor: "1"
|
replication_factor: "1"
|
||||||
topic-properties: "retention.ms:604800000;segment.bytes:26214400;retention.bytes:104857600"
|
topic_properties: "retention.ms:604800000;segment.bytes:26214400;retention.bytes:104857600"
|
||||||
|
|
||||||
pubsub:
|
pubsub:
|
||||||
queue-properties: "ackDeadlineInSec:30;messageRetentionInSec:604800"
|
queue_properties: "ackDeadlineInSec:30;messageRetentionInSec:604800"
|
||||||
|
|
||||||
aws_sqs:
|
aws_sqs:
|
||||||
queue-properties: "VisibilityTimeout:30;MaximumMessageSize:262144;MessageRetentionPeriod:604800"
|
queue_properties: "VisibilityTimeout:30;MaximumMessageSize:262144;MessageRetentionPeriod:604800"
|
||||||
|
|
||||||
rabbitmq:
|
rabbitmq:
|
||||||
host: "localhost"
|
host: "localhost"
|
||||||
@ -39,10 +39,10 @@ rabbitmq:
|
|||||||
virtual_host: "/"
|
virtual_host: "/"
|
||||||
username: "admin"
|
username: "admin"
|
||||||
password: "password"
|
password: "password"
|
||||||
queue-properties: "x-max-length-bytes:1048576000;x-message-ttl:604800000"
|
queue_properties: "x-max-length-bytes:1048576000;x-message-ttl:604800000"
|
||||||
|
|
||||||
service_bus:
|
service_bus:
|
||||||
queue-properties: "lockDurationInSec:30;maxSizeInMb:1024;messageTimeToLiveInSec:604800"
|
queue_properties: "lockDurationInSec:30;maxSizeInMb:1024;messageTimeToLiveInSec:604800"
|
||||||
|
|
||||||
logger:
|
logger:
|
||||||
level: "info"
|
level: "info"
|
||||||
|
|||||||
@ -26,7 +26,7 @@ const accessKeyId = config.get('aws_sqs.access_key_id');
|
|||||||
const secretAccessKey = config.get('aws_sqs.secret_access_key');
|
const secretAccessKey = config.get('aws_sqs.secret_access_key');
|
||||||
const region = config.get('aws_sqs.region');
|
const region = config.get('aws_sqs.region');
|
||||||
const AWS = require('aws-sdk');
|
const AWS = require('aws-sdk');
|
||||||
const queueProperties = config.get('aws_sqs.queue-properties');
|
const queueProperties = config.get('aws_sqs.queue_properties');
|
||||||
const poolInterval = config.get('js.response_poll_interval');
|
const poolInterval = config.get('js.response_poll_interval');
|
||||||
|
|
||||||
let queueAttributes = {FifoQueue: 'true', ContentBasedDeduplication: 'true'};
|
let queueAttributes = {FifoQueue: 'true', ContentBasedDeduplication: 'true'};
|
||||||
|
|||||||
@ -20,7 +20,7 @@ const config = require('config'),
|
|||||||
logger = require('../config/logger')._logger('kafkaTemplate'),
|
logger = require('../config/logger')._logger('kafkaTemplate'),
|
||||||
KafkaJsWinstonLogCreator = require('../config/logger').KafkaJsWinstonLogCreator;
|
KafkaJsWinstonLogCreator = require('../config/logger').KafkaJsWinstonLogCreator;
|
||||||
const replicationFactor = config.get('kafka.replication_factor');
|
const replicationFactor = config.get('kafka.replication_factor');
|
||||||
const topicProperties = config.get('kafka.topic-properties');
|
const topicProperties = config.get('kafka.topic_properties');
|
||||||
|
|
||||||
let kafkaClient;
|
let kafkaClient;
|
||||||
let kafkaAdmin;
|
let kafkaAdmin;
|
||||||
|
|||||||
@ -24,7 +24,7 @@ const {PubSub} = require('@google-cloud/pubsub');
|
|||||||
const projectId = config.get('pubsub.project_id');
|
const projectId = config.get('pubsub.project_id');
|
||||||
const credentials = JSON.parse(config.get('pubsub.service_account'));
|
const credentials = JSON.parse(config.get('pubsub.service_account'));
|
||||||
const requestTopic = config.get('request_topic');
|
const requestTopic = config.get('request_topic');
|
||||||
const queueProperties = config.get('pubsub.queue-properties');
|
const queueProperties = config.get('pubsub.queue_properties');
|
||||||
|
|
||||||
let pubSubClient;
|
let pubSubClient;
|
||||||
|
|
||||||
|
|||||||
@ -26,7 +26,7 @@ const port = config.get('rabbitmq.port');
|
|||||||
const vhost = config.get('rabbitmq.virtual_host');
|
const vhost = config.get('rabbitmq.virtual_host');
|
||||||
const username = config.get('rabbitmq.username');
|
const username = config.get('rabbitmq.username');
|
||||||
const password = config.get('rabbitmq.password');
|
const password = config.get('rabbitmq.password');
|
||||||
const queueProperties = config.get('rabbitmq.queue-properties');
|
const queueProperties = config.get('rabbitmq.queue_properties');
|
||||||
const poolInterval = config.get('js.response_poll_interval');
|
const poolInterval = config.get('js.response_poll_interval');
|
||||||
|
|
||||||
const amqp = require('amqplib/callback_api');
|
const amqp = require('amqplib/callback_api');
|
||||||
|
|||||||
@ -26,7 +26,7 @@ const requestTopic = config.get('request_topic');
|
|||||||
const namespaceName = config.get('service_bus.namespace_name');
|
const namespaceName = config.get('service_bus.namespace_name');
|
||||||
const sasKeyName = config.get('service_bus.sas_key_name');
|
const sasKeyName = config.get('service_bus.sas_key_name');
|
||||||
const sasKey = config.get('service_bus.sas_key');
|
const sasKey = config.get('service_bus.sas_key');
|
||||||
const queueProperties = config.get('service_bus.queue-properties');
|
const queueProperties = config.get('service_bus.queue_properties');
|
||||||
|
|
||||||
let sbClient;
|
let sbClient;
|
||||||
let receiverClient;
|
let receiverClient;
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
const config = require('config'), logger = require('./config/logger')._logger('main');
|
const config = require('config'), logger = require('./config/logger')._logger('main');
|
||||||
|
|
||||||
const serviceType = config.get('service-type');
|
const serviceType = config.get('queue_type');
|
||||||
switch (serviceType) {
|
switch (serviceType) {
|
||||||
case 'kafka':
|
case 'kafka':
|
||||||
logger.info('Starting kafka template.');
|
logger.info('Starting kafka template.');
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user