config

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteHostConfig

func DeleteHostConfig(host string) error

func GetVersion

func GetVersion() string

func SetHostConfig

func SetHostConfig(host string, newConfig HostConfig) error

Types

type AppConfig

type AppConfig 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"`
	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"`
}

func GetAppConfig

func GetAppConfig() (*AppConfig, error)

func Init

func Init() (*AppConfig, error)

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 DeleteHostErrorConfig

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

func DeleteHostLatencyConfig

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

func GetHostConfig

func GetHostConfig(host string) (*HostConfig, error)

func UpdateHostErrorsConfig

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

func UpdateHostLatencyConfig

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

func UpdateHostUrisConfig

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

func (HostConfig) Validate

func (h HostConfig) Validate() error

type HostsConfig

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

func GetHostsConfig

func GetHostsConfig() (*HostsConfig, 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) 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 GetMockDirectoryConfig

func GetMockDirectoryConfig() (*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