server

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2021 License: MIT Imports: 2 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrServerUnknown        = errors.New("ulysses/server: server type is not registered")
	ErrServerConfigurables  = errors.New("ulysses/server: bad server config")
	ErrAccountConfigurables = errors.New("ulysses/server: bad account config")
)

Caller of this module should check the returned error against the list provided below. Any error returned not appearing in the list should be considered as an Internal Error and should not be displayed to Customer/Non-Dev.

Functions

func RegisterServer added in v0.0.11

func RegisterServer(serverTypeName string, serverGen ServerGen)

RegisterServer tells the server module how to instantiate a server struct

Types

type AccountCredentials added in v0.0.11

type AccountCredentials interface {
	Customer() (credentials map[string]string)
	Admin() (credentials map[string]string)
}

It is up to module designer to parse/utilize the Credential.

type AccountResourceGroup added in v0.0.11

type AccountResourceGroup interface {
	AllResourceNames() []string
	SelectedResources(resNames ...string) map[string]*Resource
}

It is up to module designer to parse/utilize the AccountUsage.

type Resource added in v0.0.11

type Resource struct {
	Name        string
	Description string
	Allocated   float64
	Used        float64
}

func (Resource) Usage added in v0.0.11

func (res Resource) Usage() (Allocated, Used, Available float64)

type Server

type Server interface {

	// ResourceGroup() shows usage statistics of all allocatable resources on the server
	ResourceGroup() ServerResourceGroup

	// CreateAccount() utilizes internal server configuration and aconf pased in to create a series of accounts with
	// same sconf and variable aconf in order.
	CreateAccount(referenceID int, accountConfiguration interface{}) error

	// ReadAccount() returns an ServerAccount-compatible struct
	ReadAccount(referenceID int) (ServerAccount, error)

	// UpdateAccount() utilizes internal server configuration and aconf pased in to update a series of accounts
	// specified by referenceID.
	UpdateAccount(referenceID int, accountConfiguration interface{}) error

	// DeleteAccount() utilizes internal server configuration to delete a series of accounts specified by accID.
	DeleteAccount(referenceID int) error

	// PurgeResourceUsage sets all USED resource counter to 0 for all users.
	// usecase: clean-reinstall
	// Won't be automatically called on a time-basis. Not a cronjob mounting point.
	PurgeResourceUsage()
}

func NewServer added in v0.0.11

func NewServer(db *sql.DB, serverType string, instanceID string, serverConfiguration interface{}) (Server, error)

NewServer returns a Server interface specified by serverType according to the ServerRegistrarMap the internal state of the returned Server interface should reflect sconf.

type ServerAccount added in v0.0.11

type ServerAccount interface {
	Credentials() (AccountCredentials, error)
	ResourceGroup() (AccountResourceGroup, error)
}

type ServerGen added in v0.0.11

type ServerGen func(db *sql.DB, instanceID string, serverConfiguration interface{}) (Server, error)

type ServerResourceAllocation added in v0.0.11

type ServerResourceAllocation struct {
	UserAllocatedPercentageMap map[string]float64
	UserConsumedPercentageMap  map[string]float64
}

type ServerResourceGroup added in v0.0.11

type ServerResourceGroup interface {
	AllResourceNames() []string
	SelectedResources(resNames ...string) map[string]*Resource

	ResourceAllocations(resNames ...string) map[string]*ServerResourceAllocation
}

It is up to module designer to parse/utilize the AccountUsage.

Jump to

Keyboard shortcuts

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