utils

package
v0.0.0-...-7a34736 Latest Latest
Warning

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

Go to latest
Published: May 22, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Btoi64

func Btoi64(val []byte) int64

Btoi64 converts from []byte to int64

func CopyFile

func CopyFile(src, dst string) error

CopyFile the src file to dst. Any existing file will be overwritten and will not copy file attributes.

func I64tob

func I64tob(val int64) []byte

I64tob converts from int64 to []byte

Types

type Int32IdGen

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

Int32IdGen is a generator of int32 ids

func NewInt32IdGen

func NewInt32IdGen(name string) *Int32IdGen

NewInt32IdGen creates a new U16IDGen

func (*Int32IdGen) NewID

func (id *Int32IdGen) NewID() int32

NewID generates a new 32 bit ID

type NokResponse

type NokResponse struct {
	ResponseBase
}

NokResponse is a default Not OK response with an optional error string.

func (NokResponse) IsOk

func (r NokResponse) IsOk() bool

IsOk is always false for a NokResponse

type OkResponse

type OkResponse struct {
	ResponseBase
}

OkResponse is a default response that says 'the operation went well', or maybe something specified in the message?

func (OkResponse) IsOk

func (r OkResponse) IsOk() bool

IsOk is always true for a OkResponse

type PauseReq

type PauseReq struct {
	RequestBase
}

PauseReq is a request to pause the stream

type Request

type Request interface {
	ResponseChannel() chan Response

	// Some responses are more common than others, provide these in
	// the interface
	Ok(...string)
	Nok(...string)
}

A Request is done to a thread that we expect a synchrounous response to from a Responder.

type RequestBase

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

RequestBase is a base implementation of a Request

func NewRequestBase

func NewRequestBase() RequestBase

NewRequestBase creates a new RequestBase

func (RequestBase) Nok

func (r RequestBase) Nok(msg ...string)

Nok sends an Nok back as the response

func (RequestBase) Ok

func (r RequestBase) Ok(msg ...string)

Ok sends an Ok back as the response

func (RequestBase) ResponseChannel

func (r RequestBase) ResponseChannel() chan Response

ResponseChannel returns the channel on which the response should be sent

type Responder

type Responder interface {
	RequestChannel() chan Request
}

A Responder respondes to requests. The reqChannel is the channel the requests enters on.

type ResponderBase

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

ResponderBase implements a basic Responder

func NewResponderBase

func NewResponderBase() ResponderBase

NewResponderBase creates a new Responder

func (ResponderBase) Request

func (r ResponderBase) Request(req Request, timeout float32) Response

Request is a client routing trying to send a request to the ResponderBase. If there is no response within timeout, then the request is cancelled.

func (ResponderBase) RequestChannel

func (r ResponderBase) RequestChannel() chan Request

RequestChannel returns the channel to send requests on

type Response

type Response interface {
	IsOk() bool
}

Response is sent back from the Responder

type ResponseBase

type ResponseBase struct {
	Message []string
}

ResponseBase can be used as a base response that differs responses between Ok/Nok and that carries a message

type ResumeReq

type ResumeReq struct {
	RequestBase
}

ResumeReq is a request to resume the stream

type StartReq

type StartReq struct {
	RequestBase
}

StartReq is a request to resume the stream

type StopReq

type StopReq struct {
	RequestBase
}

StopReq is a request to stop the runner

type U16IDGen

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

U16IDGen is a generator of uint16 ids

func NewU16IdGen

func NewU16IdGen(name string) *U16IDGen

NewU16IdGen creates a new U16IDGen

func (*U16IDGen) NewID

func (id *U16IDGen) NewID() uint16

NewID generates a new 16 bit ID

type U32IDGen

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

U32IDGen is a generator of uint32 ids

func NewU32IdGen

func NewU32IdGen(name string) *U32IDGen

NewU32IdGen creates a new U16IDGen

func (*U32IDGen) NewID

func (id *U32IDGen) NewID() uint32

NewID generates a new 32 bit ID

Jump to

Keyboard shortcuts

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