Skip to content

Commit

Permalink
Refactored question-processor which was missed earlier. And changed t…
Browse files Browse the repository at this point in the history
…he context of the question processor
  • Loading branch information
nishant-jain-94 committed Sep 14, 2017
1 parent c24f5ca commit 51f2d6b
Show file tree
Hide file tree
Showing 27 changed files with 1,298 additions and 5,171 deletions.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ services:
restart: always

questions_processor:
build: ./ontology_processors/questions
build: ./ontology_processors/question-processor
env_file:
- ontology_manager.env
volumes:
Expand Down
29 changes: 19 additions & 10 deletions ontology_processors/question-processor/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
{
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"env": {
"node": true,
"mocha": true,
"es6": true
}
"extends": "airbnb-base",
"parserOptions": {
"ecmaVersion": 8,
"sourceType": "module"
},
"env": {
"node": true,
"mocha": true,
"es6": true
},
"rules": {
"space-after-keywords": "off",
"space-return-throw-case": "off",
"comma-dangle": [
"error",
{ "functions": "ignore" }
],
"no-underscore-dangle": ["error", { "allow": ["_stats"] }]
}
}
2 changes: 0 additions & 2 deletions ontology_processors/question-processor/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,4 @@ RUN yarn install
# Bundle app source
COPY . /usr/src/app

VOLUME /usr/src/app/neo4j_utils /usr/src/app/amqp_utils /usr/src/app/sro_utils

CMD ["yarn", "start"]
1 change: 0 additions & 1 deletion ontology_processors/question-processor/amqp_utils

This file was deleted.

5 changes: 5 additions & 0 deletions ontology_processors/question-processor/commons/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const logger = require('./logger.js');

module.exports = {
logger
};
8 changes: 8 additions & 0 deletions ontology_processors/question-processor/commons/logger.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const bunyan = require('bunyan');
const bformat = require('bunyan-format');

const formatOut = bformat({ outputMode: 'bunyan' });

const log = name => bunyan.createLogger({ name, stream: formatOut });

module.exports = log;
6 changes: 6 additions & 0 deletions ontology_processors/question-processor/config/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module.exports = {
NEO4J_URL: process.env.NEO4J_URL || 'bolt://localhost',
NEO4J_USERNAME: process.env.NEO4J_USERNAME || 'neo4j',
NEO4J_PASSWORD: process.env.NEO4J_PASSWORD || 'password',
AMQP_URL: process.env.AMQP_URL || 'amqp://localhost'
};
1 change: 1 addition & 0 deletions ontology_processors/question-processor/config/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('./config');
26 changes: 16 additions & 10 deletions ontology_processors/question-processor/eslint-results.html
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,13 @@ <h2>Summary</h2>
</tr>
<tr>
<td>Clean files</td>
<td>8</td>
<td>11</td>
</tr>
</tbody>
<tfoot>
<tr>
<td>Total files linted</td>
<td>8</td>
<td>11</td>
</tr>
</tfoot>
</table>
Expand All @@ -300,21 +300,27 @@ <h2>File Breakdown
<th class="warning-col">Warnings</th>
</tr>
</thead>
<tbody><tr class="success"><td>/home/nishant/workspace/sro-ontology-manager-github/ontology_processors/percp_scope_1.questions/gulpfile.js</td>
<tbody><tr class="success"><td>/home/nishant/workspace/sro-ontology-manager-github/ontology_processors/question-processor/commons/index.js</td>
<td>0</td>
<td>0</td></tr><tr class="success"><td>/home/nishant/workspace/sro-ontology-manager-github/ontology_processors/percp_scope_1.questions/index.js</td>
<td>0</td></tr><tr class="success"><td>/home/nishant/workspace/sro-ontology-manager-github/ontology_processors/question-processor/commons/logger.js</td>
<td>0</td>
<td>0</td></tr><tr class="success"><td>/home/nishant/workspace/sro-ontology-manager-github/ontology_processors/percp_scope_1.questions/questions.ack.js</td>
<td>0</td></tr><tr class="success"><td>/home/nishant/workspace/sro-ontology-manager-github/ontology_processors/question-processor/config/config.js</td>
<td>0</td>
<td>0</td></tr><tr class="success"><td>/home/nishant/workspace/sro-ontology-manager-github/ontology_processors/percp_scope_1.questions/questions.consumer.js</td>
<td>0</td></tr><tr class="success"><td>/home/nishant/workspace/sro-ontology-manager-github/ontology_processors/question-processor/config/index.js</td>
<td>0</td>
<td>0</td></tr><tr class="success"><td>/home/nishant/workspace/sro-ontology-manager-github/ontology_processors/percp_scope_1.questions/questions.consumer.test.js</td>
<td>0</td></tr><tr class="success"><td>/home/nishant/workspace/sro-ontology-manager-github/ontology_processors/question-processor/gulpfile.js</td>
<td>0</td>
<td>0</td></tr><tr class="success"><td>/home/nishant/workspace/sro-ontology-manager-github/ontology_processors/percp_scope_1.questions/questions.processor.js</td>
<td>0</td></tr><tr class="success"><td>/home/nishant/workspace/sro-ontology-manager-github/ontology_processors/question-processor/index.js</td>
<td>0</td>
<td>0</td></tr><tr class="success"><td>/home/nishant/workspace/sro-ontology-manager-github/ontology_processors/percp_scope_1.questions/questions.processor.test.js</td>
<td>0</td></tr><tr class="success"><td>/home/nishant/workspace/sro-ontology-manager-github/ontology_processors/question-processor/processor/index.js</td>
<td>0</td>
<td>0</td></tr><tr class="success"><td>/home/nishant/workspace/sro-ontology-manager-github/ontology_processors/percp_scope_1.questions/questions.router.js</td>
<td>0</td></tr><tr class="success"><td>/home/nishant/workspace/sro-ontology-manager-github/ontology_processors/question-processor/processor/questions.processor.js</td>
<td>0</td>
<td>0</td></tr><tr class="success"><td>/home/nishant/workspace/sro-ontology-manager-github/ontology_processors/question-processor/processor/questions.processor.test.js</td>
<td>0</td>
<td>0</td></tr><tr class="success"><td>/home/nishant/workspace/sro-ontology-manager-github/ontology_processors/question-processor/router/index.js</td>
<td>0</td>
<td>0</td></tr><tr class="success"><td>/home/nishant/workspace/sro-ontology-manager-github/ontology_processors/question-processor/router/questions.router.js</td>
<td>0</td>
<td>0</td></tr></tbody>
</table>
Expand Down
32 changes: 14 additions & 18 deletions ontology_processors/question-processor/gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
const fs = require('fs');
const path = require('path');
const gulp = require('gulp');
const gulp = require('gulp');
const mocha = require('gulp-mocha');
const eslint = require('gulp-eslint');
const reporter = require('eslint-html-reporter');

