storage

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Module = fx.Module(
	"storage",
	fx.Provide(func() Storage {
		return NewStorageService(
			&yamlStorage{
				Path: os.Getenv("CONFIG_PATH"),
			},
		)
	}),
)

Functions

This section is empty.

Types

type HTTPGet

type HTTPGet struct {
	TCPSocket   `yaml:",inline"`
	Scheme      string      `yaml:"scheme"`
	Path        string      `yaml:"path"`
	HTTPHeaders HTTPHeaders `yaml:"httpHeaders"`
}

func (*HTTPGet) Validate

func (s *HTTPGet) Validate() error

type HTTPHeader

type HTTPHeader struct {
	Name  string `yaml:"name" validate:"required"`
	Value string `yaml:"value" validate:"required"`
}

type HTTPHeaders

type HTTPHeaders []HTTPHeader

type Service

type Service struct {
	Id                  string    `yaml:"id" validate:"required"`
	Name                string    `yaml:"name" validate:"required"`
	InitialDelaySeconds int32     `yaml:"initialDelaySeconds"`              // пауза перед первым опросом в секундах, по умолчанию: 0; если меньше 0, то используется случайное значение между 0 и `periodSeconds`
	PeriodSeconds       uint16    `yaml:"periodSeconds" validate:"gt=0"`    // период опроса в секундах, по умолчанию: 10
	TimeoutSeconds      uint16    `yaml:"timeoutSeconds" validate:"gt=0"`   // время ожидания ответа в секундах, по кмолчанию: 1
	SuccessThreshold    uint8     `yaml:"successThreshold" validate:"gt=0"` // количество последовательных успешных соединений для перехода в состояние "в сети", по умолчанию: 1
	FailureThreshold    uint8     `yaml:"failureThreshold" validate:"gt=0"` // количество последовательных ошибок соединения для перехода в состояние "не в сети", по умолчанию: 3
	HTTPGet             HTTPGet   `yaml:"httpGet,omitempty" validate:"required_without=TCPSocket"`
	TCPSocket           TCPSocket `yaml:"tcpSocket,omitempty" validate:"required_without=HTTPGet"`
}

func (*Service) Validate

func (s *Service) Validate() error

type Storage

type Storage interface {
	Load() ([]Service, error)
}

type StorageService

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

func NewStorageService

func NewStorageService(storage Storage) *StorageService

func (*StorageService) Load

func (s *StorageService) Load() ([]Service, error)

type TCPSocket

type TCPSocket struct {
	Host string `yaml:"host" validate:"required,hostname"`
	Port uint16 `yaml:"port"`
}

func (TCPSocket) IsEmpty

func (s TCPSocket) IsEmpty() bool

func (*TCPSocket) Validate

func (s *TCPSocket) Validate() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