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: workflow status listener - RK-19190 #85

Merged
merged 20 commits into from
Jul 8, 2023
Merged

feat: workflow status listener - RK-19190 #85

merged 20 commits into from
Jul 8, 2023

Conversation

gosharo
Copy link
Contributor

@gosharo gosharo commented Jul 5, 2023

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> or Resolves #<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.

@gosharo gosharo requested a review from nissim-infra as a code owner July 5, 2023 22:09
@sonariorobot sonariorobot changed the title feat: workflow status listener feat: workflow status listener - RK-19191 Jul 5, 2023
@sonariorobot sonariorobot changed the title feat: workflow status listener feat: workflow status listener - RK-19190 Jul 5, 2023
@gosharo gosharo requested a review from qadiludmer July 5, 2023 23:32
//if err != nil {
// panic(err)
//}
ctx := context.Background()
Copy link
Contributor

@qadiludmer qadiludmer Jul 6, 2023

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

Copy link
Contributor Author

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

Copy link
Contributor

@qadiludmer qadiludmer left a comment

Choose a reason for hiding this comment

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

see comment

@gosharo gosharo requested a review from qadiludmer July 6, 2023 07:25
Signed-off-by: Gosha <[email protected]>

type eventHandlerImpl struct{}

func (eh *eventHandlerImpl) handle(workflowChan <-chan watch.Event) {
Copy link
Contributor

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


handlerImpl := &eventHandlerImpl{}
go func() {
handlerImpl.handle(watcher.ResultChan())
Copy link
Contributor

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

func (eh *eventHandlerImpl) handle(workflowChan <-chan watch.Event) {
log.Printf("event handler started")
for event := range workflowChan {
wf, ok := event.Object.(*v1alpha1.Workflow)
Copy link
Contributor

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

Copy link
Contributor

@qadiludmer qadiludmer left a comment

Choose a reason for hiding this comment

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

see comments

@gosharo
Copy link
Contributor Author

gosharo commented Jul 6, 2023

@qadiludmer followed you comments, and eventually erased the handler. think that I will bring it back

@gosharo gosharo requested a review from qadiludmer July 6, 2023 16:15
@gosharo gosharo added the DeployEnforcer/MergeOnceApproved Auto merge and clean branch once passed all checks label Jul 7, 2023
@gosharo gosharo requested a review from EliRookout July 7, 2023 18:17
@gosharo gosharo merged commit a8a470e into main Jul 8, 2023
@gosharo gosharo deleted the event-listener branch July 8, 2023 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DeployEnforcer/MergeOnceApproved Auto merge and clean branch once passed all checks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants