Skip to content

Commit

Permalink
Make debounced functions respect the paused_at field (#1351)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdzombak committed May 13, 2024
1 parent bda3400 commit 3af47ce
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
15 changes: 8 additions & 7 deletions pkg/execution/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,13 +272,14 @@ func (e *executor) AddLifecycleListener(l execution.LifecycleListener) {
func (e *executor) Schedule(ctx context.Context, req execution.ScheduleRequest) (*state.Identifier, error) {
if req.Function.Debounce != nil && !req.PreventDebounce {
err := e.debouncer.Debounce(ctx, debounce.DebounceItem{
AccountID: req.AccountID,
WorkspaceID: req.WorkspaceID,
AppID: req.AppID,
FunctionID: req.Function.ID,
FunctionVersion: req.Function.FunctionVersion,
EventID: req.Events[0].GetInternalID(),
Event: req.Events[0].GetEvent(),
AccountID: req.AccountID,
WorkspaceID: req.WorkspaceID,
AppID: req.AppID,
FunctionID: req.Function.ID,
FunctionVersion: req.Function.FunctionVersion,
EventID: req.Events[0].GetInternalID(),
Event: req.Events[0].GetEvent(),
FunctionPausedAt: req.FunctionPausedAt,
}, req.Function)
if err != nil {
return nil, err
Expand Down
13 changes: 7 additions & 6 deletions pkg/execution/executor/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,12 +364,13 @@ func (s *svc) handleDebounce(ctx context.Context, item queue.Item) error {
defer span.End()

_, err = s.exec.Schedule(ctx, execution.ScheduleRequest{
Function: f,
AccountID: di.AccountID,
WorkspaceID: di.WorkspaceID,
AppID: di.AppID,
Events: []event.TrackedEvent{di},
PreventDebounce: true,
Function: f,
AccountID: di.AccountID,
WorkspaceID: di.WorkspaceID,
AppID: di.AppID,
Events: []event.TrackedEvent{di},
PreventDebounce: true,
FunctionPausedAt: di.FunctionPausedAt,
})
if err != nil {
return err
Expand Down

0 comments on commit 3af47ce

Please sign in to comment.