-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial Code #1
base: init_commit
Are you sure you want to change the base?
Initial Code #1
Conversation
Other planned features:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have reviewed api.js mainly
and a bit of ledger.js, going through
src/ledger.js
Outdated
const FIFOQueue = require("./queue"); | ||
const sleep = require('./utils').sleep; | ||
const groupBy = require('./utils').groupBy; | ||
const OperationTypes = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably we dont need this enum because there can't be more types of operations by definition. In fact there should be no concept of 'Type Of Operation'
src/ledger.js
Outdated
return account; | ||
} | ||
getAccountBalances(id) { | ||
const accountEntries = this.db.getAll(Entities.ENTRIES, id); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
one interesting complexity we have to model -
we're saying that ledger will be decoupled from persistence (here, DB). there are some useful things DB offers that we will need to generalize:
For account balance i don't need to fetch entire ledger history. I can just do it in a single query on DB. so the persistence layer needs some more control over the getAccountBalance functionality if it supports something like this.
Other things pending on a high level wrt Prod readiness Defining Error scenarios We will worry about these things next week |
src/ledger.ts
Outdated
} | ||
private getOperationTask(operation: IOperation) { | ||
return async () => { | ||
await this.postOperationEntries(operation.id!, operation.entries) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't use the word 'post'
It's confusing with 'postingQueue` and HTTP POST
src/ledger.ts
Outdated
const operation: IOperation = Object.assign({status: OperationStatus.INIT}, operationRequest); | ||
return new Promise(async (resolve, reject) => { | ||
const operationId = (await this.dataConnector.insertOperation(operation)).id as string; | ||
this.postingQueue.enqueueTask(async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok so you're doing 2 things here -
inserting operation in DB
inserting it in an in-memory task queue to be processed.
The latter in fact should be the responsibility of a separate decoupled system which reads the operation from DB and inserts it in an in-memory task queue to be processed.
src/ledger.ts
Outdated
export interface IBookBalances { | ||
[assetId: string]: string, | ||
} | ||
export class LedgerSystem { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to expose this additional functionality -
'Get operations on book' -> paginated way to get latest completed operations on book.
Callers need it for several use cases.
remove queue server and websockets
…/ts-ledger into feature/sequelize
SequelizeDataConnector and migration script for local sqlite db
…o feature/queue-worker
implement server-client model for FIFO Queue management
LedgerSystem class is the core class with methods to:
Data/InMemoryData class is the database class with methods to:
API is exposed via Express APP and separate Routes for Operations (considering transfer as an operation) and Accounts.
There is a rest.http file to interact with the local server easily using the VSCode extension “REST Client”.
FIFOQueue class as the sub-system of LedgerSystem is used to serialise the task (posting entries corresponding to operations created).