Documentation
¶
Index ¶
- Variables
- func EncodePublishInfo(info *PublishInfo) (string, error)
- func RegisterAccount(endpoints []string, user, pass string)
- func RegisterTLS(endpoints []string, certFile, certKeyFile, caFile string, ...) error
- type Container
- type EtcdConf
- type InstanceState
- type KV
- type PubOption
- type PublishInfo
- type Publisher
- type SubOption
- type Subscriber
Constants ¶
This section is empty.
Variables ¶
var TimeToLive = timeToLive
TimeToLive is seconds to live in etcd.
Functions ¶
func EncodePublishInfo ¶
func EncodePublishInfo(info *PublishInfo) (string, error)
func RegisterAccount ¶
RegisterAccount registers the username/password to the given etcd cluster.
Types ¶
type EtcdConf ¶
type EtcdConf struct {
Hosts []string
Key string
ID int64 `json:",optional"`
InstanceID string `json:",optional"`
User string `json:",optional"`
Pass string `json:",optional"`
CertFile string `json:",optional"`
CertKeyFile string `json:",optional=CertFile"`
CACertFile string `json:",optional=CertFile"`
InsecureSkipVerify bool `json:",optional"`
}
EtcdConf is the config item with the given key on etcd.
func (EtcdConf) HasAccount ¶
HasAccount returns if account provided.
type InstanceState ¶ added in v0.3.0
type InstanceState string
InstanceState describes whether a discovered instance accepts ordinary traffic.
const ( InstanceReady InstanceState = "ready" InstanceDraining InstanceState = "draining" )
func (InstanceState) Valid ¶ added in v0.3.0
func (s InstanceState) Valid() bool
type PubOption ¶
type PubOption func(client *Publisher)
PubOption defines the method to customize a Publisher.
func WithPubEtcdAccount ¶
WithPubEtcdAccount provides the etcd username/password.
func WithPubEtcdTLS ¶
WithPubEtcdTLS provides the etcd CertFile/CertKeyFile/CACertFile.
type PublishInfo ¶
type PublishInfo struct {
Addr string
InstanceID string
State InstanceState
}
func DecodePublishInfo ¶
func DecodePublishInfo(data string) (*PublishInfo, error)
type Publisher ¶
type Publisher struct {
// contains filtered or unexported fields
}
A Publisher can be used to publish the value to an etcd cluster on the given key.
func NewPublisher ¶
NewPublisher returns a Publisher. endpoints is the hosts of the etcd cluster. key:value are a pair to be published. opts are used to customize the Publisher.
func (*Publisher) Close ¶ added in v0.3.0
Close stops renewing and synchronously revokes the active registration.
type SubOption ¶
type SubOption func(sub *Subscriber)
SubOption defines the method to customize a Subscriber.
func Exclusive ¶
func Exclusive() SubOption
Exclusive means that key value can only be 1:1, which means later added value will remove the keys associated with the same value previously.
func WithContainer ¶
WithContainer provides a custom container to the subscriber.
func WithExactMatch ¶
func WithExactMatch() SubOption
WithExactMatch turn off querying using key prefixes.
func WithSubEtcdAccount ¶
WithSubEtcdAccount provides the etcd username/password.
func WithSubEtcdTLS ¶
WithSubEtcdTLS provides the etcd CertFile/CertKeyFile/CACertFile.
type Subscriber ¶
type Subscriber struct {
// contains filtered or unexported fields
}
A Subscriber is used to subscribe the given key on an etcd cluster.
func NewSubscriber ¶
func NewSubscriber(endpoints []string, key string, opts ...SubOption) (*Subscriber, error)
NewSubscriber returns a Subscriber. endpoints is the hosts of the etcd cluster. key is the key to subscribe. opts are used to customize the Subscriber.
func (*Subscriber) AddListener ¶
func (s *Subscriber) AddListener(listener func())
AddListener adds listener to s.
func (*Subscriber) Instances ¶ added in v0.3.0
func (s *Subscriber) Instances() []PublishInfo
Instances returns the valid service instances in the current snapshot. Malformed entries are isolated so that one bad registration cannot hide healthy instances published under the same discovery key.
func (*Subscriber) Values ¶
func (s *Subscriber) Values() []string
Values returns all the subscription values.