gulp.task('lint', () => {
return gulp.src(['**/*.js', '!node_modules/**', '!amqp_utils/**', '!sro_utils/**', '!coverage/**', '!neo4j_utils/**'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.format(reporter, (results) => {
fs.writeFileSync(path.join(__dirname, 'eslint-results.html'), results);
}))
.pipe(eslint.failAfterError());
});
gulp.task('lint', () => gulp.src(['**/*.js', '!node_modules/**', '!amqp_utils/**', '!sro_utils/**', '!coverage/**', '!neo4j_utils/**'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.format(reporter, (results) => {
fs.writeFileSync(path.join(__dirname, 'eslint-results.html'), results);
}))
.pipe(eslint.failAfterError()));

gulp.task('test', () => {
return gulp.src(['**/*.test.js', '!node_modules/**', '!amqp_utils/**', '!sro_utils/**', '!coverage/**', '!neo4j_utils/**'])
.pipe(mocha({reporter: 'nyan'}))
.once('error', () => {
process.exit(1);
});
});
gulp.task('test', () => gulp.src(['**/*.test.js', '!node_modules/**', '!amqp_utils/**', '!sro_utils/**', '!coverage/**', '!neo4j_utils/**'])
.pipe(mocha({ reporter: 'spec' }))
.once('error', () => {
process.exit(1);
}));

gulp.task('default', ['lint', 'test']);
gulp.task('default', ['lint', 'test']);
23 changes: 15 additions & 8 deletions ontology_processors/question-processor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,21 @@
// ## index.js (Questions)

// Imports the required dependencies.
const questionAck = require('./questions.ack');
const questionStream = require('./questions.consumer');
const questionProcessor = require('./questions.processor');
const questionRouter = require('./questions.router');
const _ = require('lodash');
const { AMQP_URL } = require('./config');
const questionRouter = require('./router');
const questionProcessor = require('./processor');
const AmqpLib = require('simple-amqplib-wrapper');

const amqp = new AmqpLib(AMQP_URL);
const questionStream = amqp.consumeStream('questions');
const questionAck = _.bind(amqp.acknowledge, amqp, _, true);
// Orchestrates the pipeline
// 1. The input `questionStream` coming from the questions consumer is piped to the `questionProcessor`.
// 1. The input `questionStream` coming from the questions
// consumer is piped to the `questionProcessor`.
// 2. `questionProcessor` processes the questions and create nodes for questions.
// 3. Then the output from the `questionProcessor` is piped to the `questionRouter` which routes the question to the node_factory and relation_factory.
// 4. Once the entire processing on the questions is performed an acknowledgement is sent to the queue using `questionAck`.
questionStream.pipe(questionProcessor).pipe(questionRouter).each(questionAck);
// 3. Then the output from the `questionProcessor` is piped to the `questionRouter`
// which routes the question to the node_factory and relation_factory.
// 4. Once the entire processing on the questions is performed an acknowledgement
// is sent to the queue using `questionAck`.
questionStream.pipe(questionProcessor).pipe(questionRouter).each(questionAck);
1 change: 0 additions & 1 deletion ontology_processors/question-processor/neo4j_utils

This file was deleted.

Loading

0 comments on commit 51f2d6b

Please sign in to comment.