service

package
v0.0.0-...-0a82276 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

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

func NewService(st State) *Service

NewService returns a new service reference wrapping the input state.

func (*Service) ClaimLease

func (s *Service) ClaimLease(ctx context.Context, key lease.Key, req lease.Request) error

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

func (s *Service) ExpireLeases(ctx context.Context) error

ExpireLeases ensures that all leases that have expired are deleted from the store.

func (*Service) ExtendLease

func (s *Service) ExtendLease(ctx context.Context, key lease.Key, req lease.Request) error

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

func (s *Service) Leases(ctx context.Context, keys ...lease.Key) (map[lease.Key]lease.Info, error)

Leases (lease.Store) returns all leases in the database, optionally filtering using the input keys.

func (*Service) PinLease

func (s *Service) PinLease(ctx context.Context, key lease.Key, entity string) error

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

func (s *Service) Pinned(ctx context.Context) (map[lease.Key][]string, error)

Pinned (lease.Store) returns all leases that are currently pinned, and the entities requiring such behaviour for them.

func (*Service) RevokeLease

func (s *Service) RevokeLease(ctx context.Context, key lease.Key, holder string) error

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

func (s *Service) UnpinLease(ctx context.Context, key lease.Key, entity string) error

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.

Jump to

Keyboard shortcuts

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