Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
autoradio
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ale
autoradio
Commits
a9f5c36a
Commit
a9f5c36a
authored
3 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
Minor logging changes to coordination packages
parent
64203771
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
coordination/election/election.go
+4
-0
4 additions, 0 deletions
coordination/election/election.go
coordination/watcher/watcher.go
+0
-2
0 additions, 2 deletions
coordination/watcher/watcher.go
with
4 additions
and
2 deletions
coordination/election/election.go
+
4
−
0
View file @
a9f5c36a
...
...
@@ -52,6 +52,7 @@ func (s ElectionState) String() string {
// Election manages (or witnesses) an election protocol on a given
// database prefix.
type
Election
struct
{
path
string
session
*
concurrency
.
Session
election
*
concurrency
.
Election
self
*
pb
.
Endpoint
...
...
@@ -63,6 +64,7 @@ type Election struct {
func
New
(
session
*
concurrency
.
Session
,
path
string
,
self
*
pb
.
Endpoint
)
*
Election
{
el
:=
concurrency
.
NewElection
(
session
,
path
)
return
&
Election
{
path
:
path
,
session
:
session
,
election
:
el
,
self
:
self
,
...
...
@@ -120,10 +122,12 @@ func (e *Election) runOnce(ctx context.Context, data string, op Op) error {
}
// Invoke the leader operation.
log
.
Printf
(
"we are now the leader for %s"
,
e
.
path
)
err
=
op
(
ctx
)
// Resign, if the session is still valid. Use a standalone
// Context to resign even on cancellation.
log
.
Printf
(
"resigning leadership for %s"
,
e
.
path
)
rctx
,
cancel
:=
context
.
WithTimeout
(
context
.
Background
(),
3
*
time
.
Second
)
rerr
:=
e
.
election
.
Resign
(
rctx
)
cancel
()
...
...
This diff is collapsed.
Click to expand it.
coordination/watcher/watcher.go
+
0
−
2
View file @
a9f5c36a
...
...
@@ -2,7 +2,6 @@ package watcher
import
(
"context"
"fmt"
"log"
"sync"
"time"
...
...
@@ -131,7 +130,6 @@ func watchOnce(ctx context.Context, cli *clientv3.Client, prefix string, target
rch
:=
cli
.
Watch
(
ctx
,
prefix
,
clientv3
.
WithPrefix
(),
clientv3
.
WithRev
(
rev
))
for
resp
:=
range
rch
{
for
_
,
ev
:=
range
resp
.
Events
{
fmt
.
Printf
(
"%s %q : %q
\n
"
,
ev
.
Type
,
ev
.
Kv
.
Key
,
ev
.
Kv
.
Value
)
key
:=
string
(
ev
.
Kv
.
Key
)[
plen
:
]
switch
ev
.
Type
{
case
clientv3
.
EventTypePut
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment