package module
Version: v0.0.0-...-cfa62bf Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Jul 29, 2014 License: Apache-2.0 Imports: 6 Imported by: 0


sidekick is a library that will update a key in etcd periodically.

If sidekick.New() returns without an error, there will be a goroutine keeping the key refreshed in etcd.



hostname,err := os.Hostname()  
// comma separated list of server URLs  
etcdServers := "http://localhost:4001"  
etcdPath := "/servers/web/" + hostname  
value := "running"  
sk, _ := sidekick.New(etcdServers,etcdpath,value)  

To change the value of the key, use:


To stop updates to etcd, use:


To change from the default key TTL or update interval use:


If you want a standalone utility, see the sidekicker directory.




View Source
const DefaultTTL = 10

DefaultTTL is the default time-to-live in seconds for updates to etcd

View Source
const DefaultUpdateInterval = 8

DefaultUpdateInterval is the default frequently in seconds the key will be updated until Stop() is called


View Source
var (
	ErrIntervalTooSmall = errors.New("interval must be at least 1 second")


This section is empty.


type Sidekick

type Sidekick struct {
	// contains filtered or unexported fields

Sidekick periodically updates a key in etcd until Stop() is called

func New

func New(servers string, key string, value string) (*Sidekick, error)

New returns a Sidekick pointer if there was no error initially setting the value, and there will be a goroutine updating the value every UpdateInterval seconds until Stop() is called If a non-nil error is returned there will be no goroutine performing updates

func (*Sidekick) SetLogger

func (sk *Sidekick) SetLogger(logger *log.Logger)

SetLogger sets a logger, by default no logs are written. This is a no-op if Stop() has been called.

func (*Sidekick) Stop

func (sk *Sidekick) Stop()

Stop stops the goroutine performing updates. This is a no-op if Stop() has been called.

func (*Sidekick) TTL

func (sk *Sidekick) TTL(ttl uint64) error

TTL sets the time-to-live on every update made to etcd. This is a no-op if Stop() has been called. TODO: validation on TTL

func (*Sidekick) UpdateInterval

func (sk *Sidekick) UpdateInterval(interval uint64) error

UpdateInterval sets the update interval to the value in seconds. This is a no-op if Stop() has been called.

func (*Sidekick) Value

func (sk *Sidekick) Value(value string)

Value changes the value used and performs an update. This is a no-op if Stop() has been called.

Source Files


Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL