Documentation
¶
Index ¶
Constants ¶
const ( SkipNone = 0 SkipUUID = (1 << iota) SkipSnapUUID SkipCapacity )
const ( // these two are supposedly mutually exclusive... ACLAllowAny = "ALLOW_ANY" ACLAllowNone = "ALLOW_NONE" )
const ( DefaultClientPoolDialTimeout = 10 * time.Second DefaultClientPoolLingerTime = 10 * time.Minute DefaultClientPoolReapCycle = time.Minute )
ClientPool options defaults
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client interface {
Close()
// ID() returns a unique opaque string ID of this client.
ID() string
// Targets() returns a sorted list of unique target endpoints this instance handles.
Targets() string
RemoteOk(ctx context.Context) error
GetCluster(ctx context.Context) (*Cluster, error)
GetClusterInfo(ctx context.Context) (*ClusterInfo, error)
ListNodes(ctx context.Context) ([]*Node, error)
CreateVolume(ctx context.Context, name string, capacity uint64,
replicaCount uint32, compress bool, acl []string, projectName string,
snapshotID guuid.UUID, qosPolicyName string, blocking bool,
) (*Volume, error)
DeleteVolume(ctx context.Context, uuid guuid.UUID, projectName string, blocking bool) error
GetVolume(ctx context.Context, uuid guuid.UUID, projectName string) (*Volume, error)
GetVolumeByName(ctx context.Context, name string, projectName string) (*Volume, error)
UpdateVolume(ctx context.Context, uuid guuid.UUID, projectName string,
hook VolumeUpdateHook,
) (*Volume, error)
CreateSnapshot(ctx context.Context, name string, projectName string, srcVolUUID guuid.UUID,
descr string, blocking bool,
) (*Snapshot, error)
DeleteSnapshot(ctx context.Context, uuid guuid.UUID, projectName string, blocking bool) error
GetSnapshot(ctx context.Context, uuid guuid.UUID, projectName string) (*Snapshot, error)
GetSnapshotByName(ctx context.Context, name string, projectName string) (*Snapshot, error)
}
type ClientPool ¶
type ClientPool struct {
// contains filtered or unexported fields
}
ClientPool maintains a pool of long-lived LB clients that can be reused across individual RPC invocations to avoid connection/authentication overheads. only one live client per target is kept.
func NewClientPool ¶
func NewClientPool(dialer DialFunc) *ClientPool
NewClientPool creates and sets up a LB client pool with default config. see NewClientPoolWithOptions() for a more flexible version.
func NewClientPoolWithOptions ¶
func NewClientPoolWithOptions(dialer DialFunc, opts ClientPoolOptions) *ClientPool
NewClientPoolWithOptions creates and sets up a LB client pool using the timeouts specified in `opts`. uninitialised values in `opts` are set to defaults.
func (*ClientPool) Close ¶
func (cp *ClientPool) Close()
Close wraps up the LB client pool operation. it is a blocking call that will invoke Close() each of the individual clients and wait for those calls to return.
func (*ClientPool) GetClient ¶
func (cp *ClientPool) GetClient( ctx context.Context, targets endpoint.Slice, mgmtScheme string, ) (Client, error)
GetClient returns a ready-to-use LB client that can be used to control `target` LB. if none exist at the time of invocation, one will be created and connected to `target` transparently. GetClient() might block for the duration of dialling - within the constraints of the global pool dial timeout and `ctx` passed in (timeout, cancellation). this `ctx` has effect only on dialling, subsequent individual requests to the client itself take their own contexts.
clients obtained from the pool using GetClient() must be returned to the pool using PutClient() once the caller is done using them.
func (*ClientPool) PutClient ¶
func (cp *ClientPool) PutClient(c Client)
PutClient returns a client that necessarily must have been previously obtained from the receiver pool back to the pool.
type ClientPoolOptions ¶
type ClientPoolOptions struct {
// callers are expected to occasionally retry if dialling fails,
// normally at the behest of higher-level business logic.
// default: `lb.DefaultClientPoolDialTimeout`
DialTimeout time.Duration
// LB client is not immediately closed when the last active user
// returns it to the pool, but are left in live state for
// approximately `LingerTime` for future reuse. after that they
// are harvested at some point by the reaper.
// default: `DefaultClientPoolLingerTime`
LingerTime time.Duration
// approximately once every `ReapCycle` LB clients that are
// past their `LingerTime` will be harvested.
// default: `DefaultClientPoolReapCycle`
ReapCycle time.Duration
}
ClientPoolOptions defines ClientPool operational behaviour
type ClusterInfo ¶
type NodeState ¶
type NodeState int32
type NodesByName ¶
type NodesByName []*Node
for sort.Interface:
func (NodesByName) Len ¶
func (n NodesByName) Len() int
func (NodesByName) Less ¶
func (n NodesByName) Less(i, j int) bool
func (NodesByName) Swap ¶
func (n NodesByName) Swap(i, j int)
type SnapshotState ¶
type SnapshotState int32
const ( SnapshotStateUnknown SnapshotState = 0 SnapshotCreating SnapshotState = 1 SnapshotAvailable SnapshotState = 2 SnapshotDeleting SnapshotState = 3 SnapshotDeleted SnapshotState = 4 SnapshotFailed SnapshotState = 7 )
func (SnapshotState) String ¶
func (s SnapshotState) String() string
type Volume ¶
type Volume struct {
// "core" volume properties. q.v. IsSameAs().
Name string
UUID guuid.UUID
ReplicaCount uint32
Capacity uint64
LogicalUsedStorage uint64
Compression bool
SnapshotUUID guuid.UUID
QosPolicyName string
ACL []string
State VolumeState
Protection VolumeProtection
ETag string
ProjectName string
}
func (*Volume) ExplainDiffsFrom ¶
ExplainDiffsFrom returns a list of human-readable sentences describing the differences between a pair of volumes. the volumes are referred to in the output as lDescr and rDescr, a pair of adjectives will work well for those. only "core" volume properties are examined.
func (*Volume) IsAccessible ¶
func (*Volume) IsSameAs ¶
IsSameAs compares only "core" volume properties, rather than transient state, such as the current State, Protection and ACL.
func (*Volume) IsWritable ¶
type VolumeProtection ¶
type VolumeProtection int32
const ( VolumeProtectionUnknown VolumeProtection = 0 VolumeProtected VolumeProtection = 1 VolumeDegraded VolumeProtection = 2 VolumeReadOnly VolumeProtection = 3 VolumeNotAvailable VolumeProtection = 4 )
match present LB API values. here's to API stability!
func (VolumeProtection) String ¶
func (s VolumeProtection) String() string
type VolumeState ¶
type VolumeState int32
const ( VolumeStateUnknown VolumeState = 0 VolumeCreating VolumeState = 1 VolumeAvailable VolumeState = 2 VolumeDeleting VolumeState = 3 // TODO: remove deprecated states once the LightOS API drops them: VolumeDeletedDEPRECATED VolumeState = 4 VolumeFailed VolumeState = 7 VolumeUpdating VolumeState = 8 VolumeRollback VolumeState = 9 VolumeMigrating VolumeState = 10 )
match present LB API values. here's to API stability!
func (VolumeState) String ¶
func (s VolumeState) String() string
type VolumeUpdate ¶
type VolumeUpdate struct {
// full desired target ACL. nil slice to not update ACL, empty slice
// to clear ACL.
ACL []string
Capacity uint64
}
VolumeUpdate struct expresses the desired state of the specified (i.e. non-nil/default) volume properties.
type VolumeUpdateHook ¶
type VolumeUpdateHook func(vol *Volume) (update *VolumeUpdate, err error)
VolumeUpdateHook is passed to Client.UpdateVolume(). it will be invoked by UpdateVolume() with the freshly updated state of the volume as `vol` param. if updates to the volume are required, VolumeUpdateHook should return `update` with the desired state of the specified fields, otherwise - nil `update` should be returned, causing the update operation to be skipped. if the UpdateVolume() operation should be aborted, VolumeUpdateHook should return non-nil `err`, this error will be propagated back verbatim to the UpdateVolume() caller. care should, therefore, be taken when choosing the error type and value to return, if the ability to differentiate between the local/remote client/server errors and VolumeUpdateHook errors is a consideration.