engine

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Copyright       = fmt.Sprintf("Copyright (c) 2021-%d QuantStop.com", time.Now().Year())
	PrereleaseBlurb = "This version is pre-release and is not intended to be used as a production ready system - use at your own risk."
	GitHub          = "GitHub: https://github.com/QuantStop/QuantStopTerminal"
	Issues          = "Issues: https://github.com/QuantStop/QuantStopTerminal/issues"
)

Functions

This section is empty.

Types

type Engine

type Engine struct {
	*Version        // The engine version information
	*config.Config  // Config for engine, and all services
	*ServiceManager // Registry of all services
}

func NewEngine

func NewEngine(version, commit, date string) (*Engine, error)

NewEngine creates a new engine, and all services

func (*Engine) Restart

func (bot *Engine) Restart() error

Restart the engine. Try's to restart the application.

func (*Engine) Start

func (bot *Engine) Start() error

Start the engine. Starts the application and all services.

func (*Engine) Stop

func (bot *Engine) Stop() error

Stop the engine. Stops all services and exits the application.

func (*Engine) WaitForInterrupt

func (bot *Engine) WaitForInterrupt() error

WaitForInterrupt is a blocking routine that returns when an operating system interrupt signal is received.

type ServiceManager

type ServiceManager struct {

	// service wait group
	ServiceWG *sync.WaitGroup
	// contains filtered or unexported fields
}

ServiceManager provides a useful pattern for managing services. It allows for ease of dependency management and ensures services dependent on others use the same references in memory.

func NewServiceManager

func NewServiceManager(bot *Engine) (*ServiceManager, error)

NewServiceManager creates a new instance of the ServiceManager struct, then creates and registers all services.

func (*ServiceManager) FetchService

func (s *ServiceManager) FetchService(service interface{}) error

FetchService takes in a struct pointer and sets the value of that pointer to a service currently stored in the service registry. This ensures the input argument is set to the right pointer that refers to the originally registered service.

func (*ServiceManager) GetService added in v0.3.0

func (s *ServiceManager) GetService(name string) bool

func (*ServiceManager) SetService added in v0.3.0

func (s *ServiceManager) SetService(name string, status bool) error

SetService allows starting/stopping individual services. Not all services are allowed as some are core features that rely on other services as well. If the service is not found, or the service is not allowed, an error will be returned.

func (*ServiceManager) Start added in v0.3.0

func (s *ServiceManager) Start(name string) error

Start takes in a subsystem name string, and wait group, attempts to find the service by its name, and then start it.

func (*ServiceManager) StartAll

func (s *ServiceManager) StartAll() error

StartAll initialized each service in order of registration.

func (*ServiceManager) Stop added in v0.3.0

func (s *ServiceManager) Stop(name string) error

Stop takes in a subsystem name string and attempts to find the service by its name, and then Stop

func (*ServiceManager) StopAll

func (s *ServiceManager) StopAll()

StopAll ends every service in reverse order of registration, logging a panic if any of them fail to stop.

type Version

type Version struct {
	Version         string
	BuildTime       string
	Commit          string
	Copyright       string
	PrereleaseBlurb string
	GitHub          string
	Issues          string
	IsDaemon        bool
	IsPreRelease    bool
	IsDevMode       bool
}

func CreateDefaultVersion

func CreateDefaultVersion() *Version

func CreateVersion added in v0.3.0

func CreateVersion(version, buildTime, commit string, isDaemon, isPreRelease, isDevMode bool) *Version

func (*Version) GetVersionString

func (version *Version) GetVersionString(short bool) string

GetVersionString returns the version string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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