lib

package
v0.0.0-...-9893e25 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

SPDX-License-Identifier: MIT

SPDX-License-Identifier: MIT

SPDX-License-Identifier: MIT

SPDX-License-Identifier: MIT

Index

Constants

View Source
const (
	UnInitialized = 0
	Success       = 1
	Error         = 2
)

Variables

View Source
var (
	ErrRange = errors.New("port out of range")
)

Functions

func GetPortFromFile

func GetPortFromFile(file string) (uint16, error)

WAtch portFile and reparse it when due

func Info

func Info(info string)

func ParsePort

func ParsePort(fileContent []byte) (uint16, error)

func PortChangeNotifier

func PortChangeNotifier(portFile string, throttleTimeMs uint) (chan uint16, chan struct{}, error)

func PrintError

func PrintError(err error)

func PrintRequester

func PrintRequester() (chan StatusUpdate, chan struct{})

Channel will be closed by requester :/

func PrintStepError

func PrintStepError(err error)

Types

type Configuration

type Configuration struct {
	Once       bool
	ForceColor bool                    `mapstructure:"force-color"`
	Config     string                  `mapstructure:"config"`
	PortFile   string                  `mapstructure:"port-file" validate:"required,filepath"`
	Requests   map[string]RequestGroup `mapstructure:"requests" validate:"gt=0,dive,required"`
}

type Credentials

type Credentials struct {
	Username string `mapstructure:"username"`
	Password string `mapstructure:"password"`
}

type Request

type Request struct {
	Method      string `mapstructure:"method" validate:"omitempty,oneof=GET POST PUT DELETE OPTION"`
	Url         string `mapstructure:"url" validate:"required,http_url"`
	ContentType string `mapstructure:"content-type" validate:"required_with=ContentType"`
	Payload     string `mapstructure:"payload" validate:"required_with=ContentType"`
}

type RequestGroup

type RequestGroup struct {
	Credentials Credentials `mapstructure:"credentials"`
	Requests    []Request   `mapstructure:"requests" validate:"required,dive"`
}

type Requester

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

func NewRequester

func NewRequester() Requester

func NewRequesterWithClient

func NewRequesterWithClient(client *http.Client) Requester

func (*Requester) SendRequests

func (r *Requester) SendRequests(port uint16, requests map[string]RequestGroup, updateChan chan StatusUpdate) error

type RequesterError

type RequesterError struct {
	Errors []error
}

func (*RequesterError) Error

func (m *RequesterError) Error() string

type StatusUpdate

type StatusUpdate struct {
	Service string
	Method  string
	Path    string
	Status  int
	Step    int
	Error   error
}

Jump to

Keyboard shortcuts

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