Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 71f6437

Browse files
Changes from 30088003
1 parent e189b6c commit 71f6437

18 files changed

+1979
-734
lines changed

README.md

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,15 @@ The following parameters can be set in config files or in env variables:
1717
- KAFKA_CLIENT_CERT_KEY: Kafka connection private key, optional; default value is undefined;
1818
if not provided, then SSL connection is not used, direct insecure connection is used;
1919
if provided, it can be either path to private key file or private key content
20-
- KAFKA_GROUP_ID: consumer group id; default value: 'or-review-processor'
21-
- OR_REVIEW_TOPIC : Scorecard processor topic, default value is 'or.notification.create'
20+
- KAFKA_GROUP_ID: consumer group id; default value: 'scorecard-processor'
21+
- REVIEW_TOPIC : Review topic, default value is 'submission.notification.score'
22+
- CREATE_SUBMISSION_TOPIC : create submission topic, default value is 'submission.notification.create'
23+
- UPDATE_SUBMISSION_TOPIC : update submission topic, default value is 'submission.notification.update'
2224
- REVIEW_API_URL: review api url, default is 'https://api.topcoder-dev.com/v5/reviews'
2325
- SUBMISSION_API_URL: submission api url, default is 'https://api.topcoder-dev.com/v5/submissions'
2426
- REVIEW_TYPE_API_URL: review type api url, default is 'https://api.topcoder-dev.com/v5/reviewTypes'
27+
- CHALLENGE_API_URL: challenge API URL, default is 'https://api.topcoder-dev.com/v4/challenges'
28+
- SCORECARD_API_URL: scorecard API URL, default is 'http://localhost:4000/scorecards'
2529
- AUTH0_URL: Auth0 URL, used to get TC M2M token
2630
- AUTH0_AUDIENCE: Auth0 audience, used to get TC M2M token
2731
- TOKEN_CACHE_TIME: Auth0 token cache time, used to get TC M2M token
@@ -33,7 +37,7 @@ The following parameters can be set in config files or in env variables:
3337
Also note that there is a `/health` endpoint that checks for the health of the app. This sets up an expressjs server and listens on the environment variable `PORT`. It's not part of the configuration file and needs to be passed as an environment variable
3438

3539
Configuration for the tests is at `config/test.js`, only add such new configurations different from `config/default.js`
36-
- WAIT_TIME: wait time used in test, default is 1000 or one second
40+
- WAIT_TIME: wait time used in test, default is 2000 or 2 seconds
3741
- REVIEW_SUMMATION_API_URL: review summation api url, used to clear resource during testing, default is 'https://api.topcoder-dev.com/v5/reviewSummations'
3842

3943
## Local Kafka setup
@@ -49,16 +53,20 @@ Configuration for the tests is at `config/test.js`, only add such new configurat
4953
`bin/kafka-server-start.sh config/server.properties`
5054
- note that the zookeeper server is at localhost:2181, and Kafka server is at localhost:9092
5155
- use another terminal, go to same directory, create the needed topics:
52-
`bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic or.notification.create`
56+
`bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic submission.notification.score`
57+
`bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic submission.notification.create`
58+
`bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic submission.notification.update`
59+
`bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic avscan.action.scan`
60+
`bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic or.action.review`
5361
- verify that the topics are created:
5462
`bin/kafka-topics.sh --list --zookeeper localhost:2181`,
5563
it should list out the created topics
56-
- run the producer and then write some message into the console to send to the `or.notification.create` topic:
57-
`bin/kafka-console-producer.sh --broker-list localhost:9092 --topic or.notification.create`
64+
- run the producer and then write some message into the console to send to the `submission.notification.score` topic:
65+
`bin/kafka-console-producer.sh --broker-list localhost:9092 --topic submission.notification.score`
5866
in the console, write message, one message per line:
59-
`{ "topic": "or.notification.create", "originator": "or-app", "timestamp": "2019-02-25T00:00:00", "mime-type": "application/json", "payload": { "score": 90, "submissionId": 206743, "reviewId": 390087, "scorecardId": 300001610, "reviewerId": 151743, "reviewTypeId": 2, "eventType": "CREATE" } }`
67+
`{ "topic": "submission.notification.score", "originator": "or-app", "timestamp": "2019-02-25T00:00:00", "mime-type": "application/json", "payload": { "score": 85, "submissionId": 206744, "reviewId": 390088, "scorecardId": 300001610, "reviewerId": 151743, "reviewTypeId": 2, "eventType": "CREATE" } }`
6068
- optionally, use another terminal, go to same directory, start a consumer to view the messages:
61-
`bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic or.notification.create --from-beginning`
69+
`bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic submission.notification.score --from-beginning`
6270
- writing/reading messages to/from other topics are similar
6371

6472
## Local deployment
@@ -84,3 +92,12 @@ npm start
8492

8593
## Verification
8694
Refer to the verification document `Verification.md`
95+
96+
97+
## Notes
98+
- the retrieved M2M token has no permission to delete review summation,
99+
but clearing review summation is not necessary, so we may ignore such forbidden error
100+
- usually, we should use TC bus API (POST /v5/bus/events) to send new messages for SubmissionProcessorService.processSubmission,
101+
but recently some TC dev API is not available, and the bus API fails with `504 temporarily unavailable error` when
102+
posting to topic `or.action.review`, so instead, this processor uses a Kafka producer to send new messages
103+

0 commit comments

Comments
 (0)