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
b0c130c5
Commit
b0c130c5
authored
9 years ago
by
ale
Browse files
Options
Downloads
Patches
Plain Diff
use CreateDir to initialize presence directory
parent
6855abb0
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
coordination/etcdtest/fake_etcd.go
+1
-1
1 addition, 1 deletion
coordination/etcdtest/fake_etcd.go
coordination/presence/presence.go
+3
-6
3 additions, 6 deletions
coordination/presence/presence.go
etcd_client.go
+1
-1
1 addition, 1 deletion
etcd_client.go
with
5 additions
and
8 deletions
coordination/etcdtest/fake_etcd.go
+
1
−
1
View file @
b0c130c5
...
@@ -200,7 +200,7 @@ func (s *FakeEtcdClient) Set(key, value string, ttl uint64) (*etcd.Response, err
...
@@ -200,7 +200,7 @@ func (s *FakeEtcdClient) Set(key, value string, ttl uint64) (*etcd.Response, err
return
s
.
trigger
(
"set"
,
key
),
nil
return
s
.
trigger
(
"set"
,
key
),
nil
}
}
func
(
s
*
FakeEtcdClient
)
Set
Dir
(
key
string
,
ttl
uint64
)
(
*
etcd
.
Response
,
error
)
{
func
(
s
*
FakeEtcdClient
)
Create
Dir
(
key
string
,
ttl
uint64
)
(
*
etcd
.
Response
,
error
)
{
// TODO. There are no directories.
// TODO. There are no directories.
return
&
etcd
.
Response
{},
nil
return
&
etcd
.
Response
{},
nil
}
}
...
...
This diff is collapsed.
Click to expand it.
coordination/presence/presence.go
+
3
−
6
View file @
b0c130c5
package
presence
package
presence
import
(
import
(
"fmt"
"log"
"log"
"time"
"time"
...
@@ -12,10 +11,10 @@ import (
...
@@ -12,10 +11,10 @@ import (
type
EtcdClient
interface
{
type
EtcdClient
interface
{
AddChild
(
key
string
,
value
string
,
ttl
uint64
)
(
*
etcd
.
Response
,
error
)
AddChild
(
key
string
,
value
string
,
ttl
uint64
)
(
*
etcd
.
Response
,
error
)
Create
(
key
string
,
value
string
,
ttl
uint64
)
(
*
etcd
.
Response
,
error
)
Create
(
key
string
,
value
string
,
ttl
uint64
)
(
*
etcd
.
Response
,
error
)
CreateDir
(
key
string
,
ttl
uint64
)
(
*
etcd
.
Response
,
error
)
Update
(
key
string
,
value
string
,
ttl
uint64
)
(
*
etcd
.
Response
,
error
)
Update
(
key
string
,
value
string
,
ttl
uint64
)
(
*
etcd
.
Response
,
error
)
Delete
(
key
string
,
recursive
bool
)
(
*
etcd
.
Response
,
error
)
Delete
(
key
string
,
recursive
bool
)
(
*
etcd
.
Response
,
error
)
Get
(
key
string
,
sort
,
recursive
bool
)
(
*
etcd
.
Response
,
error
)
Get
(
key
string
,
sort
,
recursive
bool
)
(
*
etcd
.
Response
,
error
)
SetDir
(
key
string
,
ttl
uint64
)
(
*
etcd
.
Response
,
error
)
}
}
// A Client can read the list of active nodes written by Presence workers.
// A Client can read the list of active nodes written by Presence workers.
...
@@ -77,10 +76,8 @@ func (p *Presence) Stop() {
...
@@ -77,10 +76,8 @@ func (p *Presence) Stop() {
// Start the presence worker.
// Start the presence worker.
func
(
p
*
Presence
)
Start
()
error
{
func
(
p
*
Presence
)
Start
()
error
{
// Create the presence directory if it does not exist.
// Create the presence directory if it does not exist. Ignore errors.
if
_
,
err
:=
p
.
client
.
SetDir
(
p
.
path
,
0
);
err
!=
nil
{
p
.
client
.
CreateDir
(
p
.
path
,
0
)
return
fmt
.
Errorf
(
"could not create presence directory: %v"
,
err
)
}
go
p
.
run
()
go
p
.
run
()
return
nil
return
nil
...
...
This diff is collapsed.
Click to expand it.
etcd_client.go
+
1
−
1
View file @
b0c130c5
...
@@ -90,11 +90,11 @@ func NewEtcdClient(strongReads bool) EtcdClient {
...
@@ -90,11 +90,11 @@ func NewEtcdClient(strongReads bool) EtcdClient {
type
EtcdClient
interface
{
type
EtcdClient
interface
{
AddChild
(
string
,
string
,
uint64
)
(
*
etcd
.
Response
,
error
)
AddChild
(
string
,
string
,
uint64
)
(
*
etcd
.
Response
,
error
)
Create
(
string
,
string
,
uint64
)
(
*
etcd
.
Response
,
error
)
Create
(
string
,
string
,
uint64
)
(
*
etcd
.
Response
,
error
)
CreateDir
(
string
,
uint64
)
(
*
etcd
.
Response
,
error
)
CompareAndSwap
(
string
,
string
,
uint64
,
string
,
uint64
)
(
*
etcd
.
Response
,
error
)
CompareAndSwap
(
string
,
string
,
uint64
,
string
,
uint64
)
(
*
etcd
.
Response
,
error
)
Delete
(
string
,
bool
)
(
*
etcd
.
Response
,
error
)
Delete
(
string
,
bool
)
(
*
etcd
.
Response
,
error
)
Get
(
string
,
bool
,
bool
)
(
*
etcd
.
Response
,
error
)
Get
(
string
,
bool
,
bool
)
(
*
etcd
.
Response
,
error
)
Set
(
string
,
string
,
uint64
)
(
*
etcd
.
Response
,
error
)
Set
(
string
,
string
,
uint64
)
(
*
etcd
.
Response
,
error
)
SetDir
(
string
,
uint64
)
(
*
etcd
.
Response
,
error
)
Update
(
string
,
string
,
uint64
)
(
*
etcd
.
Response
,
error
)
Update
(
string
,
string
,
uint64
)
(
*
etcd
.
Response
,
error
)
Watch
(
string
,
uint64
,
bool
,
chan
*
etcd
.
Response
,
chan
bool
)
(
*
etcd
.
Response
,
error
)
Watch
(
string
,
uint64
,
bool
,
chan
*
etcd
.
Response
,
chan
bool
)
(
*
etcd
.
Response
,
error
)
}
}
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