pawnd

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2024 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MsgInit = "init"      // Start everything
	MsgTerm = "terminate" // Stop all processing
	MsgRest = "restart"   // Restart
	MsgTrig = "trigger"   // Make action happen
	MsgWait = "wait"      // Reset status to wait

	ToAll            = "*"
	ErrMainRestarted = fmt.Errorf("main restarted")
)

Common messages

View Source
var SupportedSignals = map[string]os.Signal{
	"sigusr1": syscall.SIGUSR1,
	"sigusr2": syscall.SIGUSR2,
}

Functions

func ActionName

func ActionName(name string) string

func CheckCronSpec added in v0.9.1

func CheckCronSpec(spec string) error

func CheckShScript added in v0.9.3

func CheckShScript(script string, section string) error

func CheckSignal added in v0.9.2

func CheckSignal(name string) error

func Cli

func Cli(opts appkit.Options, argsin []string) ([]string, error)

func CreateActions

func CreateActions(file *ini.File, bus *EventBus) error

func ErrAnnotate added in v0.10.0

func ErrAnnotate(err error, a ...interface{}) error

func EscapeName added in v0.12.2

func EscapeName(name string) string

func GenerateTemplates

func GenerateTemplates(opts appkit.Options) error

func Main

func Main(opts appkit.Options) error

func PrintGoroutines added in v0.9.3

func PrintGoroutines()

func Templates

func Templates() map[string]string

func UnescapeName added in v0.12.2

func UnescapeName(name string) string

func ValidateConfig

func ValidateConfig(filename string) (*ini.File, error)

Types

type BaseAction

type BaseAction struct {
	Visible bool
	// contains filtered or unexported fields
}

func (*BaseAction) Identify

func (a *BaseAction) Identify(name string, eb *EventBus)

func (*BaseAction) Send

func (a *BaseAction) Send(to, message string)

func (*BaseAction) Terminal

func (a *BaseAction) Terminal() Terminal
type BusLink interface {
	// Receiving messages
	Receive(from, message string)

	// Sending messages
	Send(to, message string)

	// Registering the EventBus to the BusLink
	Identify(name string, bus *EventBus)

	// Start the BusLink specific goroutine
	Run()
}

BusLink is the interface for sending messages to the bus

type CronAction added in v0.9.1

type CronAction struct {
	Triggered []string
	BaseAction
	// contains filtered or unexported fields
}

func NewCronAction added in v0.9.1

func NewCronAction(spec string) (*CronAction, error)

func (*CronAction) Receive added in v0.9.1

func (a *CronAction) Receive(from, message string)

func (*CronAction) Run added in v0.9.1

func (a *CronAction) Run()

type Deps added in v0.9.3

type Deps struct {
	FailSafeExit      func()
	NewTerminalStdout func() io.Writer
	SignalNotify      func(c chan<- os.Signal, sig ...os.Signal)
	SignalReset       func(sig ...os.Signal)
	SupportedSignal   func(name string) (os.Signal, error)
}

type EventBus

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

EventBus conveys messages to Listeners

func NewEventBus

func NewEventBus() *EventBus

func (*EventBus) Close added in v0.12.0

func (eb *EventBus) Close() error

func (*EventBus) LinkStopped added in v0.9.1

func (eb *EventBus) LinkStopped(name string)

Action notifies that it has stopped. This is for waiting for all actions when terminating.

func (*EventBus) Register

func (eb *EventBus) Register(name string, link BusLink)

Register a node with given name

func (*EventBus) Run

func (eb *EventBus) Run() error

Run until terminated

func (*EventBus) Send

func (eb *EventBus) Send(from, to, message string)

type FileAction

type FileAction struct {
	Patterns   []string
	Hysteresis time.Duration

	Changed []string

	BaseAction
	// contains filtered or unexported fields
}

func NewFileAction

func NewFileAction(patterns ...string) (*FileAction, error)

func (*FileAction) Receive

func (a *FileAction) Receive(from, message string)

func (*FileAction) Run added in v0.9.1

func (a *FileAction) Run()

type InitAction

type InitAction struct {
	BaseAction
	// contains filtered or unexported fields
}

func NewInitAction

