Skip to content

Commit 4527393

Browse files
author
sachin-maheshwari
authored
Merge pull request #100 from yoution/feature/shapeup4-cqrs-update
Code clean-up after CQRS standards update
2 parents 05193c6 + 2289736 commit 4527393

Some content is hidden

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

45 files changed

+51
-5175
lines changed

README.md

Lines changed: 8 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
## Dependencies
44

55
- Nodejs(v12+)
6-
- ElasticSearch
76
- Kafka
87

98
## Configuration
@@ -22,41 +21,10 @@ The following parameters can be set in config files or in env variables:
2221
if provided, it can be either path to private key file or private key content
2322
- `KAFKA_MESSAGE_ORIGINATOR`: The originator value for the kafka messages
2423
- `KAFKA_GROUP_ID`: the Kafka group id
25-
- `topics.KAFKA_ERROR_TOPIC`: the error topic at which bus api will publish any errors
2624
- `topics.TAAS_JOB_CREATE_TOPIC`: the create job entity Kafka message topic
2725
- `topics.TAAS_JOB_UPDATE_TOPIC`: the update job entity Kafka message topic
28-
- `topics.TAAS_JOB_DELETE_TOPIC`: the delete job entity Kafka message topic
29-
- `topics.TAAS_JOB_CANDIDATE_CREATE_TOPIC`: the create job candidate entity Kafka message topic
3026
- `topics.TAAS_JOB_CANDIDATE_UPDATE_TOPIC`: the update job candidate entity Kafka message topic
31-
- `topics.TAAS_JOB_CANDIDATE_DELETE_TOPIC`: the delete job candidate entity Kafka message topic
32-
- `topics.TAAS_RESOURCE_BOOKING_CREATE_TOPIC`: the create resource booking entity Kafka message topic
33-
- `topics.TAAS_RESOURCE_BOOKING_UPDATE_TOPIC`: the update resource booking entity Kafka message topic
34-
- `topics.TAAS_RESOURCE_BOOKING_DELETE_TOPIC`: the delete resource booking entity Kafka message topic
35-
- `topics.TAAS_WORK_PERIOD_CREATE_TOPIC`: the create work period entity Kafka message topic
36-
- `topics.TAAS_WORK_PERIOD_UPDATE_TOPIC`: the update work period entity Kafka message topic
37-
- `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
50-
- `esConfig.HOST`: Elasticsearch host
51-
- `esConfig.AWS_REGION`: The Amazon region to use when using AWS Elasticsearch service
52-
- `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
53-
- `esConfig.ELASTICCLOUD.username`: The elastic cloud username for basic authentication. Provide this only if your elasticsearch instance is hosted on elastic cloud
54-
- `esConfig.ELASTICCLOUD.password`: The elastic cloud password for basic authentication. Provide this only if your elasticsearch instance is hosted on elastic cloud
55-
- `esConfig.ES_INDEX_JOB`: the index name for job
56-
- `esConfig.ES_INDEX_JOB_CANDIDATE`: the index name for job candidate
57-
- `esConfig.ES_INDEX_RESOURCE_BOOKING`: the index name for resource booking
58-
- `esConfig.ES_INDEX_ROLE`: the index name for role
59-
27+
- `TAAS_API_URL`: the taas api url
6028
- `auth0.AUTH0_URL`: Auth0 URL, used to get TC M2M token
6129
- `auth0.AUTH0_AUDIENCE`: Auth0 audience, used to get TC M2M token
6230
- `auth0.AUTH0_CLIENT_ID`: Auth0 client id, used to get TC M2M token
@@ -71,7 +39,7 @@ The following parameters can be set in config files or in env variables:
7139
- `zapier.ZAPIER_JOB_CANDIDATE_SWITCH`: decides whether posting job candidate related message to zapier or not; possible values are `ON` and `OFF`, default is `OFF`
7240
- `zapier.ZAPIER_JOB_CANDIDATE_WEBHOOK`: the remote zapier zap webhook url for posting job candidate related message
7341

74-
## Local Kafka and ElasticSearch setup
42+
## Local Kafka setup
7543

7644
1. Navigate to the directory `local`
7745

@@ -81,30 +49,21 @@ The following parameters can be set in config files or in env variables:
8149
docker-compose up -d
8250
```
8351

84-
3. initialize Elasticsearch, create configured Elasticsearch index:
85-
86-
``` bash
87-
npm run delete-index # run this if you already created index
88-
npm run create-index
89-
```
90-
9152
## Local deployment
9253

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:
54+
0. 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:
9655

9756
```bash
9857
nvm use
9958
```
10059

101-
2. From the project root directory, run the following command to install the dependencies
60+
1. From the project root directory, run the following command to install the dependencies
10261

10362
```bash
10463
npm install
10564
```
10665

107-
3. To run linters if required
66+
2. To run linters if required
10867

10968
```bash
11069
npm run lint
@@ -116,7 +75,7 @@ The following parameters can be set in config files or in env variables:
11675
npm run lint:fix
11776
```
11877

119-
4. Local config
78+
3. Local config
12079

12180
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>
12281

@@ -131,7 +90,7 @@ The following parameters can be set in config files or in env variables:
13190
- Values from this file would be automatically used by many `npm` commands.
13291
- ⚠️ Never commit this file or its copy to the repository!
13392

134-
5. Start the processor and health check dropin
93+
4. Start the processor and health check dropin
13594

13695
```bash
13796
npm start
@@ -145,7 +104,7 @@ To run the processor using docker, follow the below steps
145104

146105
2. Rename the file `sample.api.env` to `api.env`
147106

