server

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2021 License: MIT Imports: 2 Imported by: 0

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")
	ErrBadJsonObject        = errors.New("ulysses/server: bad JSON object")
	ErrBadJsonArray         = errors.New("ulysses/server: bad JSON array")
)

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 AddServerRegistrar added in v0.1.0

func AddServerRegistrar(serverTypeName string, serverReg ServerRegistrar)

AddServerRegistrar adds a registrar to the global ServerRegistrarMap

func JsonArrToConfigurablesSlice

func JsonArrToConfigurablesSlice(data []byte) ([]map[string]string, error)

JsonArrToConfigurablesSlice returns a slice of map[string]string representing a Json Array ([{}, {}, {}])

func JsonToConfigurables

func JsonToConfigurables(data []byte) (map[string]string, error)

JsonToConfigurables returns map[string]string representing a Json Object ({, , ,})

Types

type AccountUsage

type AccountUsage interface {
	ForClient() (usage string)
	ForAdmin() (usage string)
}

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

type Configurables

type Configurables map[string]string

type Credential

type Credential interface {
	ForClient() (credential string)
	ForAdmin() (credential string)
}

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

type Server

type Server interface {

	// UpdateServer() should update the internal variable of a Server to reflect the new state.
	UpdateServer(sconf Configurables) (err error)

	// AddAccount() utilizes internal server configuration and aconf pased in to create a series of accounts with
	// same sconf and variable aconf in order.
	// This function returns immediately upon an error has occured. The returned accID should contain IDs for
	// all successfully created accounts.
	AddAccount(aconf []Configurables) (accID []int, err error)

	// UpdateAccount() utilizes internal server configuration and aconf pased in to update a series of accounts
	// specified by accID.
	// This function returns immediately upon an error has occured. The returned successAccID should contain
	// IDs for all successfully updated accounts.
	UpdateAccount(accID []int, aconf []Configurables) (successAccID []int, err error)

	// DeleteAccount() utilizes internal server configuration to delete a series of accounts specified by accID.
	// This function returns immediately upon an error has occured. The returned successAccID should contain
	// IDs for all successfully deleted accounts.
	DeleteAccount(accID []int) (successAccID []int, err error)

	// GetCredentials() fetch Credentials in JSON string format for each Account specified by accID.
	GetCredentials(accID []int) ([]Credential, error)

	// GetUsage() fetch the history usages of each service specified by accID
	GetUsage(accID []int) ([]AccountUsage, error)
}

Server interface-compatible structs should be copyable. Recommended design: - Pointer to struct - Member pointers in struct

func NewServerByType added in v0.1.0

func NewServerByType(serverType string, sconf Configurables) (Server, error)

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

type ServerRegistrar

type ServerRegistrar interface {
	// NewServer returns a Server interface with internal state set to reflect sconf.
	NewServer(sconf Configurables) (Server, error)
}

ServerRegistrar interface-compatible structs should be copyable. Recommended design: - Pointer to struct - Member pointers in struct

type ServerRegistrarMap

type ServerRegistrarMap map[string]ServerRegistrar

Jump to

Keyboard shortcuts

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