core

package
v0.0.0-...-44808bf Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2020 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Overview

Package core implements the runtime state machine.

Index

Constants

This section is empty.

Variables

View Source
var ErrConfigure error = errors.New("can not Configure in this state")
View Source
var ErrHalt error = errors.New("can not Halt in this state")
View Source
var ErrInit error = errors.New("can not Init in this state")
View Source
var ErrMemLock error = errors.New("mem lock failed")
View Source
var ErrRun error = errors.New("can not Run in this state")
View Source
var ErrStart error = errors.New("can not Start in this state")
View Source
var ErrStop error = errors.New("can not Stop in this state")

Functions

func StateName

func StateName(sid StateID) string

Types

type Core

type Core struct {
	// contains filtered or unexported fields
}

func New

func New(m *Mem) *Core

func (*Core) Abort

func (k *Core) Abort() error

func (Core) Config

func (k Core) Config() *config.Config

func (Core) ConfigFlags

func (k Core) ConfigFlags() *config.Flags

func (*Core) Configure

func (k *Core) Configure() error

func (*Core) Context

func (k *Core) Context() context.Context

func (*Core) Init

func (k *Core) Init(ctx context.Context, cfl *config.Flags, cfg *config.Config) (context.Context, error)

func (*Core) SetState

func (k *Core) SetState(s StateID) error

func (*Core) Start

func (k *Core) Start() error

func (*Core) State

func (k *Core) State() string

func (*Core) StateID

func (k *Core) StateID() StateID

func (*Core) Stop

func (k *Core) Stop() error

func (*Core) String

func (k *Core) String() string

func (*Core) UUID

func (k *Core) UUID() string

func (*Core) WithContext

func (k *Core) WithContext(ctx context.Context) (context.Context, error)

type Flags

type Flags struct {
	// contains filtered or unexported fields
}

Flags holds main flags settings.

func NewFlags

func NewFlags() *Flags

func (*Flags) Parse

func (f *Flags) Parse()

Parse parses the flags that were not set via the flags handler (cmd args usually) and sets them with their respective values from the configuration.

func (*Flags) Set

func (f *Flags) Set(fs *flag.FlagSet)

Set sets the flags to the provided handler.

type Machine

type Machine interface {
	Abort() error
	SetState(StateID) error
	Config() *config.Config
	ConfigFlags() *config.Flags
}

type Mem

type Mem struct {
	Auth    auth.Manager
	Api     api.Server
	Console console.Server
	Master  master.Munbot
	// contains filtered or unexported fields
}

func (*Mem) Lock

func (m *Mem) Lock() error

func (*Mem) Unlock

func (m *Mem) Unlock()

type Runtime

type Runtime interface {
	Context() context.Context
	WithContext(context.Context) (context.Context, error)
	Init(context.Context, *config.Flags, *config.Config) (context.Context, error)
	Configure() error
	Start() error
	Stop() error
}

func NewRuntime

func NewRuntime() Runtime

type SHalt

type SHalt struct {
	// contains filtered or unexported fields
}

func (*SHalt) Configure

func (s *SHalt) Configure() error

func (*SHalt) Halt

func (s *SHalt) Halt() error

func (*SHalt) Init

func (s *SHalt) Init() error

func (*SHalt) Run

func (s *SHalt) Run() error

func (*SHalt) Start

func (s *SHalt) Start() error

func (*SHalt) Stop

func (s *SHalt) Stop() error

type SInit

type SInit struct {
	// contains filtered or unexported fields
}

func (*SInit) Configure

func (s *SInit) Configure() error

func (*SInit) Halt

func (s *SInit) Halt() error

func (*SInit) Init

func (s *SInit) Init() error

func (*SInit) Run

func (s *SInit) Run() error

func (*SInit) Start

func (s *SInit) Start() error

func (*SInit) Stop

func (s *SInit) Stop() error

type SRun

type SRun struct {
	// contains filtered or unexported fields
}

func (*SRun) Configure

func (s *SRun) Configure() error

func (*SRun) Halt

func (s *SRun) Halt() error

func (*SRun) Init

func (s *SRun) Init() error

func (*SRun) Run

func (s *SRun) Run() error

func (*SRun) Start

func (s *SRun) Start() error

func (*SRun) Stop

func (s *SRun) Stop() error

type State

type State interface {
	Init() error
	Configure() error
	Start() error
	Run() error
	Stop() error
	Halt() error
}

type StateID

type StateID int
const (
	Dead StateID = iota
	Init
	Run
	Halt
)

Jump to

Keyboard shortcuts

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