runner

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RunChan chan RunChanStruct

RunChan trigger to function.

Functions

func RunTrigger

func RunTrigger(ctx context.Context, wg *sync.WaitGroup)

Types

type Command

type Command struct {
	TriggerFn func(context.Context) error

	Name   string
	Path   string
	Env    []string
	Filter func([]byte) bool

	Command  []string
	ExitCode int
	// contains filtered or unexported fields
}

func (*Command) Kill

func (c *Command) Kill()

Kill the kill command.

func (*Command) Restart

func (c *Command) Restart(runInit bool) error

Restart is kill command after that run again that command.

func (*Command) Run

func (c *Command) Run(runTrigger bool) error

func (*Command) SetContext

func (c *Command) SetContext(ctx context.Context, ctxCancel context.CancelFunc)

SetContext for killing command.

func (*Command) SetRegistry

func (c *Command) SetRegistry(registry *StoreReg)

SetRegistry to reach command to registry struct.

func (*Command) SetWaitGroup

func (c *Command) SetWaitGroup(wg *sync.WaitGroup)

SetWaitGroup is for shutdown service gracefully.

type RunChanStruct

type RunChanStruct struct {
	Name string
	Init bool
}

type StoreReg

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

StoreReg hold commands.

var GlobalReg *StoreReg

GlobalReg using in server requests. Don't forget to run KillAll before exit the program.

func NewStoreReg

func NewStoreReg(ctx context.Context, wg *sync.WaitGroup) *StoreReg

func (*StoreReg) Add

func (s *StoreReg) Add(command *Command) *StoreReg

func (*StoreReg) Del

func (s *StoreReg) Del(name string) *StoreReg

func (*StoreReg) Get

func (s *StoreReg) Get(name string) *Command

func (*StoreReg) IsExitCodeZero

func (s *StoreReg) IsExitCodeZero() bool

func (*StoreReg) KillAll

func (s *StoreReg) KillAll()

func (*StoreReg) RunAll

func (s *StoreReg) RunAll() error

func (*StoreReg) SetAsGlobal

func (s *StoreReg) SetAsGlobal() *StoreReg

Jump to

Keyboard shortcuts

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