Documentation ¶
Index ¶
- func IsEtcdServerEnabled() (enabled bool, err error)
- func IsEtcdServerEnabledInVip(vip *viper.Viper) (enabled bool, err error)
- type EtcdClient
- func (client *EtcdClient) Close()
- func (client *EtcdClient) CompareAndSwap(key string, prevValue string, newValue string) (ok bool, err error)
- func (client *EtcdClient) Delete(key string) error
- func (client *EtcdClient) Get(key string) (value string, ok bool, err error)
- func (client *EtcdClient) GetByKeyPrefix(key string) (values []string, err error)
- func (client *EtcdClient) NewMutex(key string) (mutex *EtcdClientMutex, err error)
- func (client *EtcdClient) Put(key string, value string) (err error)
- func (client *EtcdClient) PutIfAbsent(key string, value string) (ok bool, err error)
- func (client *EtcdClient) Transaction(compare []EtcdKeyValue, swap []EtcdKeyValue) (ok bool, err error)
- type EtcdClientConf
- type EtcdClientMutex
- type EtcdKeyValue
- type EtcdServer
- type EtcdServerConf
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsEtcdServerEnabled ¶
IsEtcdServerEnabled checls that etcd server is enabled using conf file
Types ¶
type EtcdClient ¶
type EtcdClient struct {
// contains filtered or unexported fields
}
EtcdClient struct has some useful methods to wolrk with etcd client
func NewEtcdClient ¶
func NewEtcdClient(metaData *blockchain.OrganizationMetaData) (client *EtcdClient, err error)
NewEtcdClient create new etcd storage client.
func NewEtcdClientFromVip ¶
func NewEtcdClientFromVip(vip *viper.Viper, metaData *blockchain.OrganizationMetaData) (client *EtcdClient, err error)
NewEtcdClientFromVip create new etcd storage client from viper.
func (*EtcdClient) CompareAndSwap ¶
func (client *EtcdClient) CompareAndSwap(key string, prevValue string, newValue string) (ok bool, err error)
CompareAndSwap uses CAS operation to set a value
func (*EtcdClient) Delete ¶
func (client *EtcdClient) Delete(key string) error
Delete deletes the existing key and value from etcd
func (*EtcdClient) Get ¶
func (client *EtcdClient) Get(key string) (value string, ok bool, err error)
Get gets value from etcd by key
func (*EtcdClient) GetByKeyPrefix ¶
func (client *EtcdClient) GetByKeyPrefix(key string) (values []string, err error)
GetByKeyPrefix gets all values which have the same key prefix
func (*EtcdClient) NewMutex ¶
func (client *EtcdClient) NewMutex(key string) (mutex *EtcdClientMutex, err error)
NewMutex Create a mutex for the given key
func (*EtcdClient) Put ¶
func (client *EtcdClient) Put(key string, value string) (err error)
Put puts key and value to etcd
func (*EtcdClient) PutIfAbsent ¶
func (client *EtcdClient) PutIfAbsent(key string, value string) (ok bool, err error)
PutIfAbsent puts value if absent
func (*EtcdClient) Transaction ¶
func (client *EtcdClient) Transaction(compare []EtcdKeyValue, swap []EtcdKeyValue) (ok bool, err error)
Transaction uses CAS operation to compare and set multiple key values
type EtcdClientConf ¶
type EtcdClientConf struct { ConnectionTimeout time.Duration `json:"connection_timeout" mapstructure:"connection_timeout"` RequestTimeout time.Duration `json:"request_timeout" mapstructure:"request_timeout"` Endpoints []string }
EtcdClientConf config ConnectionTimeout - timeout for failing to establish a connection RequestTimeout - per request timeout Endpoints - cluster endpoints
func GetEtcdClientConf ¶
func GetEtcdClientConf(vip *viper.Viper, metaData *blockchain.OrganizationMetaData) (conf *EtcdClientConf, err error)
GetEtcdClientConf gets EtcdServerConf from viper The DefaultEtcdClientConf is used in case the PAYMENT_CHANNEL_STORAGE_CLIENT field is not set in the configuration file Left Vip, just in case we need to read something from configuration in the future
type EtcdClientMutex ¶
type EtcdClientMutex struct {
// contains filtered or unexported fields
}
EtcdClientMutex mutex struct for etcd client
type EtcdKeyValue ¶
type EtcdKeyValue struct {
// contains filtered or unexported fields
}
EtcdKeyValue contains key and value
type EtcdServer ¶
type EtcdServer struct {
// contains filtered or unexported fields
}
EtcdServer struct has some useful methods to wolrk with etcd server
func GetEtcdServer ¶
func GetEtcdServer() (server *EtcdServer, err error)
GetEtcdServer returns EtcdServer in case it is defined in the viper config reuturns null if PAYMENT_CHANNEL_STORAGE property is not defined in the config file or the ENABLED field of the PAYMENT_CHANNEL_STORAGE is set to false
func GetEtcdServerFromVip ¶
func GetEtcdServerFromVip(vip *viper.Viper) (server *EtcdServer, err error)
GetEtcdServerFromVip run etcd server using viper config
type EtcdServerConf ¶
type EtcdServerConf struct { ID string Scheme string Host string ClientPort int `json:"client_port" mapstructure:"CLIENT_PORT"` PeerPort int `json:"peer_port" mapstructure:"PEER_PORT"` Token string Cluster string StartupTimeout time.Duration `json:"startup_timeout" mapstructure:"startup_timeout"` Enabled bool DataDir string `json:"data_dir" mapstructure:"DATA_DIR"` LogLevel string `json:"log_level" mapstructure:"LOG_LEVEL"` }
EtcdServerConf contains embedded etcd server config ID - unique name of the etcd server node Scheme - URL schema used to create client and peer and urls Host - host where the etcd server is executed ClientPort - port to listen clients, used together with
Schema and host to compose listen-client-urls (see link below)
PeerPort - port to listen etcd peers, used together with
Schema and host to compose listen-client-urls (see link below)
Token - unique initial cluster token. Using unique token etcd can generate unique
cluster IDs and member IDs for the clusters even if they otherwise have the exact same configuration. This can protect etcd from cross-cluster-interaction, which might corrupt the clusters.
StartupTimeout - time to wait the etcd server successfully started Enabled - enable running embedded etcd server For more details see etcd Clustering Guide link: https://github.com/etcd-io/etcd/blob/master/Documentation/op-guide/clustering.md
func GetEtcdServerConf ¶
func GetEtcdServerConf(vip *viper.Viper) (conf *EtcdServerConf, err error)
GetEtcdServerConf gets EtcdServerConf from viper The DefaultEtcdServerConf is used in case the PAYMENT_CHANNEL_STORAGE_SERVER field is not set in the configuration file