Documentation ¶
Index ¶
- type Service
- func (s *Service) ClaimLease(ctx context.Context, key lease.Key, req lease.Request) error
- func (s *Service) ExpireLeases(ctx context.Context) error
- func (s *Service) ExtendLease(ctx context.Context, key lease.Key, req lease.Request) error
- func (s *Service) LeaseGroup(ctx context.Context, namespace, modelUUID string) (map[lease.Key]lease.Info, error)
- func (s *Service) Leases(ctx context.Context, keys ...lease.Key) (map[lease.Key]lease.Info, error)
- func (s *Service) PinLease(ctx context.Context, key lease.Key, entity string) error
- func (s *Service) Pinned(ctx context.Context) (map[lease.Key][]string, error)
- func (s *Service) RevokeLease(ctx context.Context, key lease.Key, holder string) error
- func (s *Service) UnpinLease(ctx context.Context, key lease.Key, entity string) error
- type State
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service provides the API for working with external controllers.
func NewService ¶
NewService returns a new service reference wrapping the input state.
func (*Service) ClaimLease ¶
ClaimLease (lease.Store) claims the lease indicated by the input key, for the holder and duration indicated by the input request. The lease must not already be held, otherwise an error is returned.
func (*Service) ExpireLeases ¶
ExpireLeases ensures that all leases that have expired are deleted from the store.
func (*Service) ExtendLease ¶
ExtendLease (lease.Store) ensures the input lease will be held for at least the requested duration starting from now. If the input holder does not currently hold the lease, an error is returned.
func (*Service) LeaseGroup ¶
func (s *Service) LeaseGroup(ctx context.Context, namespace, modelUUID string) (map[lease.Key]lease.Info, error)
LeaseGroup (lease.Store) returns all leases for the input namespace and model.
func (*Service) Leases ¶
Leases (lease.Store) returns all leases in the database, optionally filtering using the input keys.
func (*Service) PinLease ¶
PinLease (lease.Store) adds the input entity into the lease_pin table to indicate that the lease indicated by the input key must not expire, and that this entity requires such behaviour.
func (*Service) Pinned ¶
Pinned (lease.Store) returns all leases that are currently pinned, and the entities requiring such behaviour for them.
func (*Service) RevokeLease ¶
RevokeLease (lease.Store) deletes the lease from the store, provided it exists and is held by the input holder. If either of these conditions is false, an error is returned.
func (*Service) UnpinLease ¶
UnpinLease (lease.Store) removes the record indicated by the input key and entity from the lease pin table, indicating that the entity no longer requires the lease to be pinned. When there are no entities associated with a particular lease, it is determined not to be pinned, and can expire normally.
type State ¶
type State interface { Leases(context.Context, ...lease.Key) (map[lease.Key]lease.Info, error) ClaimLease(context.Context, uuid.UUID, lease.Key, lease.Request) error ExtendLease(context.Context, lease.Key, lease.Request) error RevokeLease(context.Context, lease.Key, string) error LeaseGroup(context.Context, string, string) (map[lease.Key]lease.Info, error) PinLease(context.Context, lease.Key, string) error UnpinLease(context.Context, lease.Key, string) error Pinned(context.Context) (map[lease.Key][]string, error) ExpireLeases(context.Context) error }
State describes retrieval and persistence methods for storage.