discov

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TimeToLive = timeToLive

TimeToLive is seconds to live in etcd.

Functions

func RegisterAccount

func RegisterAccount(endpoints []string, user, pass string)

RegisterAccount registers the username/password to the given etcd cluster.

func RegisterTLS

func RegisterTLS(endpoints []string, certFile, certKeyFile, caFile string,
	insecureSkipVerify bool) error

RegisterTLS registers the CertFile/CertKeyFile/CACertFile to the given etcd.

Types

type EtcdConf

type EtcdConf struct {
	Hosts              []string
	Key                string
	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

func (c EtcdConf) HasAccount() bool

HasAccount returns if account provided.

func (EtcdConf) HasTLS

func (c EtcdConf) HasTLS() bool

HasTLS returns if TLS CertFile/CertKeyFile/CACertFile are provided.

func (EtcdConf) Validate

func (c EtcdConf) Validate() error

Validate validates c.

type PubOption

type PubOption func(client *Publisher)

PubOption defines the method to customize a Publisher.

func WithId

func WithId(id int64) PubOption

WithId customizes a Publisher with the id.

func WithPubEtcdAccount

func WithPubEtcdAccount(user, pass string) PubOption

WithPubEtcdAccount provides the etcd username/password.

func WithPubEtcdTLS

func WithPubEtcdTLS(certFile, certKeyFile, caFile string, insecureSkipVerify bool) PubOption

WithPubEtcdTLS provides the etcd CertFile/CertKeyFile/CACertFile.

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

func NewPublisher(endpoints []string, key, value string, opts ...PubOption) *Publisher

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) KeepAlive

func (p *Publisher) KeepAlive() error

KeepAlive keeps key:value alive.

func (*Publisher) Pause

func (p *Publisher) Pause()

Pause pauses the renewing of key:value.

func (*Publisher) Resume

func (p *Publisher) Resume()

Resume resumes the renewing of key:value.

func (*Publisher) Stop

func (p *Publisher) Stop()

Stop stops the renewing and revokes the 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 WithSubEtcdAccount

func WithSubEtcdAccount(user, pass string) SubOption

WithSubEtcdAccount provides the etcd username/password.

func WithSubEtcdTLS

func WithSubEtcdTLS(certFile, certKeyFile, caFile string, insecureSkipVerify bool) SubOption

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 a 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) Values

func (s *Subscriber) Values() []string

Values returns all the subscription values.

Directories

Path Synopsis
Package internal is a generated GoMock package.
Package internal is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL