-
Notifications
You must be signed in to change notification settings - Fork 81
adapt event types and values to messaging-api spec #3839
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -131,34 +131,34 @@ proc logosdelivery_start_node( | |
| ctx.myLib[].brokerCtx, | ||
| proc(event: MessageSentEvent) {.async: (raises: []).} = | ||
| callEventCallback(ctx, "onMessageSent"): | ||
| $newJsonEvent("message_sent", event), | ||
| $newJsonEvent("message:sent", event), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also looks like a breaking change 🤔 |
||
| ).valueOr: | ||
| chronicles.error "MessageSentEvent.listen failed", err = $error | ||
| return err("MessageSentEvent.listen failed: " & $error) | ||
|
|
||
| let errorListener = MessageErrorEvent.listen( | ||
| let errorListener = MessageSendErrorEvent.listen( | ||
| ctx.myLib[].brokerCtx, | ||
| proc(event: MessageErrorEvent) {.async: (raises: []).} = | ||
| callEventCallback(ctx, "onMessageError"): | ||
| $newJsonEvent("message_error", event), | ||
| proc(event: MessageSendErrorEvent) {.async: (raises: []).} = | ||
| callEventCallback(ctx, "onMessageSendError"): | ||
| $newJsonEvent("message:send-error", event), | ||
| ).valueOr: | ||
| chronicles.error "MessageErrorEvent.listen failed", err = $error | ||
| return err("MessageErrorEvent.listen failed: " & $error) | ||
| chronicles.error "MessageSendErrorEvent.listen failed", err = $error | ||
| return err("MessageSendErrorEvent.listen failed: " & $error) | ||
|
|
||
| let propagatedListener = MessagePropagatedEvent.listen( | ||
| let propagatedListener = MessageSendPropagatedEvent.listen( | ||
| ctx.myLib[].brokerCtx, | ||
| proc(event: MessagePropagatedEvent) {.async: (raises: []).} = | ||
| callEventCallback(ctx, "onMessagePropagated"): | ||
| $newJsonEvent("message_propagated", event), | ||
| proc(event: MessageSendPropagatedEvent) {.async: (raises: []).} = | ||
| callEventCallback(ctx, "onMessageSendPropagated"): | ||
| $newJsonEvent("message:send-propagated", event), | ||
| ).valueOr: | ||
| chronicles.error "MessagePropagatedEvent.listen failed", err = $error | ||
| return err("MessagePropagatedEvent.listen failed: " & $error) | ||
| chronicles.error "MessageSendPropagatedEvent.listen failed", err = $error | ||
| return err("MessageSendPropagatedEvent.listen failed: " & $error) | ||
|
|
||
| let receivedListener = MessageReceivedEvent.listen( | ||
| ctx.myLib[].brokerCtx, | ||
| proc(event: MessageReceivedEvent) {.async: (raises: []).} = | ||
| callEventCallback(ctx, "onMessageReceived"): | ||
| $newJsonEvent("message_received", event), | ||
| $newJsonEvent("message:received", event), | ||
| ).valueOr: | ||
| chronicles.error "MessageReceivedEvent.listen failed", err = $error | ||
| return err("MessageReceivedEvent.listen failed: " & $error) | ||
|
|
@@ -184,9 +184,9 @@ proc logosdelivery_stop_node( | |
| requireInitializedNode(ctx, "STOP_NODE"): | ||
| return err(errMsg) | ||
|
|
||
| MessageErrorEvent.dropAllListeners(ctx.myLib[].brokerCtx) | ||
| MessageSendErrorEvent.dropAllListeners(ctx.myLib[].brokerCtx) | ||
| MessageSentEvent.dropAllListeners(ctx.myLib[].brokerCtx) | ||
| MessagePropagatedEvent.dropAllListeners(ctx.myLib[].brokerCtx) | ||
| MessageSendPropagatedEvent.dropAllListeners(ctx.myLib[].brokerCtx) | ||
| MessageReceivedEvent.dropAllListeners(ctx.myLib[].brokerCtx) | ||
| EventConnectionStatusChange.dropAllListeners(ctx.myLib[].brokerCtx) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -181,7 +181,7 @@ proc reportTaskResult(self: SendService, task: DeliveryTask) = | |
| if not task.propagateEventEmitted: | ||
| info "Message successfully propagated", | ||
| requestId = task.requestId, msgHash = task.msgHash.to0xHex() | ||
| MessagePropagatedEvent.emit( | ||
| MessageSendPropagatedEvent.emit( | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think here the spec is wrong and the simpler form
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is my fault; I should have renamed the events in the code when I cleaned up the spec before the LMAPI release. I agree with Zoltan here. We should fix the spec, not the code. MessageSendErrorEvent is technically correct, but MessageErrorEvent stuck and at the "simple send" LMAPI level, the only MessageErrorEvent is the send event, so the discrimination that I added there is doing zero actual work. Also MessageSendPropagatedEvent -> MessagePropagatedEvent with even less loss of meaning or risk of symbol collision or rot. What do you guys think? Should we submit a fix to the spec instead?
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay fair enough. Thanks for the comments both! |
||
| self.brokerCtx, task.requestId, task.msgHash.to0xHex() | ||
| ) | ||
| task.propagateEventEmitted = true | ||
|
|
@@ -196,7 +196,7 @@ proc reportTaskResult(self: SendService, task: DeliveryTask) = | |
| requestId = task.requestId, | ||
| msgHash = task.msgHash.to0xHex(), | ||
| error = task.errorDesc | ||
| MessageErrorEvent.emit( | ||
| MessageSendErrorEvent.emit( | ||
| self.brokerCtx, task.requestId, task.msgHash.to0xHex(), task.errorDesc | ||
| ) | ||
| return | ||
|
|
@@ -211,7 +211,7 @@ proc reportTaskResult(self: SendService, task: DeliveryTask) = | |
| error = "Message too old", | ||
| age = task.messageAge() | ||
| task.state = DeliveryState.FailedToDeliver | ||
| MessageErrorEvent.emit( | ||
| MessageSendErrorEvent.emit( | ||
| self.brokerCtx, | ||
| task.requestId, | ||
| task.msgHash.to0xHex(), | ||
|
|
||
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.
These are breaking changes for logos-delivery-module! Needs follow up and new release afterward.