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.
- type Sidekick
const DefaultTTL = 10
DefaultTTL is the default time-to-live in seconds for updates to etcd
const DefaultUpdateInterval = 8
DefaultUpdateInterval is the default frequently in seconds the key will be updated until Stop() is called
This section is empty.
Sidekick periodically updates a key in etcd until Stop() is called
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
SetLogger sets a logger, by default no logs are written. This is a no-op if Stop() has been called.
func (sk *Sidekick) Stop()
Stop stops the goroutine performing updates. This is a no-op if Stop() has been called.
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 ¶
UpdateInterval sets the update interval to the value in seconds. This is a no-op if Stop() has been called.