148-
3. Set the required Kafka url and ElasticSearch host in the file `api.env`.
107+
3. Set the required Kafka url in the file `api.env`.
149108

150109
Note that you can also add other variables to `api.env`, with `<key>=<value>` format per line.
151110
If using AWS ES you should add `AWS_ACCESS_KEY_ID` and `AWS_SECRET_ACCESS_KEY` variables as well.
@@ -158,20 +117,3 @@ To run the processor using docker, follow the below steps
158117
```
159118

160119
5. When you are running the application for the first time, It will take some time initially to download the image and install the dependencies
161-
162-
## Unit Tests and E2E Tests
163-
164-
### Unit Tests
165-
- Run `npm run test` to execute unit tests.
166-
- Run `npm run test:cov` to execute unit tests and generate coverage report.
167-
168-
### E2E Tests
169-
Before running e2e tests, make sure index are created and the processor app is not running. Existing documents will be remove
170-
from ES before and after tests.
171-
172-
- RUN `npm run e2e` to execute e2e tests.
173-
- RUN `npm run e2e:cov` to execute e2e tests and generate coverage report.
174-
175-
## Verification
176-
177-
see [VERIFICATION.md](VERIFICATION.md)

VERIFICATION.md

Lines changed: 0 additions & 64 deletions
This file was deleted.

config/default.js

Lines changed: 3 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -17,62 +17,14 @@ module.exports = {
1717
// The originator value for the kafka messages
1818
KAFKA_MESSAGE_ORIGINATOR: process.env.KAFKA_MESSAGE_ORIGINATOR || 'taas-es-processor',
1919

20+
TAAS_API_URL: process.env.TAAS_API_URL || 'https://api.topcoder-dev.com/v5',
21+
2022
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',
2323
// topics for job service
2424
TAAS_JOB_CREATE_TOPIC: process.env.TAAS_JOB_CREATE_TOPIC || 'taas.job.create',
2525
TAAS_JOB_UPDATE_TOPIC: process.env.TAAS_JOB_UPDATE_TOPIC || 'taas.job.update',
26-
TAAS_JOB_DELETE_TOPIC: process.env.TAAS_JOB_DELETE_TOPIC || 'taas.job.delete',
2726
// topics for jobcandidate service
28-
TAAS_JOB_CANDIDATE_CREATE_TOPIC: process.env.TAAS_JOB_CANDIDATE_CREATE_TOPIC || 'taas.jobcandidate.create',
29-
TAAS_JOB_CANDIDATE_UPDATE_TOPIC: process.env.TAAS_JOB_CANDIDATE_UPDATE_TOPIC || 'taas.jobcandidate.update',
30-
TAAS_JOB_CANDIDATE_DELETE_TOPIC: process.env.TAAS_JOB_CANDIDATE_DELETE_TOPIC || 'taas.jobcandidate.delete',
31-
// topics for resource booking service
32-
TAAS_RESOURCE_BOOKING_CREATE_TOPIC: process.env.TAAS_RESOURCE_BOOKING_CREATE_TOPIC || 'taas.resourcebooking.create',
33-
TAAS_RESOURCE_BOOKING_UPDATE_TOPIC: process.env.TAAS_RESOURCE_BOOKING_UPDATE_TOPIC || 'taas.resourcebooking.update',
34-
TAAS_RESOURCE_BOOKING_DELETE_TOPIC: process.env.TAAS_RESOURCE_BOOKING_DELETE_TOPIC || 'taas.resourcebooking.delete',
35-
// topics for work period service
36-
TAAS_WORK_PERIOD_CREATE_TOPIC: process.env.TAAS_WORK_PERIOD_CREATE_TOPIC || 'taas.workperiod.create',
37-
TAAS_WORK_PERIOD_UPDATE_TOPIC: process.env.TAAS_WORK_PERIOD_UPDATE_TOPIC || 'taas.workperiod.update',
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-
53-
},
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',
60-
61-
esConfig: {
62-
HOST: process.env.ES_HOST || 'http://localhost:9200',
63-
64-
ELASTICCLOUD: {
65-
id: process.env.ELASTICCLOUD_ID,
66-
username: process.env.ELASTICCLOUD_USERNAME,
67-
password: process.env.ELASTICCLOUD_PASSWORD
68-
},
69-
70-
AWS_REGION: process.env.AWS_REGION || 'us-east-1', // AWS Region to be used if we use AWS ES
71-
72-
ES_INDEX_JOB: process.env.ES_INDEX_JOB || 'job',
73-
ES_INDEX_JOB_CANDIDATE: process.env.ES_INDEX_JOB_CANDIDATE || 'job_candidate',
74-
ES_INDEX_RESOURCE_BOOKING: process.env.ES_INDEX_RESOURCE_BOOKING || 'resource_booking',
75-
ES_INDEX_ROLE: process.env.ES_INDEX_ROLE || 'role'
27+
TAAS_JOB_CANDIDATE_UPDATE_TOPIC: process.env.TAAS_JOB_CANDIDATE_UPDATE_TOPIC || 'taas.jobcandidate.update'
7628
},
7729

7830
auth0: {

config/test.js

Lines changed: 0 additions & 12 deletions
This file was deleted.

local/docker-compose.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,5 @@ 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.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"
15+
KAFKA_CREATE_TOPICS: "taas.job.create:1:1,taas.job.update:1:1,taas.jobcandidate.update:1:1"
1616
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
17-
esearch:
18-
image: elasticsearch:7.7.1
19-
container_name: taas-es-processor_es
20-
ports:
21-
- "9200:9200"
22-
environment:
23-
- discovery.type=single-node

0 commit comments

Comments
 (0)