Skip to content

Commit 11264cb

Browse files
authored
Merge pull request #79 from eisbilir/work-period-automation
Work period automation
2 parents 4217172 + e1e127d commit 11264cb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+2761
-212
lines changed

.circleci/config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ workflows:
7272
only:
7373
- dev
7474
- dev-circleci
75+
- change-validatations-in-job-j
7576

7677
# Production builds are exectuted only on tagged commits to the
7778
# master branch.

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ coverage
55
.DS_Store
66
.env
77
api.env
8+
.eslintrc.y*ml

.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
12

README.md

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ The following parameters can be set in config files or in env variables:
2020
- `KAFKA_CLIENT_CERT_KEY`: Kafka connection private key, optional;
2121
if not provided, then SSL connection is not used, direct insecure connection is used;
2222
if provided, it can be either path to private key file or private key content
23+
- `KAFKA_MESSAGE_ORIGINATOR`: The originator value for the kafka messages
2324
- `KAFKA_GROUP_ID`: the Kafka group id
25+
- `topics.KAFKA_ERROR_TOPIC`: the error topic at which bus api will publish any errors
2426
- `topics.TAAS_JOB_CREATE_TOPIC`: the create job entity Kafka message topic
2527
- `topics.TAAS_JOB_UPDATE_TOPIC`: the update job entity Kafka message topic
2628
- `topics.TAAS_JOB_DELETE_TOPIC`: the delete job entity Kafka message topic
@@ -33,6 +35,18 @@ The following parameters can be set in config files or in env variables:
3335
- `topics.TAAS_WORK_PERIOD_CREATE_TOPIC`: the create work period entity Kafka message topic
3436
- `topics.TAAS_WORK_PERIOD_UPDATE_TOPIC`: the update work period entity Kafka message topic
3537
- `topics.TAAS_WORK_PERIOD_DELETE_TOPIC`: the delete work period entity Kafka message topic
38+
- `topics.TAAS_WORK_PERIOD_PAYMENT_CREATE_TOPIC`: the create work period payment entity Kafka message topic
39+
- `topics.TAAS_WORK_PERIOD_PAYMENT_UPDATE_TOPIC`: the update work period payment entity Kafka message topic
40+
- `topics.TAAS_INTERVIEW_REQUEST_TOPIC`: the request interview entity Kafka message topic
41+
- `topics.TAAS_INTERVIEW_UPDATE_TOPIC`: the update interview entity Kafka message topic
42+
- `topics.TAAS_INTERVIEW_BULK_UPDATE_TOPIC`: the bulk update interview entity Kafka message topic
43+
- `topics.TAAS_ROLE_CREATE_TOPIC`: the create role entity Kafka message topic
44+
- `topics.TAAS_ROLE_UPDATE_TOPIC`: the update role entity Kafka message topic
45+
- `topics.TAAS_ROLE_DELETE_TOPIC`: the delete role entity Kafka message topic
46+
- `topics.TAAS_ACTION_RETRY_TOPIC`: the retry process Kafka message topic
47+
- `MAX_RETRY`: maximum allowed retry count for failed operations for sending `taas.action.retry` message
48+
- `BASE_RETRY_DELAY`: base amount of retry delay (ms) for failed operations
49+
- `BUSAPI_URL`: Topcoder Bus API URL
3650
- `esConfig.HOST`: Elasticsearch host
3751
- `esConfig.AWS_REGION`: The Amazon region to use when using AWS Elasticsearch service
3852
- `esConfig.ELASTICCLOUD.id`: The elastic cloud id, if your elasticsearch instance is hosted on elastic cloud. DO NOT provide a value for ES_HOST if you are using this
@@ -41,13 +55,14 @@ The following parameters can be set in config files or in env variables:
4155
- `esConfig.ES_INDEX_JOB`: the index name for job
4256
- `esConfig.ES_INDEX_JOB_CANDIDATE`: the index name for job candidate
4357
- `esConfig.ES_INDEX_RESOURCE_BOOKING`: the index name for resource booking
44-
- `esConfig.ES_INDEX_WORK_PERIOD`: the index name for work period
58+
- `esConfig.ES_INDEX_ROLE`: the index name for role
4559

4660
- `auth0.AUTH0_URL`: Auth0 URL, used to get TC M2M token
4761
- `auth0.AUTH0_AUDIENCE`: Auth0 audience, used to get TC M2M token
4862
- `auth0.AUTH0_CLIENT_ID`: Auth0 client id, used to get TC M2M token
4963
- `auth0.AUTH0_CLIENT_SECRET`: Auth0 client secret, used to get TC M2M token
5064
- `auth0.AUTH0_PROXY_SERVER_URL`: Proxy Auth0 URL, used to get TC M2M token
65+
- `auth0.TOKEN_CACHE_TIME`: Auth0 token cache time, used to get TC M2M token
5166

