Skip to content
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

feat: enable cohort to pass on_commit messages for messenger #94

Merged
merged 4 commits into from
Nov 14, 2023

Conversation

gk-kindred
Copy link
Collaborator

@gk-kindred gk-kindred commented Nov 13, 2023

  • As this introduces a change in the contract by adding an option onCommit, will need to publish new package. Probably safe to still push as minor as no one really consumes the JS packages yet.
  • The topic for onCommit is hardcoded in the example apps, to keep it simple for example sake, thereby minimising refactor.
  • Load/performance tested with the rust version and performance has been pretty much in range to earlier commit.
    • Expect 4000 / actual between 3200 to 3500

image

"publish": {
"kafka": [
{
"topic": "test.transfer.feedback",
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoded topic as it's just the example app, and to minimise refactor.

Copy link

codecov bot commented Nov 13, 2023

Codecov Report

Attention: 39 lines in your changes are missing coverage. Please review.

Comparison is base (4e540d9) 57.35% compared to head (7907aa2) 57.00%.

❗ Current head 7907aa2 differs from pull request most recent head 53d6cfb. Consider uploading reports for the commit 53d6cfb to get more accurate results

Files Patch % Lines
packages/cohort_sdk/src/model/callback.rs 0.00% 20 Missing ⚠️
packages/cohort_banking/src/app.rs 0.00% 13 Missing ⚠️
packages/cohort_sdk/src/cohort.rs 0.00% 4 Missing ⚠️
.../src/callbacks/certification_candidate_provider.rs 0.00% 1 Missing ⚠️
packages/cohort_banking/src/model/requests.rs 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #94      +/-   ##
==========================================
- Coverage   57.35%   57.00%   -0.36%     
==========================================
  Files         113      113              
  Lines        5666     5707      +41     
==========================================
+ Hits         3250     3253       +3     
- Misses       2416     2454      +38     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

}
}

// TODO: GK - Add on commit action
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this supported? If we support action why dont we add them to interface too?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good point, messenger is written in a way that it can accept any valid json, but will only process the supported types.

But on the other end, it would be nice if the sender is made aware on what they can send. Let me think on it and see how I can add this in at the cohort end. Thank for pointing this out!

@@ -6,7 +6,8 @@ pub struct CandidateData {
pub readset: Vec<String>,
pub writeset: Vec<String>,
pub statemap: Option<Vec<HashMap<String, Value>>>,
// The "snapshot" is intentionally messing here. We will compute it ourselves before feeding this data to Talos
// The "snapshot" is intentionally missing here. We will compute it ourselves before feeding this data to Talos
pub on_commit: Option<Value>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add stricter type restrictions on the SDK end for messenger payload
// #[derive(Debug, Serialize, Deserialize, Clone, Eq, PartialEq)]
// #[serde(rename_all = "camelCase")]
#[napi(object)]
pub struct JSKafkaAction {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor, not a blocker for PR merge. Just most of the data structures use "Js" prefix (here we seems to use "JS")

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, that should be Js I will update that soon. Thanks for spotting it

@@ -113,10 +138,11 @@ export interface JsCertificationCandidate {
Before SDK can issue a certification request to Talos Certifier it needs some details from you. You will have to query your local database to fetch the following:
1. Identifiers and version numbers of all objects involved in your transaction. These are known as `readset`, `writeset` and `readvers`.
2. The copy of your transaction as one serializable object. It makes sense to describe your transaction as JSON object and serialise it to string. This is known as `statemap`.
3. Any additional message to be published for candidate requests with committed decision outcome, can added to `onCommit` field. Currently the SDK supports only publishing to **Kafka**.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we want to say "can be added to" ?

@gk-kindred gk-kindred merged commit 127d304 into master Nov 14, 2023
2 checks passed
@gk-kindred gk-kindred deleted the feature/cohort-handle-on-commit-messages branch November 14, 2023 23:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants