server

package
v0.0.0-...-501dce0 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientFilterAll

func ClientFilterAll(ci ClientInfo) bool

ClientFilterAll returns all clients

func VolumeFilterAll

func VolumeFilterAll(v Volume) bool

VolumeFilterAll returns all Volumes

Types

type Backend

type Backend interface {
	ClientInterface
	LeaseInterface
	VolumeInterface
}

Backend defines functions implemented by the data store

type ClientFilterFunc

type ClientFilterFunc func(ClientInfo) bool

ClientFilterFunc is a function to filter a list of clients based on a given condition

func ClientFilterByStatus

func ClientFilterByStatus(status ClientStatus) ClientFilterFunc

ClientFilterByStatus returns clients that match a given status

type ClientInfo

type ClientInfo struct {
	ID        string
	Status    ClientStatus
	FirstSeen time.Time
	LastSeen  time.Time
}

ClientInfo details information about a given client

type ClientInterface

type ClientInterface interface {
	GetClient(string) (ClientInfo, error)
	AddClient(string) error
	UpdateClient(string, ClientStatus) error
	RemoveClient(string) error
	Clients(ClientFilterFunc) ([]ClientInfo, error)

	WriteNotification(string, Notification) error
	WatchNotifications(string, chan<- Notification) error
	AckNotification(string) error
	WatchNotification(string) (chan struct{}, error)
}

ClientInterface defines functions for managing clients

type ClientStatus

type ClientStatus int

ClientStatus describes client's current status

const (
	// UnknownClientStatus indicates the client status is unknown
	UnknownClientStatus ClientStatus = iota

	// AliveClientStatus indicates the client is alive
	AliveClientStatus

	// DeadClientStatus indicate the client is dead/unresponsive
	DeadClientStatus

	// LeftClientStatus indicates the client intentionally left
	LeftClientStatus
)

type LeaseInterface

type LeaseInterface interface {
	ListLeaseRequests(lease.LeaseRequestFilterFunc) ([]*lease.LeaseRequest, error)
	AddLeaseRequest(*lease.LeaseRequest) error
	UpdateLeaseRequest(*lease.LeaseRequest) error
	DeleteLeaseRequest(string) error

	AddLease(*lease.Lease) error
	ListLeases(lease.LeaseFilterFunc) ([]*lease.Lease, error)
	UpdateLease(*lease.Lease) error
	DeleteLease(string) error
}

LeaseInterface defines functions for managing volume leases

type Notification

type Notification struct {
	ID      string
	Type    NotificationType
	Message string
}

Notification is a message to be passed to the client

func NewNotification

func NewNotification(t NotificationType, message string) Notification

NewNotification returns a new Notification with a given type and message

type NotificationType

type NotificationType int

NotificationType defines the type of notification sent to the client during streaming

const (
	// UnknownNotificationType is a base value
	UnknownNotificationType NotificationType = iota

	// LeaseRequestAckNotificationType is an acknowledgement of receipt of a LeaseRequest submission
	LeaseRequestAckNotificationType

	// LeaseRequestExpiredNotificationType is an announcement that a lease request has expired
	// and needs to be renwed
	LeaseRequestExpiredNotificationType

	// LeaseAvailableNotificationType is an announcement that a lease is available for a given volume
	LeaseAvailableNotificationType

	// LeaseNotificationType is an announcement that a lease has been allocated to a client
	LeaseNotificationType
)

type ResourceManager

type ResourceManager interface {
	Associate(*lease.Lease) error
	Disassociate(*lease.Lease) error
}

ResourceManager is responsible for managing the underlying resource represented by a Volume, with a given client

type Server

type Server struct {
	svc.UnimplementedVolchestratorServer
	svc.UnimplementedVolchestratorAdminServer
	// contains filtered or unexported fields
}

Server interacts with clients to manage volume leases

func NewServer

func NewServer(b Backend, r ResourceManager) *Server

NewServer creates a new Server with a given Backend

func (*Server) Acknowledge

func (s *Server) Acknowledge(ctx context.Context, msg *svc.Acknowledgement) (*svc.Empty, error)

Acknowledge handles an acknowledgement from the client of a Notification

func (*Server) AddVolume

func (s *Server) AddVolume(ctx context.Context, volume *svc.Volume) (*svc.Volume, error)

AddVolume adds a new volume to the backend

func (*Server) DeleteVolume

func (s *Server) DeleteVolume(ctx context.Context, volumeID *svc.VolumeID) (*svc.Empty, error)

DeleteVolume deletes a volume from the backend

func (*Server) Deregister

func (s *Server) Deregister(ctx context.Context, req *svc.DeregisterMessage) (*svc.Empty, error)

Deregister removes a clients and all its elements

func (*Server) GetVolume

func (s *Server) GetVolume(ctx context.Context, volumeID *svc.VolumeID) (*svc.Volume, error)

GetVolume returns a Volume for a given ID, or nil if the volume ID is not found in the backend

func (*Server) Heartbeat

Heartbeat handles client HeartbeatMessages

func (*Server) Init

func (s *Server) Init()

Init starts background routines

func (*Server) ListClients

func (s *Server) ListClients(ctx context.Context, m *svc.Empty) (*svc.ClientList, error)

ListClients returns the ClientMap info

func (*Server) ListLeases

func (s *Server) ListLeases(ctx context.Context, e *svc.Empty) (*svc.LeaseList, error)

ListLeases returns all Leases in the backend

func (*Server) ListVolumes

func (s *Server) ListVolumes(ctx context.Context, e *svc.Empty) (*svc.VolumeList, error)

ListVolumes returns all volumes currently in the backend

func (*Server) Prune

func (s *Server) Prune()

Prune cleans up various resources

func (*Server) Register

func (s *Server) Register(ctx context.Context, req *svc.RegisterMessage) (*svc.Empty, error)

Register adds a new client

func (*Server) SubmitLeaseRequest

func (s *Server) SubmitLeaseRequest(ctx context.Context, request *svc.LeaseRequest) (*svc.Empty, error)

SubmitLeaseRequest adds a LeaseRequest to the backend

func (*Server) UpdateVolume

func (s *Server) UpdateVolume(ctx context.Context, volume *svc.Volume) (*svc.Volume, error)

UpdateVolume performs an in-place update of an existing volume in the backend

func (*Server) WatchNotifications

WatchNotifications is called for a client to watch notifications

type Volume

type Volume struct {
	ID               string
	Tags             []string
	AvailabilityZone string
	Status           VolumeStatus
}

Volume represents a definition of an EBS volume in the data store

type VolumeFilterFunc

type VolumeFilterFunc func(Volume) bool

VolumeFilterFunc is a function to filter a list of Volumes based on a given condition

func VolumeFilterByStatus

func VolumeFilterByStatus(status VolumeStatus) VolumeFilterFunc

VolumeFilterByStatus returns volumes with a status of AvailableVolumeStatus

type VolumeInterface

type VolumeInterface interface {
	GetVolume(string) (*Volume, error)
	ListVolumes(VolumeFilterFunc) ([]*Volume, error)
	AddVolume(*Volume) error
	UpdateVolume(*Volume) error
	DeleteVolume(string) error
}

VolumeInterface defines functions for managing volumes

type VolumeStatus

type VolumeStatus int

VolumeStatus describes a volume's current status

const (
	// UnknownVolumeStatus indicates the volume status is unknown
	UnknownVolumeStatus VolumeStatus = iota

	// AvailableVolumeStatus indicates the volume is available for leasing
	AvailableVolumeStatus

	// LeasePendingVolumeStatus indicates the volume is pending a lease acquisition from a client
	LeasePendingVolumeStatus

	// LeasedVolumeStatus indicates the volume is currently leased by a client
	LeasedVolumeStatus
)

Directories

Path Synopsis
backend
resource
nop

Jump to

Keyboard shortcuts

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