Documentation ¶
Index ¶
- Constants
- func AddParts(address string) (string, int, error)
- func CheckPasswordAgainstHash(password, hash string) bool
- func CnvSliceStrToSliceInf(in []string) []interface{}
- func ExternalIP() (string, error)
- func Find(a []string, x interface{}, op string) bool
- func GenerateBcryptHash(password string, cost int) (string, error)
- func Hash(s string, f crypto.Hash) string
- func HashFNV(s string) string
- func IsNotFound(err error) bool
- func NewHTTPClient() *http.Client
- func ParseDuration(durationStr string) (time.Duration, error)
- func Path(keys ...string) string
- func RandToken() string
- func ReachableTCP(addr string) error
- func ReportFailureEtcdRequestCounter(clusterID, action, path string)
- func RetryableError(err error) bool
- func RuntimeStats() []string
- type BasicAuthTransport
- type Etcd
- func (e *Etcd) CheckKey(key string) bool
- func (e *Etcd) Context() (context.Context, context.CancelFunc)
- func (e *Etcd) DoDelete(key string, opts ...etcdv3.OpOption) (*etcdv3.DeleteResponse, error)
- func (e *Etcd) DoGet(key string, opts ...etcdv3.OpOption) (*etcdv3.GetResponse, error)
- func (e *Etcd) DoGrant(ttl int64) (*etcdv3.LeaseGrantResponse, error)
- func (e *Etcd) DoKeepAlive(id etcdv3.LeaseID) error
- func (e *Etcd) DoKeepAliveOnce(id etcdv3.LeaseID) (*etcdv3.LeaseKeepAliveResponse, error)
- func (e *Etcd) DoPut(key, val string, opts ...etcdv3.OpOption) (*etcdv3.PutResponse, error)
- func (e *Etcd) DoRevoke(id etcdv3.LeaseID) (*etcdv3.LeaseRevokeResponse, error)
- func (e *Etcd) DoSync() error
- func (e *Etcd) LeaseContext() (context.Context, context.CancelFunc)
- func (e *Etcd) Run(stopc chan struct{})
- func (e *Etcd) WatchContext() (context.Context, context.CancelFunc)
- type EtcdError
- type FernetString
- type Registry
- type RegistryItem
- type Worker
Constants ¶
const ( // DefaultEtcdRetryCount for Etcd operations DefaultEtcdRetryCount = 3 // DefaultEtcdtIntervalBetweenRetries for Etcd failed operations DefaultEtcdtIntervalBetweenRetries = time.Second * 5 )
Variables ¶
This section is empty.
Functions ¶
func CheckPasswordAgainstHash ¶
CheckPasswordAgainstHash compares the password with the hashed password
func CnvSliceStrToSliceInf ¶
func CnvSliceStrToSliceInf(in []string) []interface{}
CnvSliceStrToSliceInf converts the given slice of string to slice of interface which be used later in logging.
func ExternalIP ¶
ExternalIP returns an external ip address of the current host
func Find ¶
Find tells whether string contains x. op - boolean operator, expected `AND` `OR` string value. x - could be string or slice of string.
func GenerateBcryptHash ¶
GenerateBcryptHash return the hash password
func Hash ¶
Hash generates a new slice of bytee hash from a given string using a given hash algorithms.
func HashFNV ¶
HashFNV generates a new 64-bit number from a given string using 64-bit FNV-1a hash function.
func IsNotFound ¶
IsNotFound verifies the type of given error is NotFound or not.
func NewHTTPClient ¶
NewHTTPClient returns the net/http.Client with a custom set of configs.
func ParseDuration ¶
ParseDuration parses a string into a time.Duration, assuming that a year always has 365d, a week always has 7d, and a day always has 24h.
func ReachableTCP ¶
ReachableTCP checks an address is reachable via TCP.
func ReportFailureEtcdRequestCounter ¶
func ReportFailureEtcdRequestCounter(clusterID, action, path string)
func RetryableError ¶
RetryableError determines that given error is retryable or not.
func RuntimeStats ¶
func RuntimeStats() []string
RuntimeStats is used to return various runtime information
Types ¶
type BasicAuthTransport ¶
type BasicAuthTransport struct { Username string Password string // Transport is the underlying HTTP transport to use when making requests. // It will default to http.DefaultTransport if nil Transport http.RoundTripper }
BasicAuthTransport is an http.RoundTripper that authenticates all requests using HTTP Basic Authentication with the provided username and password
type Etcd ¶
Etcd is the Etcd v3 client wrapper with addition context.
func (*Etcd) CheckKey ¶
CheckKey accepts a given Etcd key with format: then finds the key. Return true if one instance is found, otherwise false.
func (*Etcd) Context ¶
func (e *Etcd) Context() (context.Context, context.CancelFunc)
Context returns a cancelable context and its cancel function.
func (*Etcd) DoDelete ¶
DoDelete deletes a key, or optionally using WithRange(end), [key, end). More details please refer to etcd clientv3.KV interface.
func (*Etcd) DoGrant ¶
func (e *Etcd) DoGrant(ttl int64) (*etcdv3.LeaseGrantResponse, error)
DoGrant creates a new lease.
func (*Etcd) DoKeepAlive ¶
DoKeepAlive attempts to keep the given lease alive forever. If the keepalive responses posted to the channel are not consumed promptly the channel may become full. When full, the lease client will continue sending keep alive requests to the etcd server, but will drop responses until there is capacity on the channel to send more responses.
If client keep alive loop halts with an unexpected error (e.g. "etcdserver: no leader") or canceled by the caller (e.g. context.Canceled), KeepAlive returns a ErrKeepAliveHalted error containing the error reason.
The returned "LeaseKeepAliveResponse" channel closes if underlying keep alive stream is interrupted in some way the client cannot handle itself; given context "ctx" is canceled or timed out.
func (*Etcd) DoKeepAliveOnce ¶
DoKeepAliveOnce renews the lease once. The response corresponds to the first message from calling KeepAlive. If the response has a recoverable error, KeepAliveOnce will retry the RPC with a new keep alive message.
func (*Etcd) DoPut ¶
DoPut puts a key-value pair into etcd. More details please refer to etcd clientv3.KV interface.
func (*Etcd) DoSync ¶
DoSync synchronizes client's endpoints with the known endpoints from etcd membership
func (*Etcd) LeaseContext ¶
func (e *Etcd) LeaseContext() (context.Context, context.CancelFunc)
LeaseContext returns a cancelable context and its cancel function.
func (*Etcd) WatchContext ¶
func (e *Etcd) WatchContext() (context.Context, context.CancelFunc)
WatchContext wraps context with the WithRequireLeader If the context is "context.Background/TODO", returned "WatchChan" will not be closed and block until event is triggered, except when server returns a non-recoverable error (e.g. ErrCompacted). For example, when context passed with "WithRequireLeader" and the connected server has no leader (e.g. due to network partition), error "etcdserver: no leader" (ErrNoLeader) will be returned, and then "WatchChan" is closed with non-nil "Err()". In order to prevent a watch stream being stuck in a partitioned node, make sure to wrap context with "WithRequireLeader".
type EtcdError ¶
type EtcdError struct {
// contains filtered or unexported fields
}
EtcdError is the Etcd error wrapper
func NewEtcdErr ¶
NewEtcdErr returns an Etcd error.
type FernetString ¶ added in v0.0.11
type FernetString struct { Token string `json:"token,omitempty"` Encrypted bool `json:"encrypted" default:"false"` }
func (*FernetString) Decrypt ¶ added in v0.0.11
func (fs *FernetString) Decrypt() bool
func (*FernetString) Encrypt ¶ added in v0.0.11
func (fs *FernetString) Encrypt() (err error)