-
Notifications
You must be signed in to change notification settings - Fork 4
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: workflow status listener - RK-19190 #85
Conversation
Signed-off-by: Gosha <[email protected]>
cmd/piper/piper.go
Outdated
//if err != nil { | ||
// panic(err) | ||
//} | ||
ctx := context.Background() |
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 would split the code to 2 files
event_handlers.go
func HandleWorkflowEvents(workflowClient) {
// create the watch and start listening to events and also handling them
}
piper.go (this is the main)
go HandleWorkflowEvents(globalClients.Workflows)
This way piper.go only deals with initializing stuff and not doing any actual logic
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.
already on it :D
check the new commit @qadiludmer
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.
see comment
Signed-off-by: Gosha <[email protected]>
Signed-off-by: Gosha <[email protected]>
pkg/event_handler/event_handler.go
Outdated
|
||
type eventHandlerImpl struct{} | ||
|
||
func (eh *eventHandlerImpl) handle(workflowChan <-chan watch.Event) { |
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.
handle should get the actual event, not the channel
pkg/event_handler/main.go
Outdated
|
||
handlerImpl := &eventHandlerImpl{} | ||
go func() { | ||
handlerImpl.handle(watcher.ResultChan()) |
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.
here you should wait for channel data and once new data arrive pass it to the handler
pkg/event_handler/event_handler.go
Outdated
func (eh *eventHandlerImpl) handle(workflowChan <-chan watch.Event) { | ||
log.Printf("event handler started") | ||
for event := range workflowChan { | ||
wf, ok := event.Object.(*v1alpha1.Workflow) |
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.
type checking should be done on the Start()
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.
see comments
Signed-off-by: Gosha <[email protected]>
Signed-off-by: Gosha <[email protected]>
Signed-off-by: Gosha <[email protected]>
Signed-off-by: Gosha <[email protected]>
Signed-off-by: Gosha <[email protected]>
Signed-off-by: Gosha <[email protected]>
@qadiludmer followed you comments, and eventually erased the handler. think that I will bring it back |
Signed-off-by: Gosha <[email protected]>
Signed-off-by: Gosha <[email protected]>
Signed-off-by: Gosha <[email protected]>
Signed-off-by: Gosha <[email protected]>
Signed-off-by: Gosha <[email protected]>
Signed-off-by: Gosha <[email protected]>
Signed-off-by: Gosha <[email protected]>
Signed-off-by: Gosha <[email protected]>
Signed-off-by: Gosha <[email protected]>
Signed-off-by: GoshaDozoretz <[email protected]>
Signed-off-by: Gosha <[email protected]>
Signed-off-by: Gosha [email protected]
Pull Request
Description
Please provide a brief description of the changes made in this pull request.
Related Issue(s)
If this pull request addresses or relates to any open issues, please mention them here using the syntax
Fixes #<issue_number>
orResolves #<issue_number>
.Checklist
Before submitting this pull request, please ensure that you have completed the following tasks:
Testing Instructions
Please provide clear instructions on how to test and verify the changes made in this pull request.
Additional Information
Add any additional information or context that would be helpful in understanding and reviewing this pull request.