-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds a engine API retry which will continue to retry an API call if the API currently reports that the API is closed. This is useful for when leadership changes are in progress (typical during boot where leaders are actively being shuffled). The retry will continue to retry an active API call every 300ms when the API reports as closed (because leadership has caused the API to be closed). The retry will continue to cancel calls if the caller has cancelled the context, or if the cron is shutting down. Signed-off-by: joshvanl <me@joshvanl.dev>
- Loading branch information
Showing
9 changed files
with
421 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* | ||
Copyright (c) 2024 Diagrid Inc. | ||
Licensed under the MIT License. | ||
*/ | ||
|
||
package fake | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/diagridio/go-etcd-cron/internal/api" | ||
) | ||
|
||
type Fake struct { | ||
runFn func(context.Context) error | ||
apiFn func() api.Interface | ||
} | ||
|
||
func New() *Fake { | ||
return &Fake{ | ||
runFn: func(context.Context) error { | ||
return nil | ||
}, | ||
apiFn: func() api.Interface { | ||
return nil | ||
}, | ||
} | ||
} | ||
|
||
func (f *Fake) WithRun(fn func(context.Context) error) *Fake { | ||
f.runFn = fn | ||
return f | ||
} | ||
|
||
func (f *Fake) WithAPI(a api.Interface) *Fake { | ||
f.apiFn = func() api.Interface { return a } | ||
|
||
return f | ||
} | ||
|
||
func (f *Fake) Run(ctx context.Context) error { | ||
return f.runFn(ctx) | ||
} | ||
|
||
func (f *Fake) API() api.Interface { | ||
return f.apiFn() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
Copyright (c) 2025 Diagrid Inc. | ||
Licensed under the MIT License. | ||
*/ | ||
|
||
package fake | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/diagridio/go-etcd-cron/internal/engine" | ||
) | ||
|
||
func Test_Fake(t *testing.T) { | ||
var _ engine.Interface = New() | ||
} |
Oops, something went wrong.