configuration

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	RegPortValue       = regexp.MustCompile(`^listen\s*(\d+)\s*\S*$`)
	RegServerNameValue = regexp.MustCompile(`^server_name\s*(.+)$`)
)

Functions

func HttpPorts

func HttpPorts(q Querier) []int

func HttpServers

func HttpServers(q Querier) (int, map[string][]int)

func Port

func Port(q Querier) int

func Ports

func Ports(qs []Querier) []int

func StreamServers

func StreamServers(q Querier) (int, []int)

Types

type ConfigManager

type ConfigManager interface {
	Start() error
	Stop() error
	GetConfiguration() Configuration

	GetServerInfo() *v1.WebServerInfo
	// contains filtered or unexported methods
}

func NewNginxConfigurationManager

func NewNginxConfigurationManager(
	loader loader.Loader,
	configuration Configuration,
	serverBinPath, backupDir string,
	backupCycle, backupSaveTime int,
	rwLocker *sync.RWMutex,
) ConfigManager

type Configuration

type Configuration interface {
	Querier
	// insert
	InsertByKeyword(insertParser parser.Parser, keyword string) error
	InsertByQueryer(insertParser parser.Parser, queryer Querier) error
	// InsertByIndex(insertParser parser.Parser, targetContext parser.Context, index int) error
	// remove
	RemoveByKeyword(keyword string) error
	RemoveByQueryer(queryer Querier) error
	// RemoveByIndex(targetContext parser.Context, index int) error
	// modify
	ModifyByKeyword(modifyParser parser.Parser, keyword string) error
	ModifyByQueryer(modifyParser parser.Parser, queryer Querier) error
	// ModifyByIndex(modifyParser parser.Parser, targetContext parser.Context, index int) error
	// update all
	UpdateFromJsonBytes(data []byte) error

	// view
	View() []byte
	Json() []byte
	Dump() map[string][]byte
	// contains filtered or unexported methods
}

keyword string: <parser type>[':sep: <value string>', ':sep: :reg: <value regexp>']

e.g. for Nginx Config keyword string:

  1. server
  2. location:sep: :reg: \^\~\s+\/
  3. key:sep: server_name test1\.com
  4. comment:sep: :reg: .*

func NewConfiguration

func NewConfiguration(
	config *parser.Config,
	preventer loop_preventer.LoopPreventer,
	rwLocker *sync.RWMutex,
) Configuration

func NewConfigurationFromJsonBytes

func NewConfigurationFromJsonBytes(data []byte) (Configuration, error)

func NewConfigurationFromPath

func NewConfigurationFromPath(filePath string) (Configuration, error)

type HttpInfo

type HttpInfo struct {
	ServerCount     int
	ServerPortCount map[string][]int
	PortCount       []int
}

type Querier

type Querier interface {
	// keyword string: <parser type>[':sep: <value string>', ':sep: :reg: <value regexp>']
	//
	// e.g. for Nginx Config keyword string:
	//     1) server
	//     2) location:sep: :reg: \^\~\s+\/
	//     3) key:sep: server_name test1\.com
	//     4) comment:sep: :reg: .*
	Query(keyword string) (Querier, error)
	// keyword string: <parser type>[':sep: <value string>', ':sep: :reg: <value regexp>']
	//
	// e.g. for Nginx Config keyword string:
	//     1) server
	//     2) location:sep: :reg: \^\~\s+\/
	//     3) key:sep: server_name test1\.com
	//     4) comment:sep: :reg: .*
	QueryAll(keyword string) ([]Querier, error)
	Self() parser.Parser
	// contains filtered or unexported methods
}

keyword string: <parser type>[':sep: <value string>', ':sep: :reg: <value regexp>']

e.g. for Nginx Config keyword string:

  1. server
  2. location:sep: :reg: \^\~\s+\/
  3. key:sep: server_name test1\.com
  4. comment:sep: :reg: .*

func NewQuerier

func NewQuerier(fatherContext parser.Context, selfIndex int) (Querier, error)

type Statistician

type Statistician interface {
	HttpInfo() HttpInfo
	StreamInfo() StreamInfo
	Statistics() *v1.Statistics
}

func NewStatistician

func NewStatistician(c Configuration) Statistician

type StreamInfo

type StreamInfo struct {
	ServerCount int
	PortCount   []int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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