config

package module
v0.0.0-...-c2cae38 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2023 License: MIT Imports: 13 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	ProgramGroup *ProcessGroup
	// contains filtered or unexported fields
}

Config memory representation of supervisor configuration file

func NewConfig

func NewConfig(configFile string) *Config

NewConfig creates Config object

func (*Config) GetConfigFileDir

func (c *Config) GetConfigFileDir() string

GetConfigFileDir returns directory of supervisord configuration file

func (*Config) GetEntries

func (c *Config) GetEntries(filterFunc func(entry *Entry) bool) []*Entry

GetEntries returns configuration entries by filter

func (*Config) GetEventListeners

func (c *Config) GetEventListeners() []*Entry

GetEventListeners returns configuration entries of event listeners

func (*Config) GetGroups

func (c *Config) GetGroups() []*Entry

GetGroups returns configuration entries of all program groups

func (*Config) GetInetHTTPServer

func (c *Config) GetInetHTTPServer() (*Entry, bool)

GetInetHTTPServer returns inet_http_server configuration section

func (*Config) GetProgram

func (c *Config) GetProgram(name string) *Entry

GetProgram returns the program configuration entry or nil

func (*Config) GetProgramNames

func (c *Config) GetProgramNames() []string

GetProgramNames returns slice with all program names

func (*Config) GetPrograms

func (c *Config) GetPrograms() []*Entry

GetPrograms returns configuration entries of all programs

func (*Config) GetSupervisorctl

func (c *Config) GetSupervisorctl() (*Entry, bool)

GetSupervisorctl returns "supervisorctl" configuration section

func (*Config) GetSupervisord

func (c *Config) GetSupervisord() (*Entry, bool)

GetSupervisord returns "supervisord" configuration section

func (*Config) GetUnixHTTPServer

func (c *Config) GetUnixHTTPServer() (*Entry, bool)

GetUnixHTTPServer returns unix_http_server configuration section

func (*Config) Load

func (c *Config) Load() ([]string, error)

Load the configuration and return loaded programs

func (*Config) RemoveProgram

func (c *Config) RemoveProgram(programName string)

RemoveProgram removes program entry by its name

func (*Config) String

func (c *Config) String() string

String converts configuration to the string

type Entry

type Entry struct {
	ConfigDir string
	Group     string
	Name      string
	// contains filtered or unexported fields
}

Entry standards for a configuration section in supervisor configuration file

func NewEntry

func NewEntry(configDir string) *Entry

NewEntry creates configuration entry

func (*Entry) GetBool

func (c *Entry) GetBool(key string, defValue bool) bool

GetBool gets value of key as bool

func (*Entry) GetBytes

func (c *Entry) GetBytes(key string, defValue int) int

GetBytes returns value of the key as bytes setting.

logSize=1MB
logSize=1GB
logSize=1KB
logSize=1024

func (*Entry) GetEnv

func (c *Entry) GetEnv(key string) []string

GetEnv returns slice of strings with keys separated from values by single "=". An environment string example:

environment = A="env 1",B="this is a test"

func (*Entry) GetEnvFromFiles

func (c *Entry) GetEnvFromFiles(key string) []string

GetEnvFromFiles returns slice of strings with keys separated from values by single "=". An envFile example:

envFiles = global.env,prod.env

cat global.env varA=valueA

func (*Entry) GetEventListenerName

func (c *Entry) GetEventListenerName() string

GetEventListenerName returns event listener name

func (*Entry) GetGroupName

func (c *Entry) GetGroupName() string

GetGroupName returns group name if entry is a group

func (*Entry) GetInt

func (c *Entry) GetInt(key string, defValue int) int

GetInt gets value of the key as int

func (*Entry) GetProgramName

func (c *Entry) GetProgramName() string

GetProgramName returns program name

func (*Entry) GetPrograms

func (c *Entry) GetPrograms() []string

GetPrograms returns slice with programs from the group

func (*Entry) GetString

func (c *Entry) GetString(key string, defValue string) string

GetString returns value of the key as a string

