-
Notifications
You must be signed in to change notification settings - Fork 295
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
Add monitoring and send sync/async functionality #1966
Conversation
Add monitoring and sending async/sync requests to ledger via SocketIO. Closes: hyperledger-cacti#1941 Signed-off-by: stepniowskip <[email protected]>
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.
LGTM
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.
@StepniowskiP The two tests below are being skipped by the CI right now, did you run these manually on your machine and did they pass?
- packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/integration/iroha-iroha-transfer-example.test.ts
- packages/cactus-plugin-ledger-connector-iroha/src/test/typescript/integration/run-transaction-endpoint-v1.test.ts
args: any, | ||
method?: Record<string, unknown>, |
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.
@StepniowskiP Seems like a breaking change. Could you please refactor it to be backwards compatible with 1.0.0
?
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.
Sure, I have refactored method parameter to one before my changes
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.
@StepniowskiP Is it just me or the parameters are still out of order (e.g. not backwards compatible)?
This is the diff I'm looking at:
args: any, | ||
method?: Record<string, unknown>, |
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.
@StepniowskiP Seems like a breaking change. Could you please refactor it to be backwards compatible with 1.0.0
?
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.
Sure, I have refactored method parameter to one before my changes
return Transaction.CLASS_NAME; | ||
} | ||
|
||
constructor(logLevel?: LogLevelDesc) { |
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.
@StepniowskiP Please use an interface to define an object that contains the options, that way adding new arguments can be done within that object instead of having to pile up new options as the Nth constructor parameter and struggle with ordering, etc.
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.
Done
import commands from "iroha-helpers-ts/lib/commands/index"; | ||
import queries from "iroha-helpers-ts/lib/queries"; | ||
|
||
export class Transaction { |
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.
@StepniowskiP Could this be called IrohaTransactionWrapper
instead? The Iroha
prefix will help with distinguishing it in the logs from every other ledger's transaction logs and the Wrapper
will hint at the fact that it's not the class/type that ships with the Iroha libraries that we use.
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.
Sure, renamed to IrohaTransactionWrapper
public async sendSyncRequest(syncRequestData: any): Promise<void> { | ||
this.log.debug(`Inside ##sendSyncRequest()`); | ||
|
||
syncRequestData["syncRequest"] = true; |
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.
@StepniowskiP Could this input mutation be avoided by having the boolean flag as a separate parameter of the sendAsyncRequest
method?
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.
I have added flag parameter async to sendRequest function
clearInterval(this.monitoringInterval); | ||
} | ||
|
||
public async sendAsyncRequest(asyncRequestData: any): Promise<any> { |
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.
@StepniowskiP If it supports both sync and async would it make sense to not call it sendAsyncRequest
but maybe sendRequest
?
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.
Sure, renamed and refactored
const block = await this.sendAsyncRequest(syncRequestData); | ||
this.log.debug(block); | ||
this.socket.emit("response", block.transactionReceipt); | ||
} catch (err: any) { |
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.
@StepniowskiP Can you use unknown
instead of any
?
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.
Done
socket: SocketIoSocket; | ||
} | ||
|
||
export class SocketSessionEndpoint { |
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.
@StepniowskiP Any chance that you could make the name of the class and the constructor arg interface type consistent?
SocketSessionEndpoint
is a bit too generic in my opinion because literally every endpoint that uses SocketIO could be accurately be described by the same name.
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.
Sure, renamed to iroha-socketio-endpoint
@@ -206,6 +206,9 @@ | |||
"type": "boolean", | |||
"nullable": false, | |||
"description": "Can only be set to false for an insecure grpc connection." | |||
}, | |||
"monitorMode": { |
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.
@StepniowskiP mode
implies to me an enum not a boolean, could you add a description to the spec here that explains what this does and what are the possible values (true
and false
) change in the behavior?
If it is a boolean then maybe call it monitorModeEnabled
and if it has more possible values other than true/false then make it an enum so that later on those other possible values can be added as needed without having to break backwards compatibility.
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.
I have added description to this parameter
fixes for iroha pr hyperledger-cacti#1966 Signed-off-by: stepniowskip <[email protected]>
fixes for iroha pr hyperledger-cacti#1966 Signed-off-by: stepniowskip <[email protected]>
fixes for iroha pr hyperledger-cacti#1966 Signed-off-by: stepniowskip <[email protected]>
args: any, | ||
method?: Record<string, unknown>, |
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.
@StepniowskiP Is it just me or the parameters are still out of order (e.g. not backwards compatible)?
This is the diff I'm looking at:
@petermetz Author of this PR no longer works for us, I'll take over this task. I've opened separate PR here - #2048 where I've fixed the ordering issue you mentioned. Please continue your review there, and close this PR since it'll not be handled anymore. |
Add monitoring and sending async/sync requests to ledger via SocketIO.