-
Notifications
You must be signed in to change notification settings - Fork 37
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: reworked optional data sent in emitted events #140
feat: reworked optional data sent in emitted events #140
Conversation
d709bf4
to
09c110f
Compare
09c110f
to
a9a3c93
Compare
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 like this approach. Since it already breaks API compatibility, we might as well update the struct and EmitEvent method to expect map[string]string
types instead.
worker/worker.go
Outdated
@@ -158,11 +158,14 @@ func (w *Worker) Transmit(addr string, id string, responseTo string, metadata ma | |||
return | |||
} | |||
|
|||
// EmitEvent emits a WorkerEvent, worker message id, and an optional message. | |||
// EmitEvent emits a WorkerEvent, worker message id, and key-value pairs of optional data. | |||
func (w *Worker) EmitEvent(event ipc.WorkerEventName, messageID string, message string) error { |
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.
This method signature might as well change to accept a data map[string]string
parameter instead of message string
.
internal/work/dispatcher.go
Outdated
} | ||
event.Message = eventMessageData["message"] |
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.
Similarly, the WorkerEvent
struct should change to have a data map[string]string
field.
32e4520
to
ad0bab9
Compare
582caa4
to
8dcbe2b
Compare
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 appreciate the usage of golines
to wrap long lines into multiple shorter ones. However, the effective change of this PR is difficult to discern due to the extraneous line wraps. Could you please either keep all the formatting changes into a separate commit, or run golines
over the entire codebase and open a separate PR updating all the lines in one commit. I think I'd prefer the deliberate PR approach, as it can both keep the changes in a single commit and solve this formatting change for us once. But if you'd prefer a single commit on one PR, I understand.
Actually, running |
Yeah I had conflicting thoughts about this too, but I agree running it once over the entire codebase would be a better idea. It may be a good idea to update the "contributing" doc to make golines in future PRs mandatory instead of the current optional suggestion and if possible add a golines check to the linting GH action that's currently in use. |
8dcbe2b
to
c894be3
Compare
Signed-off-by: Jason Jerome <jajerome@redhat.com>
Signed-off-by: Jason Jerome <jajerome@redhat.com>
c894be3
to
2de113a
Compare
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.
Looks great!
This commit is proposing a change in how optional data is sent in emitted events
and parsed in the yggdrasil dispatcher to simplify the process if additional optional
data needs to be included in emitted worker events in the future.
This update should also not show any changes in behaviour compared to the main branch.
This work primarily came out of attempts to add a
responseTo
optional field in the emitted eventwhile avoiding parsing complications in the dispatcher. [#141]