config

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package config carrega um arquivo mocksmith.yaml e o converte nas Options do runtime. O config é a base; quem chama (a CLI) sobrepõe com as flags.

Index

Constants

View Source
const DefaultFile = "mocksmith.yaml"

DefaultFile é o nome procurado no diretório atual quando --config não recebe um caminho.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Spec        string              `yaml:"spec"`
	Addr        string              `yaml:"addr"`
	Profile     string              `yaml:"profile"`
	ForceStatus int                 `yaml:"forceStatus"`
	Endpoints   map[string]Endpoint `yaml:"endpoints"`
	Overrides   map[string]Override `yaml:"overrides"`
}

Config é a forma declarativa do mocksmith.yaml.

func Load

func Load(path string) (*Config, error)

Load lê e faz o parse do arquivo de config no caminho informado.

func (*Config) ToOptions

func (c *Config) ToOptions() app.Options

ToOptions converte o config nas Options do runtime, traduzindo os blocos por endpoint nas listas "path=valor" que o app já entende. Os endpoints são percorridos em ordem estável.

type Endpoint

type Endpoint struct {
	Fail     int    `yaml:"fail"`
	Slow     string `yaml:"slow"`
	Timeout  string `yaml:"timeout"`
	Corrupt  string `yaml:"corrupt"`
	Sequence []int  `yaml:"sequence"`
}

Endpoint reúne os comportamentos por endpoint declarados no config.

type Override

type Override struct {
	Status    int     `yaml:"status"`
	LatencyMs int     `yaml:"latencyMs"`
	Rate      float64 `yaml:"rate"`
}

Override é o estado inicial de runtime de um endpoint (Admin API).

Jump to

Keyboard shortcuts

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