config

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetVersion

func GetVersion() string

func InitLogger added in v1.2.0

func InitLogger()

Types

type AppArguments added in v1.2.0

type AppArguments struct {
	MocksDirectory     string `arg:"required,--mocks-directory" help:"path to the mocks directory"`
	MocksConfigFile    string `arg:"--mocks-config-file" help:"path to the config file"`
	DefaultContentType string `` /* 130-byte string literal not displayed */
	ServerPort         int    `default:"8080" arg:"-P,--port" help:"port to be used"`
	DisableCache       bool   `arg:"--disable-cache" help:"disable the caching"`
	DisableLatency     bool   `arg:"--disable-latency" help:"disable latency simulation"`
	DisableError       bool   `arg:"--disable-error" help:"disable error simulation"`
	DisableCors        bool   `arg:"--disable-cors" help:"disable CORS headers"`
}

func ParseAppArguments added in v1.2.0

func ParseAppArguments() *AppArguments

type ErrorConfig

type ErrorConfig struct {
	Percentage    *int           `json:"percentage"`
	LatencyConfig *LatencyConfig `json:"latency"`
}

type HostConfig

type HostConfig struct {
	LatencyConfig *LatencyConfig         `json:"latency"`
	ErrorsConfig  map[string]ErrorConfig `json:"errors"`
	UrisConfig    map[string]UriConfig   `json:"uris"`
}

func (*HostConfig) Validate

func (h *HostConfig) Validate() error

type HostsConfig

type HostsConfig struct {
	Hosts map[string]HostConfig `json:"hosts"`
}

func NewHostsConfig added in v1.2.0

func NewHostsConfig(appArguments *AppArguments) (*HostsConfig, error)

func (*HostsConfig) DeleteHostConfig added in v1.2.0

func (h *HostsConfig) DeleteHostConfig(host string)

func (*HostsConfig) DeleteHostErrorConfig added in v1.2.0

func (h *HostsConfig) DeleteHostErrorConfig(host, errorCode string) (*HostConfig, error)

func (*HostsConfig) DeleteHostLatencyConfig added in v1.2.0

func (h *HostsConfig) DeleteHostLatencyConfig(host string) (*HostConfig, error)

func (*HostsConfig) GetAppropriateErrorsConfig

func (h *HostsConfig) GetAppropriateErrorsConfig(host, uri string) *map[string]ErrorConfig

func (*HostsConfig) GetAppropriateLatencyConfig

func (h *HostsConfig) GetAppropriateLatencyConfig(host, uri string) *LatencyConfig

func (*HostsConfig) GetHostConfig added in v1.2.0

func (h *HostsConfig) GetHostConfig(host string) *HostConfig

func (*HostsConfig) SetHostConfig added in v1.2.0

func (h *HostsConfig) SetHostConfig(host string, newConfig HostConfig)

func (*HostsConfig) UpdateHostErrorsConfig added in v1.2.0

func (h *HostsConfig) UpdateHostErrorsConfig(host string, errorsConfig map[string]ErrorConfig) (*HostConfig, error)

func (*HostsConfig) UpdateHostLatencyConfig added in v1.2.0

func (h *HostsConfig) UpdateHostLatencyConfig(host string, latencyConfig *LatencyConfig) (*HostConfig, error)

func (*HostsConfig) UpdateHostUrisConfig added in v1.2.0

func (h *HostsConfig) UpdateHostUrisConfig(host string, urisConfig map[string]UriConfig) (*HostConfig, error)

func (*HostsConfig) Validate

func (h *HostsConfig) Validate() error

type LatencyConfig

type LatencyConfig struct {
	Min *int `json:"min"`
	P95 *int `json:"p95"`
	P99 *int `json:"p99"`
	Max *int `json:"max"`
}

type MocksDirectoryConfig

type MocksDirectoryConfig struct {
	Path string
}

func NewMocksDirectoryConfig added in v1.2.0

func NewMocksDirectoryConfig(appArguments *AppArguments) (*MocksDirectoryConfig, error)

type UriConfig

type UriConfig struct {
	LatencyConfig *LatencyConfig         `json:"latency"`
	ErrorsConfig  map[string]ErrorConfig `json:"errors"`
}

Jump to

Keyboard shortcuts

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