Skip to content

Commit

Permalink
chore: pull in redis/pub-sub/kvs/ttk/state plugin/state machine code …
Browse files Browse the repository at this point in the history
…for upcoming flows (#78)

* chore: rename Scope interface to less conflicting name

* chore: fix tests

* chore: import redis/pub-sub/kvs code

* chore: import persistant model

* chore: import state plugin

* chore: add TTK for future integration tests

* chore: fix compose file

* chore: fix wieeeerrrddd redis test break

* chore: appease lint god

* chore: update unit tests

* chore: remove extra hosts
  • Loading branch information
kleyow committed Jul 8, 2021
1 parent d040df3 commit 3309b3c
Show file tree
Hide file tree
Showing 68 changed files with 10,909 additions and 151 deletions.
77 changes: 77 additions & 0 deletions ambient.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,80 @@ declare module '@mojaloop/central-services-metrics'
declare module '@hapi/good'
declare module 'hapi-openapi'
declare module 'blipp'

// version 2.4 -> https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/javascript-state-machine/index.d.ts
// we are using ^3.1.0
declare module 'javascript-state-machine' {
type Method = (...args: unknown[]) => void | Promise<void>
type Data = Record<string, string | number | boolean | unknown>


interface Transition {
name: string;
from: string;
to: string;
}
interface TransitionEvent<JSM> {
transition: string;
from: string;
to: string;
fsm: JSM;
event: string;
}
interface StateMachineConfig {
init?: string;
transitions: Transition[];
data?: Data;
methods?: Record<string, Method>;
}

interface StateMachineInterface {
// current state
state: string;

// return true if state s is the current state
is(s: string): boolean

// return true if transition t can occur from the current state
can(t: string): boolean

// return true if transition t cannot occur from the current state
cannot(t: string): boolean

// return list of transitions that are allowed from the current state
transitions(): string[]

// return list of all possible transitions
allTransitions(): string[]

// return list of all possible states
allStates(): string []
}
export default class StateMachine {
constructor(config: StateMachineConfig)

// current state
state: string;

// return true if state s is the current state
is(s: string): boolean

// return true if transition t can occur from the current state
can(t: string): boolean

// return true if transition t cannot occur from the current state
cannot(t: string): boolean

// return list of transitions that are allowed from the current state
transitions(): string[]

// return list of all possible transitions
allTransitions(): string[]

// return list of all possible states
allStates(): string []

static factory(spec: StateMachineConfig): StateMachine
}

}
7 changes: 6 additions & 1 deletion config/development.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
"PORT": 4004,
"HOST": "0.0.0.0",
"PARTICIPANT_ID": "auth_service",
"REDIS": {
"PORT": 6379,
"HOST": "redis",
"TIMEOUT": 100
},
"INSPECT": {
"DEPTH": 4,
"SHOW_HIDDEN": false,
Expand Down Expand Up @@ -66,4 +71,4 @@
]
}
}
}
}
7 changes: 6 additions & 1 deletion config/integration.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
"PORT": 4004,
"HOST": "0.0.0.0",
"PARTICIPANT_ID": "auth_service",
"REDIS": {
"PORT": 6379,
"HOST": "redis",
"TIMEOUT": 100
},
"INSPECT": {
"DEPTH": 4,
"SHOW_HIDDEN": false,
Expand Down Expand Up @@ -66,4 +71,4 @@
]
}
}
}
}
7 changes: 6 additions & 1 deletion config/production.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
"PORT": 4004,
"HOST": "0.0.0.0",
"PARTICIPANT_ID": "auth_service",
"REDIS": {
"PORT": 6379,
"HOST": "redis",
"TIMEOUT": 100
},
"INSPECT": {
"DEPTH": 4,
"SHOW_HIDDEN": false,
Expand Down Expand Up @@ -66,4 +71,4 @@
]
}
}
}
}
7 changes: 6 additions & 1 deletion config/test.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
"PORT": 4004,
"HOST": "0.0.0.0",
"PARTICIPANT_ID": "auth_service",
"REDIS": {
"PORT": 6379,
"HOST": "localhost",
"TIMEOUT": 100
},
"INSPECT": {
"DEPTH": 4,
"SHOW_HIDDEN": false,
Expand Down Expand Up @@ -49,4 +54,4 @@
]
}
}
}
}
20 changes: 20 additions & 0 deletions docker-compose.linux.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# This is an extension docker-compose file that contains `extra_hosts` entries to work arouind networking
# on linux, start docker-local with the following command
#
# docker-compose -f docker-compose.yml -f docker-compose.linux.yml up -d
#
# I suspect that with some of the recent changes to the way containers refer to one another inside the
# docker-local environment, this will no longer be needed. Please delete this file if you are reading this message
# past July and we haven't run into issues...

version: "3.7"

services:
auth-service:
extra_hosts:
- "redis:172.17.0.1"
- "ml-testing-toolkit:172.17.0.1"

ml-testing-toolkit:
extra_hosts:
- "auth-service:172.17.0.1"
47 changes: 45 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ services:
- mojaloop-net
depends_on:
- mysql
- redis
volumes:
- ./scripts/wait4.js:/opt/auth-service/scripts/wait4.js
- ./scripts/wait4.config.js:/opt/auth-service/scripts/wait4.config.js
healthcheck:
test: wget -q http://172.17.0.1:4004/health -O /dev/null || exit 1
test: wget -q http://localhost:4004/health -O /dev/null || exit 1
timeout: 20s
retries: 30
interval: 15s
Expand All @@ -46,4 +47,46 @@ services:
timeout: 20s
retries: 10
start_period: 40s
interval: 30s
interval: 30s

redis:
container_name: redis
image: "redis:6.2.4-alpine"
networks:
- mojaloop-net
ports:
- "6379:6379"
restart: always

ml-testing-toolkit:
image: mojaloop/ml-testing-toolkit:v12.4.0
container_name: ml-testing-toolkit
volumes:
- "./docker/ml-testing-toolkit/spec_files:/opt/mojaloop-testing-toolkit/spec_files"
- "./docker/ml-testing-toolkit/secrets:/opt/mojaloop-testing-toolkit/secrets"
ports:
- "15000:5000"
- "5050:5050"
command: npm start
networks:
- mojaloop-net
depends_on:
- mongo

ml-testing-toolkit-ui:
image: mojaloop/ml-testing-toolkit-ui:v12.0.0
container_name: ml-testing-toolkit-ui
ports:
- "6060:6060"
command: nginx -g "daemon off;"
depends_on:
- ml-testing-toolkit
- mongo
networks:
- mojaloop-net

mongo:
image: mongo
container_name: 3p_mongo
ports:
- "27017:27017"
Empty file.
21 changes: 21 additions & 0 deletions docker/ml-testing-toolkit/secrets/publickey.cer
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
-----BEGIN CERTIFICATE-----
MIID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J1pieZzv4+RUJz8NgXxjW
ZRwqCkEqPe/8S1X9srtcrdbHryDdC18Ldu/rADEKbSqy0BhQdKYDcxulaQuqibwD
i0dWSdTWoseAbUqp2ACc6aF/
-----END CERTIFICATE-----
Loading

0 comments on commit 3309b3c

Please sign in to comment.