Skip to content

Commit

Permalink
Merge c748a25 into 59e8801
Browse files Browse the repository at this point in the history
  • Loading branch information
RonShvarz committed Aug 2, 2023
2 parents 59e8801 + c748a25 commit 75e8a44
Show file tree
Hide file tree
Showing 9 changed files with 239 additions and 22 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
branches: [master]
push:
branches: [master]

workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
Expand All @@ -25,6 +25,9 @@ jobs:
- uses: actions/setup-node@v1
with:
node-version: 14.x
- name: setup
run: |
docker run -d -p 27017:27017 -e MONGO_INITDB_ROOT_USERNAME=tester -e MONGO_INITDB_ROOT_PASSWORD=password mongo:4.4.1-bionic
- run: npm ci
- name: lint and test
run: |
Expand Down
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
const NodesMap = require('./lib/dag/dag');
const NodeStates = require('./lib/const/NodeStates');
const NodeTypes = require('./lib/dag/index');
const Persistency = require('./lib/persistency/persistency');

module.exports = {
NodesMap,
NodeStates,
NodeTypes
NodeTypes,
Persistency
};
2 changes: 2 additions & 0 deletions lib/dag/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const GraphNode = require('./graph-node');
const NodeBase = require('./node-base');
const Batch = require('./node-batch');
const Stateless = require('./node-stateless');
const ExecBatch = require('./node-exec-batch');
const ExecNode = require('./node-exec');
const NodeResult = require('./node-result');
Expand All @@ -10,6 +11,7 @@ module.exports = {
GraphNode,
NodeBase,
Batch,
Stateless,
ExecNode,
ExecBatch,
NodeResult,
Expand Down
10 changes: 10 additions & 0 deletions lib/dag/node-stateless.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const NodeBase = require('./node-base');

class Stateless extends NodeBase {
constructor(options) {
super(options);
this.statelessIndex = options.statelessIndex;
}
}

module.exports = Stateless;
30 changes: 30 additions & 0 deletions lib/persistency/mongodb-adapter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const dbConnect = require('@hkube/db');

class MongoDbAdapter {
constructor() {
this._db = null;
}

async init(options) {
const { provider, ...config } = options;
this._db = dbConnect(config, provider);
await this._db.init();
}

setGraph({ jobId, data }) {
return this._db.jobs.updateGraph({ jobId, graph: data });
}

async getGraph({ jobId }) {
const res = await this._db.jobs.fetchGraph({ jobId });
if (!res) {
return null;
}
if (Object.keys(res).length === 1 && res.jobId) {
return null;
}
return res;
}
}

module.exports = MongoDbAdapter;
25 changes: 25 additions & 0 deletions lib/persistency/persistency.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
const MongoDbAdapter = require('./mongodb-adapter');

class Persistency {
async init(config) {
const options = config || {};
const { type, connection } = options;
switch (type) {
case 'mongodb':
default:
this._adapter = new MongoDbAdapter();
await this._adapter.init(connection);
break;
}
}

setGraph(...args) {
return this._adapter.setGraph(...args);
}

getGraph(...args) {
return this._adapter.getGraph(...args);
}
}

module.exports = Persistency;
121 changes: 101 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"license": "MIT",
"dependencies": {
"@hkube/consts": "^1.0.37",
"@hkube/db": "^1.0.42",
"@hkube/parsers": "^2.1.7",
"@hkube/uid": "^1.0.4",
"graphlib": "^2.1.8",
Expand Down

0 comments on commit 75e8a44

Please sign in to comment.