util

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrSendFaied is returned when the request could not be created
	ErrSendFailed = errors.New("sending failed")
	// ErrResponseReadFail is returned when the response to the request could not be read
	ErrResponseReadFail = errors.New("failed to read response")
	// ErrBadResponse is returned when the request did not receive a 2** response
	ErrBadResponse = errors.New("bad response")
)

Functions

func SendMsg

func SendMsg(method, toAddr, msg string, options ...RequestOption) (string, error)

SendMessage creates and send a HTTP Request to the specified addresss

func Term

func Term() chan os.Signal

Term returns a channel which receives a message when there is an interrupt

Types

type Counter

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

Counter is a thread safe monotonic natural number counter

func NewCounter

func NewCounter() *Counter

NewCounter instantiates Counter

func (*Counter) Next

func (id *Counter) Next() int

Next returns the next value

func (*Counter) Reset

func (id *Counter) Reset()

Reset resets the counter to 0

type RequestOption

type RequestOption func(*http.Request)

RequestOption can be used to modify the request that is to be sent

func JsonRequest

func JsonRequest() RequestOption

JsonRequest sets the content type to application/json

Jump to

Keyboard shortcuts

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