-
Notifications
You must be signed in to change notification settings - Fork 2
feat: execute successfully completed actions once #206
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
Conversation
internal/controller/controller.go
Outdated
|
|
||
| startedActionsWg sync.WaitGroup | ||
| startedActions map[string]struct{} | ||
| completedActions map[string]time.Time |
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.
guess it's time to create a map + RWMutex as a separate struct
internal/controller/controller.go
Outdated
| now := time.Now() | ||
|
|
||
| s.startedActionsMu.Lock() | ||
| defer s.startedActionsMu.Unlock() |
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.
why are u locking on startedActionsMu here? i think it's better to lock on separate mutex
once again, i think we need simple concurrent map as separate struct
| observedMax := maxExecutingObserved | ||
| counts := make(map[string]int) | ||
| for k, v := range executionCounts { | ||
| counts[k] = v |
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.
cirisked
left a comment
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.
all good, but i'd like to have separate struct to handle concurrent map read/write ops
internal/controller/controller.go
Outdated
| healthCheck *health.HealthzProvider | ||
| actionsMu sync.Mutex | ||
| startedActions map[string]struct{} // protected by actionsMu | ||
| completedActions map[string]int8 // protected by actionsMu |
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.
[nit] I'd call it recentlyCompletedActions to be more accurrate

actions might be executed at least twice as PollActions and AckAction are asynchronous operations and can sometimes race. Introduce a store for tracking recently completed actions to avoid that. The completed actions will be garbage collected after two polls when they are completed and successfully acked.