server

package
v0.1.13 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	RESOURCE_DATA_TRANSFER uint64 = iota + 1
	RESOURCE_SERVICE_HOUR
	RESOURCE_IP_ADDRESS_V4
	RESOURCE_IP_ADDRESS_V6
	RESOURCE_TCP_PORT
	RESOURCE_UDP_PORT
)

ResourceID ENUMS

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 ProvisioningServerGen)

RegisterServer tells the server module how to instantiate a server struct. A ProvisioningServer implementation should be registered with the server module in init()

Types

type Account added in v0.0.13

type Account interface {
	Credentials() (Credentials, error)
	Resources() ([]*Resource, error)
}

type Credential

type Credential struct {
	CredentialName  string      `json:"credential_name"`
	CredentialValue interface{} `json:"credential_value"` // string, int, bool, []string, []int only
}

type Credentials added in v0.0.17

type Credentials interface {
	// Customer() returns the customer-oriented information.
	// interface{} types should be in string/number/bool/[]string/[]number
	Customer() []*Credential

	// Provider() returns the provider-oriented information.
	// interface{} types should be in string/number/bool/[]string/[]number
	Admin() []*Credential
}

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

type ProvisioningServer added in v0.0.13

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

	// ReadAccount() returns an ServerAccount-compatible struct
	GetAccount(productSN uint64) (Account, error)

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

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

	// Temporarily disable an account from being used or recover it
	SuspendAccount(productSN uint64) error
	UnsuspendAccount(productSN uint64) error

	// Monthly Refresh Usage
	RefreshAccount(productSN uint64) error
}

func NewProvisioningServer added in v0.0.14

func NewProvisioningServer(serverType, instanceID string, serverConfiguration interface{}) (ProvisioningServer, error)

NewProvisioningServer returns a ProvisioningServer interface specified by serverType according to the ServerRegistrarMap the internal state of the returned Server interface should reflect serverConfiguration. A Server implementation should utilize this function to instantiate a ProvisioningServer struct with known name.

type ProvisioningServerGen added in v0.0.13

type ProvisioningServerGen func(instanceID string, serverConfiguration interface{}) (ProvisioningServer, error)

type Resource added in v0.0.11

type Resource struct {
	ResourceID uint64  `json:"resource_id"` // enums should be saved somewhere in the database
	Allocated  float64 `json:"allocated"`
	Used       float64 `json:"used"`
	Free       float64 `json:"free"`
}

Jump to

Keyboard shortcuts

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