5267
- `zapier.ZAPIER_COMPANYID_SLUG`: your company id in zapier; numeric value
5368
- `zapier.ZAPIER_CONTACTID_SLUG`: your contact id in zapier; numeric value
@@ -75,7 +90,13 @@ The following parameters can be set in config files or in env variables:
7590

7691
## Local deployment
7792

78-
1. Make sure that Kafka and Elasticsearch is running as per instructions above.
93+
0. Make sure that Kafka and Elasticsearch is running as per instructions above.
94+
95+
1. Make sure to use Node v12+ by command `node -v`. We recommend using [NVM](https://github.com/nvm-sh/nvm) to quickly switch to the right version:
96+
97+
```bash
98+
nvm use
99+
```
79100

80101
2. From the project root directory, run the following command to install the dependencies
81102

@@ -95,6 +116,21 @@ The following parameters can be set in config files or in env variables:
95116
npm run lint:fix
96117
```
97118

119+
4. Local config
120+
121+
In the `taas-es-processor` root directory create `.env` file with the next environment variables. Values for **Auth0 config** should be shared with you on the forum.<br>
122+
123+
```bash
124+
# Auth0 config
125+
AUTH0_URL=
126+
AUTH0_AUDIENCE=
127+
AUTH0_CLIENT_ID=
128+
AUTH0_CLIENT_SECRET=
129+
```
130+
131+
- Values from this file would be automatically used by many `npm` commands.
132+
- ⚠️ Never commit this file or its copy to the repository!
133+
98134
5. Start the processor and health check dropin
99135

100136
```bash

VERIFICATION.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,39 +2,51 @@
22

33
## Create documents in ES
44

5-
- Run the following commands to create `Job`, `JobCandidate`, `ResourceBooking`, `WorkPeriod` documents in ES.
5+
- Run the following commands to create `Job`, `JobCandidate`, `Interview`, `ResourceBooking`, `WorkPeriod`, `WorkPeriodPayment`, `Role` documents in ES.
66

77
``` bash
88
# for Job
99
docker exec -i taas-es-processor_kafka /opt/kafka/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic taas.job.create < test/messages/taas.job.create.event.json
1010
# for JobCandidate
1111
docker exec -i taas-es-processor_kafka /opt/kafka/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic taas.jobcandidate.create < test/messages/taas.jobcandidate.create.event.json
12+
# for Interview
13+
docker exec -i taas-es-processor_kafka /opt/kafka/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic taas.interview.requested < test/messages/taas.interview.requested.event.json
1214
# for ResourceBooking
1315
docker exec -i taas-es-processor_kafka /opt/kafka/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic taas.resourcebooking.create < test/messages/taas.resourcebooking.create.event.json
1416
# for WorkPeriod
1517
docker exec -i taas-es-processor_kafka /opt/kafka/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic taas.workperiod.create < test/messages/taas.workperiod.create.event.json
18+
# for WorkPeriodPayment
19+
docker exec -i taas-es-processor_kafka /opt/kafka/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic taas.workperiodpayment.create < test/messages/taas.workperiodpayment.create.event.json
20+
# for Role
21+
docker exec -i taas-es-processor_kafka /opt/kafka/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic taas.role.requested < test/messages/taas.role.create.event.json
1622
```
1723

1824
- Run `npm run view-data <model-name-here>` to see if documents were created.
1925

2026
## Update documents in ES
21-
- Run the following commands to update `Job`, `JobCandidate`, `ResourceBooking`, `WorkPeriod` documents in ES.
27+
- Run the following commands to update `Job`, `JobCandidate`, `Interview`, `ResourceBooking`, `WorkPeriod`, `WorkPeriodPayment`, `Role` documents in ES.
2228

2329
``` bash
2430
# for Job
2531
docker exec -i taas-es-processor_kafka /opt/kafka/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic taas.job.update < test/messages/taas.job.update.event.json
2632
# for JobCandidate
2733
docker exec -i taas-es-processor_kafka /opt/kafka/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic taas.jobcandidate.update < test/messages/taas.jobcandidate.update.event.json
34+
# for Interview
35+
docker exec -i taas-es-processor_kafka /opt/kafka/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic taas.interview.update < test/messages/taas.interview.update.event.json
2836
# for ResourceBooking
2937
docker exec -i taas-es-processor_kafka /opt/kafka/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic taas.resourcebooking.update < test/messages/taas.resourcebooking.update.event.json
3038
# for WorkPeriod
3139
docker exec -i taas-es-processor_kafka /opt/kafka/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic taas.workperiod.update < test/messages/taas.workperiod.update.event.json
40+
# for WorkPeriodPayment
41+
docker exec -i taas-es-processor_kafka /opt/kafka/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic taas.workperiodpayment.update < test/messages/taas.workperiodpayment.update.event.json
42+
# for Role
43+
docker exec -i taas-es-processor_kafka /opt/kafka/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic taas.role.update < test/messages/taas.role.update.event.json
3244
```
3345

3446
- Run `npm run view-data <model-name-here>` to see if documents were updated.
3547

3648
## Delete documents in ES
37-
- Run the following commands to delete `Job`, `JobCandidate`, `ResourceBooking`, `WorkPeriod` documents in ES.
49+
- Run the following commands to delete `Job`, `JobCandidate`, `ResourceBooking`, `WorkPeriod`, `Role` documents in ES.
3850

3951
``` bash
4052
# for Job
@@ -45,6 +57,8 @@
4557
docker exec -i taas-es-processor_kafka /opt/kafka/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic taas.resourcebooking.delete < test/messages/taas.resourcebooking.delete.event.json
4658
# for WorkPeriod
4759
docker exec -i taas-es-processor_kafka /opt/kafka/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic taas.workperiod.delete < test/messages/taas.workperiod.delete.event.json
60+
# for Role
61+
docker exec -i taas-es-processor_kafka /opt/kafka/bin/kafka-console-producer.sh --broker-list localhost:9092 --topic taas.role.delete < test/messages/taas.role.delete.event.json
4862
```
4963

5064
- Run `npm run view-data <model-name-here>` to see if documents were deleted.

config/default.js

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* The default configuration file.
33
*/
4-
4+
require('dotenv').config()
55
module.exports = {
66
PORT: process.env.PORT || 3001,
77
LOG_LEVEL: process.env.LOG_LEVEL || 'debug',
@@ -14,8 +14,12 @@ module.exports = {
1414

1515
// Kafka group id
1616
KAFKA_GROUP_ID: process.env.KAFKA_GROUP_ID || 'taas-es-processor',
17+
// The originator value for the kafka messages
18+
KAFKA_MESSAGE_ORIGINATOR: process.env.KAFKA_MESSAGE_ORIGINATOR || 'taas-es-processor',
1719

1820
topics: {
21+
// The error topic at which bus api will publish any errors
22+
KAFKA_ERROR_TOPIC: process.env.KAFKA_ERROR_TOPIC || 'common.error.reporting',
1923
// topics for job service
2024
TAAS_JOB_CREATE_TOPIC: process.env.TAAS_JOB_CREATE_TOPIC || 'taas.job.create',
2125
TAAS_JOB_UPDATE_TOPIC: process.env.TAAS_JOB_UPDATE_TOPIC || 'taas.job.update',
@@ -31,8 +35,28 @@ module.exports = {
3135
// topics for work period service
3236
TAAS_WORK_PERIOD_CREATE_TOPIC: process.env.TAAS_WORK_PERIOD_CREATE_TOPIC || 'taas.workperiod.create',
3337
TAAS_WORK_PERIOD_UPDATE_TOPIC: process.env.TAAS_WORK_PERIOD_UPDATE_TOPIC || 'taas.workperiod.update',
34-
TAAS_WORK_PERIOD_DELETE_TOPIC: process.env.TAAS_WORK_PERIOD_DELETE_TOPIC || 'taas.workperiod.delete'
38+
TAAS_WORK_PERIOD_DELETE_TOPIC: process.env.TAAS_WORK_PERIOD_DELETE_TOPIC || 'taas.workperiod.delete',
39+
// topics for work period payment service
40+
TAAS_WORK_PERIOD_PAYMENT_CREATE_TOPIC: process.env.TAAS_WORK_PERIOD_PAYMENT_CREATE_TOPIC || 'taas.workperiodpayment.create',
41+
TAAS_WORK_PERIOD_PAYMENT_UPDATE_TOPIC: process.env.TAAS_WORK_PERIOD_PAYMENT_UPDATE_TOPIC || 'taas.workperiodpayment.update',
42+
// topics for interview service
43+
TAAS_INTERVIEW_REQUEST_TOPIC: process.env.TAAS_INTERVIEW_REQUEST_TOPIC || 'taas.interview.requested',
44+
TAAS_INTERVIEW_UPDATE_TOPIC: process.env.TAAS_INTERVIEW_UPDATE_TOPIC || 'taas.interview.update',
45+
TAAS_INTERVIEW_BULK_UPDATE_TOPIC: process.env.TAAS_INTERVIEW_BULK_UPDATE_TOPIC || 'taas.interview.bulkUpdate',
46+
// topics for role service
47+
TAAS_ROLE_CREATE_TOPIC: process.env.TAAS_ROLE_CREATE_TOPIC || 'taas.role.requested',
48+
TAAS_ROLE_UPDATE_TOPIC: process.env.TAAS_ROLE_UPDATE_TOPIC || 'taas.role.update',
49+
TAAS_ROLE_DELETE_TOPIC: process.env.TAAS_ROLE_DELETE_TOPIC || 'taas.role.delete',
50+
// special kafka topics
51+
TAAS_ACTION_RETRY_TOPIC: process.env.TAAS_ACTION_RETRY_TOPIC || 'taas.action.retry'
52+
3553
},
54+
// maximum allowed retry count for failed operations for sending `action.retry` message
55+
MAX_RETRY: process.env.MAX_RETRY || 3,
56+
// base amount of retry delay for failed operations
57+
BASE_RETRY_DELAY: process.env.BASE_RETRY_DELAY || 500,
58+
// Topcoder Bus API URL
59+
BUSAPI_URL: process.env.BUSAPI_URL || 'https://api.topcoder-dev.com/v5',
3660

3761
esConfig: {
3862
HOST: process.env.ES_HOST || 'http://localhost:9200',
@@ -48,15 +72,16 @@ module.exports = {
4872
ES_INDEX_JOB: process.env.ES_INDEX_JOB || 'job',
4973
ES_INDEX_JOB_CANDIDATE: process.env.ES_INDEX_JOB_CANDIDATE || 'job_candidate',
5074
ES_INDEX_RESOURCE_BOOKING: process.env.ES_INDEX_RESOURCE_BOOKING || 'resource_booking',
51-
ES_INDEX_WORK_PERIOD: process.env.ES_INDEX_WORK_PERIOD || 'work_period'
75+
ES_INDEX_ROLE: process.env.ES_INDEX_ROLE || 'role'
5276
},
5377

5478
auth0: {
5579
AUTH0_URL: process.env.AUTH0_URL,
5680
AUTH0_AUDIENCE: process.env.AUTH0_AUDIENCE,
5781
AUTH0_CLIENT_ID: process.env.AUTH0_CLIENT_ID,
5882
AUTH0_CLIENT_SECRET: process.env.AUTH0_CLIENT_SECRET,
59-
AUTH0_PROXY_SERVER_URL: process.env.AUTH0_PROXY_SERVER_URL
83+
AUTH0_PROXY_SERVER_URL: process.env.AUTH0_PROXY_SERVER_URL,
84+
TOKEN_CACHE_TIME: process.env.TOKEN_CACHE_TIME
6085
},
6186

6287
zapier: {

config/test.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,7 @@ module.exports = {
66
zapier: {
77
ZAPIER_SWITCH: process.env.ZAPIER_SWITCH || 'ON',
88
ZAPIER_JOB_CANDIDATE_SWITCH: process.env.ZAPIER_JOB_CANDIDATE_SWITCH || 'ON'
9-
}
9+
},
10+
// don't retry actions during tests because tests for now don't expect it and should be updated first
11+
MAX_RETRY: 0
1012
}

local/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ services:
1212
- "9092:9092"
1313
environment:
1414
KAFKA_ADVERTISED_HOST_NAME: localhost
15-
KAFKA_CREATE_TOPICS: "taas.job.create:1:1,taas.jobcandidate.create:1:1,taas.resourcebooking.create:1:1,taas.job.update:1:1,taas.jobcandidate.update:1:1,taas.resourcebooking.update:1:1,taas.job.delete:1:1,taas.jobcandidate.delete:1:1,taas.resourcebooking.delete:1:1"
15+
KAFKA_CREATE_TOPICS: "taas.job.create:1:1,taas.jobcandidate.create:1:1,taas.interview.requested:1:1,taas.resourcebooking.create:1:1,taas.workperiod.create:1:1,taas.workperiodpayment.create:1:1,taas.job.update:1:1,taas.jobcandidate.update:1:1,taas.interview.update:1:1,taas.interview.bulkUpdate:1:1,taas.resourcebooking.update:1:1,taas.workperiod.update:1:1,taas.workperiodpayment.update:1:1,taas.job.delete:1:1,taas.jobcandidate.delete:1:1,taas.resourcebooking.delete:1:1,taas.workperiod.delete:1:1"
1616
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
1717
esearch:
1818
image: elasticsearch:7.7.1

0 commit comments

Comments
 (0)