config

package
v3.1.3 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrFilePathIsNotUnderConfigPath = errors.New("File path is not under config path")
View Source
var ErrInvalidMockDefinition = errors.New("Invalid mock config")

ErrInvalidMockDefinition the file contains an invalid mock config

View Source
var ErrMockDoesntExist = errors.New("Definition doesn't exist")
View Source
var ErrNotValidParserFound = errors.New("Not valid config reader found")

ErrNotValidParserFound we don't have any config reader valid for this file

Functions

This section is empty.

Types

type ConfigMapping

type ConfigMapping struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewConfigMapping

func NewConfigMapping(path string, mapper *FSMapper, fsUpdate chan struct{}) *ConfigMapping

func (*ConfigMapping) Delete

func (fm *ConfigMapping) Delete(URI string) error

func (*ConfigMapping) Get

func (fm *ConfigMapping) Get(URI string) (mock.Definition, bool)

func (*ConfigMapping) List

func (fm *ConfigMapping) List() []mock.Definition

func (*ConfigMapping) Set

func (fm *ConfigMapping) Set(URI string, mock mock.Definition) error

type FSMapper

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

FSMapper this struct contains the path of config and some config readers

func NewFileSystemMapper

func NewFileSystemMapper() *FSMapper

NewFileSystemMapper file config constructor

func (*FSMapper) AddParser

func (fd *FSMapper) AddParser(reader Parser)

AddParser allows append new readers to able load different config files

func (*FSMapper) Read

func (fd *FSMapper) Read(filename string) (mock.Definition, error)

func (*FSMapper) Write

func (fd *FSMapper) Write(filename string, mock mock.Definition) error

type FileWatcher

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

func NewFileWatcher

func NewFileWatcher(path string, fsUpdate chan struct{}) *FileWatcher

func (*FileWatcher) Bind

func (fw *FileWatcher) Bind()

Bind start the watching process to detect any change on defintions

func (*FileWatcher) UnBind

func (fw *FileWatcher) UnBind()

type Mapping

type Mapping interface {
	Set(URI string, mock mock.Definition) error
	Delete(URI string) error
	Get(URI string) (mock.Definition, bool)
	List() []mock.Definition
}

type Parser

type Parser interface {
	CanParse(filename string) bool
	Parse(content []byte) (mock.Definition, error)
}

Parser interface allows recognize if there is available some config reader for an a specific file.

type PrioritySort

type PrioritySort []mock.Definition

PrioritySort mock array sorted by priority

func (PrioritySort) Len

func (s PrioritySort) Len() int

func (PrioritySort) Less

func (s PrioritySort) Less(i, j int) bool

func (PrioritySort) Swap

func (s PrioritySort) Swap(i, j int)

type Reader

type Reader interface {
	Read(string) (mock.Definition, error)
}

Reader interface contains the funtions to obtain the mock defintions.

type Watcher

type Watcher interface {
	Bind()
	UnBind()
}

Watcher interface contains the function watching process

type Writer

type Writer interface {
	Write(string, mock.Definition) error
}

Writer interface contains the function persist mock definitions.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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