utils

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2023 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNoInput = errors.New("no input")

ErrNoInput indicates no text input

View Source
var ErrNoRecord = errors.New("no record found")

ErrNoRecord indicates no record found error

View Source
var ErrTextDoesNotMatch = errors.New("wrong text")

ErrTextDoesNotMatch indicates old text does not match a new one

View Source
var MaxLogDataSize = 100

MaxLogDataSize indicates how many bytes of data to log

Functions

func FloatEquals added in v0.2.387

func FloatEquals(a, b float32) bool

FloatEquals compares two floats

func IsRetryable added in v0.2.387

func IsRetryable(err error) bool

IsRetryable - check if error is retryable io.EOF or timeout

func LogData

func LogData(st string, data string)

LogData logs data to debug

func RetrieveInfo added in v0.2.407

func RetrieveInfo(pr interface{}) string

RetrieveInfo invokes Info() if interface has one else returns ""

func RetryAll added in v0.2.387

func RetryAll(err error) bool

RetryAll - retries all errors

Types

type ErrBadAccent

type ErrBadAccent struct {
	BadAccents []string
}

ErrBadAccent indicate bad accent error

func NewErrBadAccent

func NewErrBadAccent(badAccents []string) *ErrBadAccent

NewErrBadAccent creates new error

func (*ErrBadAccent) Error

func (r *ErrBadAccent) Error() string

type ErrBadSymbols added in v0.4.0

type ErrBadSymbols struct {
	Orig, Cleaned string
}

ErrBadSymbols indicates a word with wrong symbols

func NewErrBadSymbols added in v0.4.0

func NewErrBadSymbols(word, cleaned string) *ErrBadSymbols

NewErrBadSymbols creates new error

func (*ErrBadSymbols) Error added in v0.4.0

func (r *ErrBadSymbols) Error() string

type ErrTextTooLong added in v0.2.387

type ErrTextTooLong struct {
	Max, Len int
}

ErrTextTooLong indicates too long input

func NewErrTextTooLong added in v0.2.387

func NewErrTextTooLong(len, max int) *ErrTextTooLong

NewErrTextTooLong creates new error

func (*ErrTextTooLong) Error added in v0.2.387

func (r *ErrTextTooLong) Error() string

type ErrWordTooLong

type ErrWordTooLong struct {
	Word string
}

ErrWordTooLong indicates too long word

func NewErrWordTooLong

func NewErrWordTooLong(word string) *ErrWordTooLong

NewErrWordTooLong creates new error

func (*ErrWordTooLong) Error

func (r *ErrWordTooLong) Error() string

type HTTPBackoff added in v0.2.387

type HTTPBackoff struct {
	HTTPClient HTTPInvokerJSON

	InvokeIndicatorFunc func(interface{})
	RetryIndicatorFunc  func(interface{})
	// contains filtered or unexported fields
}

HTTPBackoff http call with backoff

func NewHTTPBackoff added in v0.2.387

func NewHTTPBackoff(realWrapper HTTPInvokerJSON, backoffF func() backoff.BackOff, retryF func(error) bool) (*HTTPBackoff, error)

NewHTTPBackoff creates new wrapper with backoff errF must return same error or wrap to backoff.PermanentError to stop backoff

func (*HTTPBackoff) Info added in v0.2.407

func (hw *HTTPBackoff) Info() string

Info returns info about wrapper

func (*HTTPBackoff) InvokeJSON added in v0.2.387

func (hw *HTTPBackoff) InvokeJSON(dataIn interface{}, dataOut interface{}) error

InvokeJSON makes http call with json

func (*HTTPBackoff) InvokeJSONU added in v0.2.387

func (hw *HTTPBackoff) InvokeJSONU(URL string, dataIn interface{}, dataOut interface{}) error

InvokeJSONU makes call to URL wits JSON

func (*HTTPBackoff) InvokeText added in v0.2.387

func (hw *HTTPBackoff) InvokeText(dataIn string, dataOut interface{}) error

InvokeText makes http call with text input

type HTTPInvokerJSON added in v0.2.387

type HTTPInvokerJSON interface {
	InvokeJSONU(string, interface{}, interface{}) error
	InvokeJSON(interface{}, interface{}) error
	InvokeText(string, interface{}) error
}

HTTPInvokerJSON http POST invoker with JSON in, out params

type HTTPWrap

type HTTPWrap struct {
	HTTPClient *http.Client
	URL        string
	Timeout    time.Duration
	// contains filtered or unexported fields
}

HTTPWrap for http call

func NewHTTPWrap added in v0.2.387

func NewHTTPWrap(urlStr string) (*HTTPWrap, error)

NewHTTPWrap creates new wrapper

func NewHTTPWrapT added in v0.2.387

func NewHTTPWrapT(urlStr string, timeout time.Duration) (*HTTPWrap, error)

NewHTTPWrapT creates new wrapper with timer

func (*HTTPWrap) Info added in v0.2.407

func (hw *HTTPWrap) Info() string

Info returns info about wrapper

func (*HTTPWrap) InvokeJSON

func (hw *HTTPWrap) InvokeJSON(dataIn interface{}, dataOut interface{}) error

InvokeJSON makes http call with json

func (*HTTPWrap) InvokeJSONU added in v0.2.387

func (hw *HTTPWrap) InvokeJSONU(URL string, dataIn interface{}, dataOut interface{}) error

InvokeJSONU makes http call to URL with JSON

func (*HTTPWrap) InvokeText

func (hw *HTTPWrap) InvokeText(dataIn string, dataOut interface{}) error

InvokeText makes http call with text

type RequestTypeEnum

type RequestTypeEnum int

RequestTypeEnum represent possible request types

const (
	//RequestOriginal value
	RequestOriginal RequestTypeEnum = iota + 1
	//RequestNormalized value - text after number replace
	RequestNormalized
	//RequestCleaned value - text after clean, normalize and url replace
	RequestCleaned
	//RequestUser value - data normalized by user
	RequestUser
	//RequestOriginalSSML value
	RequestOriginalSSML
)

func (RequestTypeEnum) String

func (e RequestTypeEnum) String() string

Jump to

Keyboard shortcuts

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