func (*Entry) GetStringArray

func (c *Entry) GetStringArray(key string, sep string) []string

GetStringArray gets string value and split it with "sep" to slice

func (*Entry) GetStringExpression

func (c *Entry) GetStringExpression(key string, defValue string) string

GetStringExpression returns value of key as a string and attempts to parse it with StringExpression

func (*Entry) HasParameter

func (c *Entry) HasParameter(key string) bool

HasParameter checks if key (parameter) has value

func (*Entry) IsEventListener

func (c *Entry) IsEventListener() bool

IsEventListener returns true if this section is for event listener

func (*Entry) IsGroup

func (c *Entry) IsGroup() bool

IsGroup returns true if it is group section

func (*Entry) IsProgram

func (c *Entry) IsProgram() bool

IsProgram returns true if this is a program section

func (*Entry) String

func (c *Entry) String() string

String dumps configuration as a string

type ProcessGroup

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

ProcessGroup manage the program and its group mapping

func NewProcessGroup

func NewProcessGroup() *ProcessGroup

NewProcessGroup create a ProcessGroup object

func (*ProcessGroup) Add

func (pg *ProcessGroup) Add(group string, procName string)

Add adds process to a group

func (*ProcessGroup) Clone

func (pg *ProcessGroup) Clone() *ProcessGroup

Clone clones process group

func (*ProcessGroup) ForEachProcess

func (pg *ProcessGroup) ForEachProcess(procFunc func(group string, procName string))

ForEachProcess iterates all the processes and process it with procFunc

func (*ProcessGroup) GetAllGroup

func (pg *ProcessGroup) GetAllGroup() []string

GetAllGroup gets all the process groups

func (*ProcessGroup) GetAllProcess

func (pg *ProcessGroup) GetAllProcess(group string) []string

GetAllProcess gets all the processes in a group

func (*ProcessGroup) GetGroup

func (pg *ProcessGroup) GetGroup(procName string, defGroup string) string

GetGroup gets group name of process. If group was not found by procName, set its group to defGroup and return this defGroup

func (*ProcessGroup) InGroup

func (pg *ProcessGroup) InGroup(procName string, group string) bool

InGroup checks if process belongs to a group or not

func (*ProcessGroup) Remove

func (pg *ProcessGroup) Remove(procName string)

Remove removes a process from a group

func (*ProcessGroup) String

func (pg *ProcessGroup) String() string

String converts process and its group mapping to human-readable string

func (*ProcessGroup) Sub

func (pg *ProcessGroup) Sub(other *ProcessGroup) (added []string, changed []string, removed []string)

Sub removes all the programs listed in other ProcessGroup from this ProcessGroup

type ProcessSorter

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

ProcessSorter sort the program by its priority

func NewProcessSorter

func NewProcessSorter() *ProcessSorter

NewProcessSorter creates sorter

func (*ProcessSorter) SortProgram

func (p *ProcessSorter) SortProgram(programConfigs []*Entry) []*Entry

SortProgram sort the program and return the result

type ProgramByPriority

type ProgramByPriority []*Entry

ProgramByPriority sort program by its priority

func (ProgramByPriority) Len

func (p ProgramByPriority) Len() int

Len returns amount of programs

func (ProgramByPriority) Less

func (p ProgramByPriority) Less(i, j int) bool

Less returns true if the priority i-th program is less than the priority of j-th program

func (ProgramByPriority) Swap

func (p ProgramByPriority) Swap(i, j int)

Swap swaps program i and program j

type StringExpression

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

StringExpression replace the python String like "%(var)s" to string

func NewStringExpression

func NewStringExpression(envs ...string) *StringExpression

NewStringExpression create a new StringExpression with the environment variables

func (*StringExpression) Add

func (se *StringExpression) Add(key string, value string) *StringExpression

Add adds environment variable (key,value)

func (*StringExpression) Eval

func (se *StringExpression) Eval(s string) (string, error)

Eval substitutes "%(var)s" in given string with evaluated values, and returns resulting string

Jump to

Keyboard shortcuts

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