-
Notifications
You must be signed in to change notification settings - Fork 6
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
refactor: change leader election semantics. #238
Conversation
Now leader election campaign will not return when the node beomes leader, instead it will block until the leader election session exists, updating status proactively. This change will make leader election status more accurate.
Codecov Report
@@ Coverage Diff @@
## v0.13.x #238 +/- ##
===========================================
- Coverage 82.88% 82.57% -0.31%
===========================================
Files 94 96 +2
Lines 3751 3840 +89
===========================================
+ Hits 3109 3171 +62
- Misses 475 492 +17
- Partials 167 177 +10
Continue to review full report at Codecov.
|
@@ -2,12 +2,17 @@ package cron | |||
|
|||
import ( | |||
"context" | |||
_ "embed" |
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.
a blank import should be only in a main or test package, or have a comment justifying it
@@ -22,7 +22,16 @@ func TestElection(t *testing.T) { | |||
return | |||
} | |||
addrs := strings.Split(os.Getenv("ETCD_ADDR"), ",") | |||
dispatcher := &events.Event[*Status]{} | |||
dispatcher := Dispatcher(&events.Event[*Status]{}) |
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.
missing ',' in argument list (and 10 more errors)
@@ -20,36 +23,41 @@ func TestNewEtcdDriver(t *testing.T) { | |||
} | |||
ctx, cancel := context.WithTimeout(context.Background(), 60*time.Second) | |||
defer cancel() | |||
dispatcher := &events.Event[*leader.Status]{} |
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.
expected ';', found '{'
* fix(factory): on reload, close the connection right away. graceful shutdown logic should be implemented in the close function, not in the factory. * fix(cron): test flakes * feat: add eventv2 * wip: prototyping generics api * wip: prototyping generics api * wip: prototyping generics api * feat: ctxmeta support generic * fix: asyncContext.Value interface to any * wip: generics * wip: add once to event * refactor: remove text package * feat: interface{} to any * refactor: remove deprecated cron * test: workflow go-version 1.18beta2 * test: setup-go stable false * test: fix workflow go-version * doc: add listener comment * feat: simplify run group * fix: remove deprecatedcron test * fix: missing StatusChanged * fix: some test * feat: simplify run group * fix: some import style * fix: remove config module dispatcher * fix(otgorm): hooks (#236) * fix(otgorm): hooks * fix: remove debug prints (cherry picked from commit 1afb3d7) * refactor(control): add pool * fix(pool): data race * fix(pool): data race * fix(pool): go vet "call to (*T).Fatalf from a non-test goroutine" * refactor: change leader election semantics. (#238) * refactor: change leader election semantics. Now leader election campaign will not return when the node beomes leader, instead it will block until the leader election session exists, updating status proactively. This change will make leader election status more accurate. * fix(leader): mock driver for test * fix: return if renew fails * test: increase test duration * docs: add jetbrains thanks * fix(cron): example flakes * fix(leader): TestElection block test * fix(leader): missing dispatch when leader status on * fix(leader): test data race * fix(leader): test key conflict * test(ots3): test container of minio * feat: add a simple way to ensure cron jobs to run at least once for each schedule. * doc: add comment * fix(leaderredis): data race Co-authored-by: Trock <g_trock@163.com> * fix: server.go merge conflict * feat(test): upgrade github actions * fix: otredis TestModule_ProvideCommand * fix: workflow lint add setup-go * fix: workflow lint add setup-go * fix: pool.Run need start before call Go method when use async mode. * feat: add pool.Counter to observe the status of pool. Co-authored-by: Trock <g_trock@163.com> Co-authored-by: Trock <35254251+GGXXLL@users.noreply.github.com>
Now leader election campaign will not return when the node beomes leader, instead it will block until the leader election session exits, updating status proactively. This change will make leader election status more accurate.