service

package
v0.0.0-...-daf1326 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2022 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DataLifeSpanDays = 7
)
View Source
const (
	ServicePortDefault int = 11010
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ServicePort int `envconfig:"SERVICE_PORT" yaml:"service_port"`

	LogPath string `envconfig:"LOG_PATH" yaml:"log_path,omitempty"`

	Foreground   bool `yaml:"foreground,omitempty"`
	ChildProcess bool `yaml:"childprocess,omitempty"`
}

Config holds the parameters list which can be configured

func NewConfigFromENV

func NewConfigFromENV() (*Config, error)

NewConfigFromENV creates Config from Environmental Variables

func NewConfigFromYAML

func NewConfigFromYAML(yamlBytes []byte) (*Config, error)

NewConfigFromYAML creates Config from YAML

func NewDefaultConfig

func NewDefaultConfig() *Config

NewDefaultConfig creates DefaultConfig

func (*Config) Validate

func (config *Config) Validate() error

Validate validates configuration

type MonitorService

type MonitorService struct {
	Config    *Config
	WebServer *http.Server
	Router    *mux.Router
	Storage   *Storage
}

MonitorService is a service object

func NewMonitorService

func NewMonitorService(config *Config) *MonitorService

NewMonitorService creates a new monitor service

func (*MonitorService) Destroy

func (svc *MonitorService) Destroy()

Destroy destroys the service

func (*MonitorService) Init

func (svc *MonitorService) Init() error

Init initializes the service

func (*MonitorService) Start

func (svc *MonitorService) Start() error

Start starts the service

type Storage

type Storage struct {
	Instances     map[string]types.ReportInstance
	FileTransfers map[string][]types.ReportFileTransfer
	Mutex         sync.Mutex
}

Storage is a storage object

func NewStorage

func NewStorage() *Storage

NewStorage creates a storage

func (*Storage) AddFileTransfer

func (storage *Storage) AddFileTransfer(transfer types.ReportFileTransfer) error

AddInstance adds an instance

func (*Storage) AddInstance

func (storage *Storage) AddInstance(instance types.ReportInstance)

AddInstance adds an instance

func (*Storage) CleanUp

func (storage *Storage) CleanUp()

CleanUp clears all instance and transfer data

func (*Storage) Destroy

func (storage *Storage) Destroy()

Destroy destroys the storage

func (*Storage) GetInstance

func (storage *Storage) GetInstance(instanceID string) (types.ReportInstance, bool)

GetInstance returns instance

func (*Storage) Init

func (storage *Storage) Init() error

Init initializes the storage

func (*Storage) ListFileTransfers

func (storage *Storage) ListFileTransfers() []types.ReportFileTransfer

ListInstances lists instances

func (*Storage) ListFileTransfersForInstance

func (storage *Storage) ListFileTransfersForInstance(instanceID string) []types.ReportFileTransfer

ListInstances lists instances

func (*Storage) ListInstances

func (storage *Storage) ListInstances() []types.ReportInstance

ListInstances lists instances

func (*Storage) TerminateInstance

func (storage *Storage) TerminateInstance(instanceID string) error

TerminateInstance sets the instance terminated

func (*Storage) UpdateInstanceLastActivityTime

func (storage *Storage) UpdateInstanceLastActivityTime(instanceID string) error

UpdateInstanceLastActivityTime updates the instance's last activity time

Jump to

Keyboard shortcuts

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