-
Notifications
You must be signed in to change notification settings - Fork 267
Conversation
super woot, but tests didn't pass :-( |
Codecov Report
@@ Coverage Diff @@
## develop #746 +/- ##
===========================================
- Coverage 73.31% 72.19% -1.11%
===========================================
Files 138 142 +4
Lines 4690 4789 +99
===========================================
+ Hits 3438 3457 +19
- Misses 1252 1332 +80
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## develop #746 +/- ##
===========================================
- Coverage 73.76% 72.72% -1.04%
===========================================
Files 141 145 +4
Lines 4733 4842 +109
===========================================
+ Hits 3491 3521 +30
- Misses 1242 1321 +79
Continue to review full report at Codecov.
|
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 approve this because changes needed are minor (comment updates mostly)
However, there's one thing missing here which we had in proto which is timeout. Currently this blocks for ever, and we need to allow setting timeout as a followup.
Co-Authored-By: lucksus <[email protected]>
Implemented all your points, @zippy. Yes, the timeout, was thinking about this and planning to add it as follow up. Or should I add it here and now? |
I'm ok with followup unless you think it's really easy. One other thing I forgot was that there's no app_spec example. That should also be a followup. |
@@ -333,6 +333,13 @@ fn hdk_test_entry() -> Entry { | |||
Entry::App(hdk_test_app_entry_type(), hdk_test_entry_value()) | |||
} | |||
|
|||
fn handle_send_message(to_agent: Address, message: String) -> String { |
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.
So send
and receive can pass/return String, can it use other types?
Like could receive
return a ZomeApiResult?
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 tried with a Result<String, String>
but discovered a bug in JsonString::from<Result<>>
. Already synced with @thedavidmeister. So I reverted back to just String for now.
Basically possible but tried to keep the scope small for this one.
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 see, ok well knowing that we will implement a complex struct, not just a string eases my mind on this one 👍
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.
oh yeah i forgot about that bug
i'd better actually fix that! 😅
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.
Is there a follow up created for this one @lucksus @thedavidmeister ?
/// This is direct message that got created by the zome code through hdk::send(). | ||
#[derive(Serialize, Deserialize, Clone, PartialEq, Debug, DefaultJson)] | ||
pub struct CustomDirectMessage { | ||
/// We have to track which zome sent the message so we can call the |
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.
That's an interesting point... so an app can have one receive
callback per zome?
But it could handle different event types, if they were passed as data, and using a match
in receive?
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.
@Connoropolous pretty similar to how websockets works i guess, you can send and receive strings, but dispatching logic and simulating request/response behaviour is BYO
|
||
let zome_call = ZomeFnCall::new( | ||
zome, | ||
"no capability since this is a callback", |
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 thought we weren't calling this capability anymore? Trait?
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.
We haven't removed "capability" from the code yet. Otherwise this function wouldn't expect a capability name as second parameter.
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.
K
/// [define_zome!](macro.defineZome.html) macro. | ||
/// | ||
/// This functions blocks and returns the result returned by the `receive` callback on | ||
/// the other side. |
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 want to add example code in here to this description, but I am open to / happy to do that as a followup
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.
Great 👍
Co-Authored-By: lucksus <[email protected]>
Wooot! |
Usage
Define receive callback in
define_zome!
next togenesis
:Use
hdk::send
to asynchronously send and receive the return value of thereceive
callback from the other node:Yes, you can have a receive callback in each zome.
hdk::send
calls only map to the receive callback of the zome in which send gets called.Chunks
receive
added todefine_zome!
macroCustomDirectMessage
addedhandle_custom_direct_message
workflow that runs on the receiving end, calls the callback and dispatches an action to send the response