func NewInitAction(triggerName string) *InitAction

func (*InitAction) Receive

func (a *InitAction) Receive(from, message string)

func (*InitAction) Run added in v0.9.1

func (a *InitAction) Run()

type Message

type Message struct {
	From     string
	To       string
	Contents string
}

type PrefixedWriter

type PrefixedWriter struct {
	Prefix    []byte    // Prefix to add to each line
	Eol       []byte    // Suffix to add each line
	Out       io.Writer // Write everything to this writer.
	TimeStamp bool      // Add timestamps to output
	// contains filtered or unexported fields
}

PrefixedWriter is an io.Writer that prefixes and suffixes all lines given to it.

func NewPrefixedWriter

func NewPrefixedWriter(prefix string, out io.Writer) *PrefixedWriter

NewPrefixedWriter create a PrefixedWriter with given prefix and write everything to out.

func (*PrefixedWriter) Write

func (p *PrefixedWriter) Write(buf []byte) (n int, err error)

Write writes given buf with a prefix to the Out writer. Only write lines ending with a newline. If the input data doesn't contain a newline, the data is written to an internal buffer which is flushed the next time data with newline is given.

type RestartAction added in v0.9.3

type RestartAction struct {
	BaseAction
	// contains filtered or unexported fields
}

func NewRestartAction added in v0.9.3

func NewRestartAction(conffile string) *RestartAction

func (*RestartAction) Receive added in v0.9.3

func (a *RestartAction) Receive(from, message string)

func (*RestartAction) Run added in v0.9.3

func (a *RestartAction) Run()

type ShAction added in v0.9.3

type ShAction struct {
	Cooldown  time.Duration
	Timeout   time.Duration
	Daemon    bool
	OnChange  bool
	Succeeded []string
	Failed    []string

	BaseAction
	// contains filtered or unexported fields
}

func NewShAction added in v0.9.3

func NewShAction(script string) (*ShAction, error)

func (*ShAction) Cancel added in v0.9.4

func (a *ShAction) Cancel()

func (*ShAction) Receive added in v0.9.3

func (a *ShAction) Receive(from, message string)

func (*ShAction) Run added in v0.9.3

func (a *ShAction) Run()

func (*ShAction) RunCommand added in v0.9.3

func (a *ShAction) RunCommand() error

type SignalAction

type SignalAction struct {
	Triggered []string

	// If this signal should terminate the program
	Terminator bool

	BaseAction
	// contains filtered or unexported fields
}

func NewSignalAction

func NewSignalAction(signame string) (*SignalAction, error)

func (*SignalAction) Receive

func (a *SignalAction) Receive(from, message string)

func (*SignalAction) Run added in v0.9.1

func (a *SignalAction) Run()

type Terminal

type Terminal interface {
	Stderr() io.Writer
	Stdout() io.Writer
	Verbose() io.Writer
	SetStatus(status string, info string)
}

Terminal is the interface for outputting data to a terminal

func GetTerminal

func GetTerminal(name string) Terminal

func RegisterTerminal

func RegisterTerminal(name string, visible bool) Terminal

RegisterTerminal registers an interface to outputting

type TerminalOutput

type TerminalOutput struct {
	Width       int
	Verbose     bool
	TitleStatus string
	ProgTitle   string
	// contains filtered or unexported fields
}

func NewTerminalOutput

func NewTerminalOutput(opts appkit.Options) *TerminalOutput

func (*TerminalOutput) Ready added in v0.13.0

func (a *TerminalOutput) Ready() bool

func (*TerminalOutput) Register added in v0.13.0

func (a *TerminalOutput) Register(t *terminal)

Register a new Terminal to the TerminalOutput

func (*TerminalOutput) Stop

func (a *TerminalOutput) Stop()

Stop TerminalOutput. This cannot be stopped with the MsgTerm message as some other actions can print while they are terminating.

type VerboseWriter

type VerboseWriter struct {
	Out     io.Writer
	Verbose bool
}

VerboseWriter writes to Out only if Verbose is set.

func (*VerboseWriter) Write

func (w *VerboseWriter) Write(buf []byte) (int, error)

Jump to

Keyboard shortcuts

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