Documentation
¶
Index ¶
- Constants
- Variables
- func BoolPtr(i bool) *bool
- func ByteHamming84Decode(i uint8) (o uint8, ok bool)
- func ByteParity(i uint8) (o uint8, ok bool)
- func BytePtr(i byte) *byte
- func BytesPad(i []byte, repeat byte, length int, options ...PadOption) []byte
- func ChainHTTPMiddlewares(h http.Handler, ms ...HTTPMiddleware) http.Handler
- func ChainHTTPMiddlewaresWithPrefix(h http.Handler, prefixes []string, ms ...HTTPMiddleware) http.Handler
- func ConvertPCMBitDepth(srcSample int, srcBitDepth, dstBitDepth int) (dstSample int, err error)
- func Copy(ctx context.Context, dst io.Writer, src io.Reader) (int64, error)
- func CopyFile(ctx context.Context, dst, src string, f CopyFileFunc) (err error)
- func DurationPtr(i time.Duration) *time.Duration
- func ErrorCause(err error) error
- func FlagCmd() (o string)
- func Float64Ptr(i float64) *float64
- func Int64Ptr(i int64) *int64
- func IntPtr(i int) *int
- func LocalCopyFileFunc(ctx context.Context, dst string, srcStat os.FileInfo, srcFile *os.File) (err error)
- func MoveFile(ctx context.Context, dst, src string, f CopyFileFunc) (err error)
- func NopCloser(w io.Writer) io.WriteCloser
- func PCMLevel(samples []int) float64
- func PCMNormalize(samples []int, bitDepth int) (o []int)
- func PadCut(p *bytesPadder)
- func PadLeft(p *bytesPadder)
- func PadRight(p *bytesPadder)
- func RandStr(n int) string
- func ServeHTTP(w *Worker, o ServeHTTPOptions)
- func Sleep(ctx context.Context, d time.Duration) (err error)
- func SortInt64(a []int64)
- func StrPad(i string, repeat rune, length int, options ...PadOption) string
- func StrPtr(i string) *string
- func UInt32Ptr(i uint32) *uint32
- func UInt8Ptr(i uint8) *uint8
- func Unzip(ctx context.Context, dst, src string) (err error)
- func Zip(ctx context.Context, dst, src string) (err error)
- type BiMap
- func (m *BiMap) Get(k interface{}) (interface{}, bool)
- func (m *BiMap) GetInverse(k interface{}) (interface{}, bool)
- func (m *BiMap) MustGet(k interface{}) interface{}
- func (m *BiMap) MustGetInverse(k interface{}) interface{}
- func (m *BiMap) Set(k, v interface{}) *BiMap
- func (m *BiMap) SetInverse(k, v interface{}) *BiMap
- type BitsWriter
- type BitsWriterOptions
- type BufferPool
- type BufferPoolItem
- type BytesIterator
- func (i *BytesIterator) Dump() (bs []byte)
- func (i *BytesIterator) HasBytesLeft() bool
- func (i *BytesIterator) Len() int
- func (i *BytesIterator) NextByte() (b byte, err error)
- func (i *BytesIterator) NextBytes(n int) (bs []byte, err error)
- func (i *BytesIterator) Offset() int
- func (i *BytesIterator) Seek(n int)
- func (i *BytesIterator) Skip(n int)
- type Chan
- type ChanOptions
- type CloseFunc
- type Closer
- type CompleteLogger
- type CopyFileFunc
- type CounterAvgStat
- type CounterRateStat
- type CtxReader
- type DurationPercentageStat
- type Errors
- type Eventer
- type EventerHandler
- type EventerOptions
- type ExecCmdOptions
- type ExecHandler
- type FlagStrings
- type GoroutineLimiter
- type GoroutineLimiterFunc
- type GoroutineLimiterOptions
- type HTTPClient
- type HTTPDownloader
- func (d *HTTPDownloader) Close() error
- func (d *HTTPDownloader) DownloadInDirectory(ctx context.Context, dst string, srcs ...HTTPDownloaderSrc) error
- func (d *HTTPDownloader) DownloadInFile(ctx context.Context, dst string, srcs ...HTTPDownloaderSrc) (err error)
- func (d *HTTPDownloader) DownloadInWriter(ctx context.Context, dst io.Writer, srcs ...HTTPDownloaderSrc) error
- type HTTPDownloaderOptions
- type HTTPDownloaderSrc
- type HTTPMiddleware
- type HTTPResponseFunc
- type HTTPSendJSONOptions
- type HTTPSender
- type HTTPSenderOptions
- type HTTPSenderRetryFunc
- type Limiter
- type LimiterBucket
- type PCMChannelsConverter
- type PCMSampleFunc
- type PCMSampleRateConverter
- type PCMSilenceDetector
- type PCMSilenceDetectorOptions
- type PadOption
- type RWMutex
- type RWMutexOptions
- type Rational
- type SSHSession
- type SSHSessionFunc
- type ServeHTTPOptions
- type SeverityCtxLogger
- type SeverityLogger
- type SignalHandler
- type SortInt64Slice
- type Stat
- type StatHandler
- type StatMetadata
- type Stater
- type StaterOptions
- type StatsHandleFunc
- type StdLogger
- type Task
- type TaskFunc
- type Templater
- func (t *Templater) AddLayout(c string)
- func (t *Templater) AddLayoutsFromDir(dirPath, ext string) (err error)
- func (t *Templater) AddTemplate(path, content string) (err error)
- func (t *Templater) AddTemplatesFromDir(dirPath, ext string) (err error)
- func (t *Templater) DelTemplate(path string)
- func (t *Templater) Parse(content string) (o *template.Template, err error)
- func (t *Templater) Template(path string) (tpl *template.Template, ok bool)
- type Timestamp
- type Translator
- func (t *Translator) HTTPMiddleware(h http.Handler) http.Handler
- func (t *Translator) LanguageCtx(ctx context.Context) string
- func (t *Translator) ParseDir(dirPath string) (err error)
- func (t *Translator) ParseFile(path string) (err error)
- func (t *Translator) Translate(language, key string) string
- func (t *Translator) TranslateCtx(ctx context.Context, key string) string
- type TranslatorOptions
- type Worker
- type WorkerOptions
- type WriterAdapter
- type WriterAdapterOptions
Constants ¶
const ( ExecStatusCrashed = "crashed" ExecStatusRunning = "running" ExecStatusStopped = "stopped" )
Statuses
const ( // Calling Add() only blocks if the chan has been started and the ctx // has not been canceled ChanAddStrategyBlockWhenStarted = "block.when.started" // Calling Add() never blocks ChanAddStrategyNoBlock = "no.block" ChanOrderFIFO = "fifo" ChanOrderFILO = "filo" )
Chan constants
const (
StatNameWaitRatio = "astikit.wait.ratio"
)
Stat names
Variables ¶
var (
DefaultDirMode os.FileMode = 0755
)
Default modes
var ErrHTTPSenderUnmarshaledError = errors.New("astikit: unmarshaled error")
Functions ¶
func ByteHamming84Decode ¶ added in v0.0.10
ByteHamming84Decode hamming 8/4 decodes
func ByteParity ¶ added in v0.0.10
ByteParity returns the byte parity
func ChainHTTPMiddlewares ¶ added in v0.0.3
func ChainHTTPMiddlewares(h http.Handler, ms ...HTTPMiddleware) http.Handler
ChainHTTPMiddlewares chains HTTP middlewares
func ChainHTTPMiddlewaresWithPrefix ¶ added in v0.0.3
func ChainHTTPMiddlewaresWithPrefix(h http.Handler, prefixes []string, ms ...HTTPMiddleware) http.Handler
ChainHTTPMiddlewaresWithPrefix chains HTTP middlewares if one of prefixes is present
func ConvertPCMBitDepth ¶ added in v0.0.3
ConvertPCMBitDepth converts the PCM bit depth
func CopyFile ¶ added in v0.0.5
func CopyFile(ctx context.Context, dst, src string, f CopyFileFunc) (err error)
CopyFile is a cancellable copy of a local file to a local or remote location
func DurationPtr ¶ added in v0.0.3
DurationPtr transforms a time.Duration into a *time.Duration
func ErrorCause ¶ added in v0.2.0
ErrorCause returns the cause of an error
func FlagCmd ¶ added in v0.0.4
func FlagCmd() (o string)
FlagCmd retrieves the command from the input Args
func Float64Ptr ¶ added in v0.0.3
Float64Ptr transforms a float64 into a *float64
func LocalCopyFileFunc ¶ added in v0.0.5
func LocalCopyFileFunc(ctx context.Context, dst string, srcStat os.FileInfo, srcFile *os.File) (err error)
LocalCopyFileFunc is the local CopyFileFunc that allows doing cross partition copies
func MoveFile ¶ added in v0.0.8
func MoveFile(ctx context.Context, dst, src string, f CopyFileFunc) (err error)
MoveFile is a cancellable move of a local file to a local or remote location
func NopCloser ¶ added in v0.0.5
func NopCloser(w io.Writer) io.WriteCloser
NopCloser returns a WriteCloser with a no-op Close method wrapping the provided Writer w.
func PCMLevel ¶ added in v0.0.3
PCMLevel computes the PCM level of samples https://dsp.stackexchange.com/questions/2951/loudness-of-pcm-stream https://dsp.stackexchange.com/questions/290/getting-loudness-of-a-track-with-rms?noredirect=1&lq=1
func PCMNormalize ¶ added in v0.0.3
PCMNormalize normalizes the PCM samples
func PadCut ¶ added in v0.0.10
func PadCut(p *bytesPadder)
PadCut is a PadOption It indicates to the padder it must cut the input to the provided length if its original length is bigger
func PadLeft ¶ added in v0.0.10
func PadLeft(p *bytesPadder)
PadLeft is a PadOption It indicates additionnal bytes have to be added to the left
func PadRight ¶ added in v0.0.10
func PadRight(p *bytesPadder)
PadRight is a PadOption It indicates additionnal bytes have to be added to the right
func RandStr ¶ added in v0.0.5
RandStr generates a random string of length n https://stackoverflow.com/questions/22892120/how-to-generate-a-random-string-of-a-fixed-length-in-golang
func ServeHTTP ¶ added in v0.0.2
func ServeHTTP(w *Worker, o ServeHTTPOptions)
ServeHTTP spawns an HTTP server
func SortInt64 ¶ added in v0.0.6
func SortInt64(a []int64)
SortInt64 sorts a slice of int64s in increasing order.
Types ¶
type BiMap ¶ added in v0.0.10
type BiMap struct {
// contains filtered or unexported fields
}
BiMap represents a bidirectional map
func (*BiMap) Get ¶ added in v0.0.10
Get gets the value in the forward map based on the provided key
func (*BiMap) GetInverse ¶ added in v0.0.10
GetInverse gets the value in the inverse map based on the provided key
func (*BiMap) MustGet ¶ added in v0.9.2
func (m *BiMap) MustGet(k interface{}) interface{}
MustGet gets the value in the forward map based on the provided key and panics if key is not found
func (*BiMap) MustGetInverse ¶ added in v0.9.2
func (m *BiMap) MustGetInverse(k interface{}) interface{}
MustGetInverse gets the value in the inverse map based on the provided key and panics if key is not found
func (*BiMap) Set ¶ added in v0.0.10
Set sets the value in the forward and inverse map for the provided forward key
func (*BiMap) SetInverse ¶ added in v0.0.10
SetInverse sets the value in the forward and inverse map for the provided inverse key
type BitsWriter ¶ added in v0.0.9
type BitsWriter struct {
// contains filtered or unexported fields
}
BitsWriter represents an object that can write individual bits into a writer in a developer-friendly way. Check out the Write method for more information. This is particularly helpful when you want to build a slice of bytes based on individual bits for testing purposes.
func NewBitsWriter ¶ added in v0.0.9
func NewBitsWriter(o BitsWriterOptions) (w *BitsWriter)
NewBitsWriter creates a new BitsWriter
func (*BitsWriter) Write ¶ added in v0.0.9
func (w *BitsWriter) Write(i interface{}) (err error)
Write writes bits into the writer. Bits are only written when there are enough to create a byte. When using a string or a bool, bits are added from left to right as if Available types are:
- string("10010"): processed as n bits, n being the length of the input
- []byte: processed as n bytes, n being the length of the input
- bool: processed as one bit
- uint8/uint16/uint32/uint64: processed as n bits, if type is uintn
func (*BitsWriter) WriteN ¶ added in v0.0.9
func (w *BitsWriter) WriteN(i interface{}, n int) error
WriteN writes the input into n bits
type BitsWriterOptions ¶ added in v0.0.9
BitsWriterOptions represents BitsWriter options
type BufferPool ¶ added in v0.0.6
type BufferPool struct {
// contains filtered or unexported fields
}
BufferPool represents a *bytes.Buffer pool
func NewBufferPool ¶ added in v0.0.6
func NewBufferPool() *BufferPool
NewBufferPool creates a new BufferPool
func (*BufferPool) New ¶ added in v0.0.6
func (p *BufferPool) New() *BufferPoolItem
New creates a new BufferPoolItem
type BufferPoolItem ¶ added in v0.0.6
BufferPoolItem represents a BufferPool item
func (*BufferPoolItem) Close ¶ added in v0.0.6
func (i *BufferPoolItem) Close() error
Close implements the io.Closer interface
type BytesIterator ¶ added in v0.0.9
type BytesIterator struct {
// contains filtered or unexported fields
}
BytesIterator represents an object capable of iterating sequentially and safely through a slice of bytes. This is particularly useful when you need to iterate through a slice of bytes and don't want to check for "index out of range" errors manually.
func NewBytesIterator ¶ added in v0.0.9
func NewBytesIterator(bs []byte) *BytesIterator
NewBytesIterator creates a new BytesIterator
func (*BytesIterator) Dump ¶ added in v0.0.9
func (i *BytesIterator) Dump() (bs []byte)
Dump dumps the rest of the slice
func (*BytesIterator) HasBytesLeft ¶ added in v0.0.9
func (i *BytesIterator) HasBytesLeft() bool
HasBytesLeft checks whether there are bytes left
func (*BytesIterator) Len ¶ added in v0.0.9
func (i *BytesIterator) Len() int
Len returns the slice length
func (*BytesIterator) NextByte ¶ added in v0.0.9
func (i *BytesIterator) NextByte() (b byte, err error)
NextByte returns the next byte
func (*BytesIterator) NextBytes ¶ added in v0.0.9
func (i *BytesIterator) NextBytes(n int) (bs []byte, err error)
NextBytes returns the n next bytes
func (*BytesIterator) Offset ¶ added in v0.0.9
func (i *BytesIterator) Offset() int
Offset returns the offset
func (*BytesIterator) Seek ¶ added in v0.0.9
func (i *BytesIterator) Seek(n int)
Seek seeks to the nth byte
func (*BytesIterator) Skip ¶ added in v0.0.9
func (i *BytesIterator) Skip(n int)
Skip skips the n previous/next bytes
type Chan ¶ added in v0.0.3
type Chan struct {
// contains filtered or unexported fields
}
Chan is an object capable of executing funcs in a specific order while controlling the conditions in which adding new funcs is blocking Check out ChanOptions for detailed options
type ChanOptions ¶ added in v0.0.3
type ChanOptions struct { // Determines the conditions in which Add() blocks. See constants with pattern ChanAddStrategy* // Default is ChanAddStrategyNoBlock AddStrategy string // Order in which the funcs will be processed. See constants with pattern ChanOrder* // Default is ChanOrderFIFO Order string // By default the funcs not yet processed when the context is cancelled are dropped. // If "ProcessAll" is true, ALL funcs are processed even after the context is cancelled. // However, no funcs can be added after the context is cancelled ProcessAll bool }
ChanOptions are Chan options
type CloseFunc ¶ added in v0.0.4
type CloseFunc func() error
CloseFunc is a method that closes something
type Closer ¶ added in v0.0.4
type Closer struct {
// contains filtered or unexported fields
}
Closer is an object that can close several things
type CompleteLogger ¶ added in v0.1.0
type CompleteLogger interface { StdLogger SeverityLogger SeverityCtxLogger }
CompleteLogger represents a complete logger
func AdaptStdLogger ¶ added in v0.0.4
func AdaptStdLogger(i StdLogger) CompleteLogger
AdaptStdLogger transforms an StdLogger into a CompleteLogger if needed
type CopyFileFunc ¶ added in v0.0.5
type CopyFileFunc func(ctx context.Context, dst string, srcStat os.FileInfo, srcFile *os.File) error
CopyFileFunc represents a CopyFile func
func SSHCopyFileFunc ¶ added in v0.0.5
func SSHCopyFileFunc(fn SSHSessionFunc) CopyFileFunc
SSHCopyFileFunc is the SSH CopyFileFunc that allows doing SSH copies
type CounterAvgStat ¶ added in v0.0.4
type CounterAvgStat struct {
// contains filtered or unexported fields
}
CounterAvgStat is an object capable of computing the average value of a counter
func NewCounterAvgStat ¶ added in v0.0.4
func NewCounterAvgStat() *CounterAvgStat
NewCounterAvgStat creates a new counter avg stat
type CounterRateStat ¶ added in v0.7.0
type CounterRateStat struct {
// contains filtered or unexported fields
}
CounterRateStat is an object capable of computing the average value of a counter per second
func NewCounterRateStat ¶ added in v0.7.0
func NewCounterRateStat() *CounterRateStat
NewCounterRateStat creates a new counter rate stat
type CtxReader ¶ added in v0.0.5
type CtxReader struct {
// contains filtered or unexported fields
}
CtxReader represents a reader with a context
func NewCtxReader ¶ added in v0.0.5
NewCtxReader creates a reader with a context
type DurationPercentageStat ¶ added in v0.0.4
type DurationPercentageStat struct {
// contains filtered or unexported fields
}
DurationPercentageStat is an object capable of computing the percentage of time some work is taking per second
func NewDurationPercentageStat ¶ added in v0.0.4
func NewDurationPercentageStat() *DurationPercentageStat
NewDurationPercentageStat creates a new duration percentage stat
type Errors ¶ added in v0.0.4
type Errors struct {
// contains filtered or unexported fields
}
Errors is an error containing multiple errors
type Eventer ¶ added in v0.0.12
type Eventer struct {
// contains filtered or unexported fields
}
Eventer represents an object that can dispatch simple events (name + payload)
func NewEventer ¶ added in v0.0.12
func NewEventer(o EventerOptions) *Eventer
NewEventer creates a new eventer
func (*Eventer) On ¶ added in v0.0.12
func (e *Eventer) On(name string, h EventerHandler)
On adds an handler for a specific name
type EventerHandler ¶ added in v0.0.12
type EventerHandler func(payload interface{})
EventerHandler represents a function that can handle the payload of an event
type EventerOptions ¶ added in v0.0.12
type EventerOptions struct {
Chan ChanOptions
}
EventerOptions represents Eventer options
type ExecCmdOptions ¶ added in v0.0.2
type ExecCmdOptions struct { Args []string CmdAdapter func(cmd *exec.Cmd, h *ExecHandler) error Name string StopFunc func(cmd *exec.Cmd) error }
ExecCmdOptions represents exec options
type ExecHandler ¶ added in v0.0.2
type ExecHandler struct {
// contains filtered or unexported fields
}
ExecHandler represents an object capable of handling the execution of a cmd
func ExecCmd ¶ added in v0.0.2
func ExecCmd(w *Worker, o ExecCmdOptions) (h *ExecHandler, err error)
ExecCmd executes a cmd The process will be stopped when the worker stops
func (*ExecHandler) Status ¶ added in v0.0.2
func (h *ExecHandler) Status() string
Status returns the cmd status
type FlagStrings ¶ added in v0.0.9
FlagStrings represents a flag that can be set several times and stores unique string values
func NewFlagStrings ¶ added in v0.0.9
func NewFlagStrings() FlagStrings
NewFlagStrings creates a new FlagStrings
func (FlagStrings) Set ¶ added in v0.0.9
func (f FlagStrings) Set(i string) error
Set implements the flag.Value interface
func (FlagStrings) String ¶ added in v0.0.9
func (f FlagStrings) String() string
String implements the flag.Value interface
type GoroutineLimiter ¶ added in v0.0.6
type GoroutineLimiter struct {
// contains filtered or unexported fields
}
GoroutineLimiter is an object capable of doing several things in parallel while maintaining the max number of things running in parallel under a threshold
func NewGoroutineLimiter ¶ added in v0.0.6
func NewGoroutineLimiter(o GoroutineLimiterOptions) (l *GoroutineLimiter)
NewGoroutineLimiter creates a new GoroutineLimiter
func (*GoroutineLimiter) Close ¶ added in v0.0.6
func (l *GoroutineLimiter) Close() error
Close closes the limiter properly
func (*GoroutineLimiter) Do ¶ added in v0.0.6
func (l *GoroutineLimiter) Do(fn GoroutineLimiterFunc) (err error)
Do executes custom work in a goroutine
type GoroutineLimiterFunc ¶ added in v0.0.6
type GoroutineLimiterFunc func()
GoroutineLimiterFunc is a GoroutineLimiter func
type GoroutineLimiterOptions ¶ added in v0.0.6
type GoroutineLimiterOptions struct {
Max int
}
GoroutineLimiterOptions represents GoroutineLimiter options
type HTTPClient ¶ added in v0.0.4
HTTPClient represents an HTTP client
type HTTPDownloader ¶ added in v0.0.6
type HTTPDownloader struct {
// contains filtered or unexported fields
}
HTTPDownloader represents an object capable of downloading several HTTP srcs simultaneously and doing stuff to the results
func NewHTTPDownloader ¶ added in v0.0.6
func NewHTTPDownloader(o HTTPDownloaderOptions) (d *HTTPDownloader)
NewHTTPDownloader creates a new HTTPDownloader
func (*HTTPDownloader) Close ¶ added in v0.0.6
func (d *HTTPDownloader) Close() error
Close closes the downloader properly
func (*HTTPDownloader) DownloadInDirectory ¶ added in v0.0.6
func (d *HTTPDownloader) DownloadInDirectory(ctx context.Context, dst string, srcs ...HTTPDownloaderSrc) error
DownloadInDirectory downloads in parallel a set of srcs and saves them in a dst directory
func (*HTTPDownloader) DownloadInFile ¶ added in v0.0.6
func (d *HTTPDownloader) DownloadInFile(ctx context.Context, dst string, srcs ...HTTPDownloaderSrc) (err error)
DownloadInFile downloads in parallel a set of srcs and concatenates them in a dst file while maintaining the initial order
func (*HTTPDownloader) DownloadInWriter ¶ added in v0.0.6
func (d *HTTPDownloader) DownloadInWriter(ctx context.Context, dst io.Writer, srcs ...HTTPDownloaderSrc) error
DownloadInWriter downloads in parallel a set of srcs and concatenates them in a writer while maintaining the initial order
type HTTPDownloaderOptions ¶ added in v0.0.6
type HTTPDownloaderOptions struct { Limiter GoroutineLimiterOptions ResponseFunc HTTPResponseFunc Sender HTTPSenderOptions }
HTTPDownloaderOptions represents HTTPDownloader options
type HTTPDownloaderSrc ¶ added in v0.0.6
type HTTPMiddleware ¶ added in v0.0.3
HTTPMiddleware represents an HTTP middleware
func HTTPMiddlewareBasicAuth ¶ added in v0.0.3
func HTTPMiddlewareBasicAuth(username, password string) HTTPMiddleware
HTTPMiddlewareBasicAuth adds basic HTTP auth to an HTTP handler
func HTTPMiddlewareContentType ¶ added in v0.0.3
func HTTPMiddlewareContentType(contentType string) HTTPMiddleware
HTTPMiddlewareContentType adds a content type to an HTTP handler
func HTTPMiddlewareHeaders ¶ added in v0.0.5
func HTTPMiddlewareHeaders(vs map[string]string) HTTPMiddleware
HTTPMiddlewareHeaders adds headers to an HTTP handler
type HTTPResponseFunc ¶ added in v0.0.6
HTTPResponseFunc is a func that can process an $http.Response
type HTTPSendJSONOptions ¶ added in v0.9.2
type HTTPSendJSONOptions struct { BodyError interface{} BodyIn interface{} BodyOut interface{} Headers map[string]string Method string URL string }
HTTPSendJSONOptions represents SendJSON options
type HTTPSender ¶ added in v0.0.4
type HTTPSender struct {
// contains filtered or unexported fields
}
HTTPSender represents an object capable of sending http requests
func NewHTTPSender ¶ added in v0.0.4
func NewHTTPSender(o HTTPSenderOptions) (s *HTTPSender)
NewHTTPSender creates a new HTTP sender
func (*HTTPSender) SendJSON ¶ added in v0.9.2
func (s *HTTPSender) SendJSON(o HTTPSendJSONOptions) (err error)
SendJSON sends a new JSON HTTP request
func (*HTTPSender) SendWithTimeout ¶ added in v0.5.0
func (s *HTTPSender) SendWithTimeout(req *http.Request, timeout time.Duration) (resp *http.Response, err error)
SendWithTimeout sends a new *http.Request with a timeout
type HTTPSenderOptions ¶ added in v0.0.4
type HTTPSenderOptions struct { Client HTTPClient Logger StdLogger RetryFunc HTTPSenderRetryFunc RetryMax int RetrySleep time.Duration Timeout time.Duration }
HTTPSenderOptions represents HTTPSender options
type HTTPSenderRetryFunc ¶ added in v0.0.4
HTTPSenderRetryFunc is a function that decides whether to retry an HTTP request
type Limiter ¶ added in v0.0.3
type Limiter struct {
// contains filtered or unexported fields
}
Limiter represents a limiter
type LimiterBucket ¶ added in v0.0.3
type LimiterBucket struct {
// contains filtered or unexported fields
}
LimiterBucket represents a limiter bucket
func (*LimiterBucket) Close ¶ added in v0.0.3
func (b *LimiterBucket) Close()
close closes the bucket properly
func (*LimiterBucket) Inc ¶ added in v0.0.3
func (b *LimiterBucket) Inc() bool
Inc increments the bucket count
type PCMChannelsConverter ¶ added in v0.0.3
type PCMChannelsConverter struct {
// contains filtered or unexported fields
}
PCMChannelsConverter is an object of converting PCM's channels
func NewPCMChannelsConverter ¶ added in v0.0.3
func NewPCMChannelsConverter(srcNumChannels, dstNumChannels int, fn PCMSampleFunc) *PCMChannelsConverter
NewPCMChannelsConverter creates a new PCMChannelsConverter
func (*PCMChannelsConverter) Add ¶ added in v0.0.3
func (c *PCMChannelsConverter) Add(i int) (err error)
Add adds a new sample to the converter
func (*PCMChannelsConverter) Reset ¶ added in v0.0.3
func (c *PCMChannelsConverter) Reset()
Reset resets the converter
type PCMSampleFunc ¶ added in v0.0.3
PCMSampleFunc is a func that can process a sample
type PCMSampleRateConverter ¶ added in v0.0.3
type PCMSampleRateConverter struct {
// contains filtered or unexported fields
}
PCMSampleRateConverter is an object capable of converting a PCM's sample rate
func NewPCMSampleRateConverter ¶ added in v0.0.3
func NewPCMSampleRateConverter(srcSampleRate, dstSampleRate, numChannels int, fn PCMSampleFunc) *PCMSampleRateConverter
NewPCMSampleRateConverter creates a new PCMSampleRateConverter
func (*PCMSampleRateConverter) Add ¶ added in v0.0.3
func (c *PCMSampleRateConverter) Add(i int) (err error)
Add adds a new sample to the converter
func (*PCMSampleRateConverter) Reset ¶ added in v0.0.3
func (c *PCMSampleRateConverter) Reset()
Reset resets the converter
type PCMSilenceDetector ¶ added in v0.0.3
type PCMSilenceDetector struct {
// contains filtered or unexported fields
}
PCMSilenceDetector represents a PCM silence detector
func NewPCMSilenceDetector ¶ added in v0.0.3
func NewPCMSilenceDetector(o PCMSilenceDetectorOptions) (d *PCMSilenceDetector)
NewPCMSilenceDetector creates a new silence detector
func (*PCMSilenceDetector) Add ¶ added in v0.0.3
func (d *PCMSilenceDetector) Add(samples []int) (validSamples [][]int)
Add adds samples to the buffer and checks whether there are valid samples between silences
func (*PCMSilenceDetector) Reset ¶ added in v0.0.3
func (d *PCMSilenceDetector) Reset()
Reset resets the silence detector
type PCMSilenceDetectorOptions ¶ added in v0.0.3
type PCMSilenceDetectorOptions struct { MaxSilenceLevel float64 `toml:"max_silence_level"` MinSilenceDuration time.Duration `toml:"min_silence_duration"` SampleRate int `toml:"sample_rate"` StepDuration time.Duration `toml:"step_duration"` }
PCMSilenceDetectorOptions represents a PCM silence detector options
type PadOption ¶ added in v0.0.10
type PadOption func(p *bytesPadder)
PadOption represents a Pad option
type RWMutex ¶ added in v0.1.0
type RWMutex struct {
// contains filtered or unexported fields
}
RWMutex represents a RWMutex capable of logging its actions to ease deadlock debugging
func NewRWMutex ¶ added in v0.1.0
func NewRWMutex(o RWMutexOptions) *RWMutex
NewRWMutex creates a new RWMutex
func (*RWMutex) IsDeadlocked ¶ added in v0.1.0
IsDeadlocked checks whether the mutex is deadlocked with a given timeout and returns the last caller
type RWMutexOptions ¶ added in v0.1.0
RWMutexOptions represents RWMutex options
type Rational ¶ added in v0.0.4
type Rational struct {
// contains filtered or unexported fields
}
Rational represents a rational
func NewRational ¶ added in v0.0.4
NewRational creates a new rational
func (*Rational) MarshalText ¶ added in v0.0.4
MarshalText implements the TextMarshaler interface
func (*Rational) UnmarshalText ¶ added in v0.0.4
UnmarshalText implements the TextUnmarshaler interface
type SSHSession ¶ added in v0.0.5
type SSHSession interface { Run(string) error Start(string) error StdinPipe() (io.WriteCloser, error) Wait() error }
SSHSession represents an SSH Session
type SSHSessionFunc ¶ added in v0.0.5
type SSHSessionFunc func() (s SSHSession, c *Closer, err error)
SSHSessionFunc represents a func that can return an SSHSession
type ServeHTTPOptions ¶ added in v0.0.2
ServeHTTPOptions represents serve options
type SeverityCtxLogger ¶ added in v0.1.0
type SeverityCtxLogger interface { DebugC(ctx context.Context, v ...interface{}) DebugCf(ctx context.Context, format string, v ...interface{}) ErrorC(ctx context.Context, v ...interface{}) ErrorCf(ctx context.Context, format string, v ...interface{}) InfoC(ctx context.Context, v ...interface{}) InfoCf(ctx context.Context, format string, v ...interface{}) }
SeverityCtxLogger represents a severity with context logger
type SeverityLogger ¶ added in v0.0.4
type SeverityLogger interface { Debug(v ...interface{}) Debugf(format string, v ...interface{}) Error(v ...interface{}) Errorf(format string, v ...interface{}) Info(v ...interface{}) Infof(format string, v ...interface{}) }
SeverityLogger represents a severity logger
type SignalHandler ¶ added in v0.0.2
SignalHandler represents a func that can handle a signal
func LoggerSignalHandler ¶ added in v0.6.0
func LoggerSignalHandler(l SeverityLogger, ignoredSignals ...os.Signal) SignalHandler
LoggerSignalHandler returns a SignalHandler that logs the signal
func TermSignalHandler ¶ added in v0.0.2
func TermSignalHandler(f func()) SignalHandler
TermSignalHandler returns a SignalHandler that is executed only on a term signal
type SortInt64Slice ¶ added in v0.0.6
type SortInt64Slice []int64
SortInt64Slice attaches the methods of Interface to []int64, sorting in increasing order.
func (SortInt64Slice) Len ¶ added in v0.0.6
func (p SortInt64Slice) Len() int
func (SortInt64Slice) Less ¶ added in v0.0.6
func (p SortInt64Slice) Less(i, j int) bool
func (SortInt64Slice) Swap ¶ added in v0.0.6
func (p SortInt64Slice) Swap(i, j int)
type Stat ¶ added in v0.0.4
type Stat struct { StatMetadata Value interface{} }
Stat represents a stat
type StatHandler ¶ added in v0.0.4
StatHandler represents a stat handler
type StatMetadata ¶ added in v0.0.4
StatMetadata represents a stat metadata
type Stater ¶ added in v0.0.4
type Stater struct {
// contains filtered or unexported fields
}
Stater is an object that can compute and handle stats
func NewStater ¶ added in v0.0.4
func NewStater(o StaterOptions) *Stater
NewStater creates a new stater
func (*Stater) AddStat ¶ added in v0.0.4
func (s *Stater) AddStat(m StatMetadata, h StatHandler)
AddStat adds a stat
func (*Stater) StatsMetadata ¶ added in v0.0.4
func (s *Stater) StatsMetadata() (ms []StatMetadata)
StatsMetadata returns the stats metadata
type StaterOptions ¶ added in v0.0.4
type StaterOptions struct { HandleFunc StatsHandleFunc Period time.Duration }
StaterOptions represents stater options
type StatsHandleFunc ¶ added in v0.0.4
type StatsHandleFunc func(stats []Stat)
StatsHandleFunc is a method that can handle stats
type StdLogger ¶ added in v0.0.4
type StdLogger interface { Print(v ...interface{}) Printf(format string, v ...interface{}) }
StdLogger represents a standard logger
type Task ¶ added in v0.0.2
type Task struct {
// contains filtered or unexported fields
}
Task represents a task
func (*Task) NewSubTask ¶ added in v0.0.2
NewSubTask creates a new sub task
type TaskFunc ¶ added in v0.0.2
type TaskFunc func() *Task
TaskFunc represents a function that can create a new task
type Templater ¶ added in v0.0.3
type Templater struct {
// contains filtered or unexported fields
}
Templater represents an object capable of storing and parsing templates
func NewTemplater ¶ added in v0.0.3
func NewTemplater() *Templater
NewTemplater creates a new templater
func (*Templater) AddLayoutsFromDir ¶ added in v0.0.3
AddLayoutsFromDir walks through a dir and add files as layouts
func (*Templater) AddTemplate ¶ added in v0.0.3
AddTemplate adds a new template
func (*Templater) AddTemplatesFromDir ¶ added in v0.0.3
AddTemplatesFromDir walks through a dir and add files as templates
func (*Templater) DelTemplate ¶ added in v0.0.3
DelTemplate deletes a template
type Timestamp ¶
Timestamp represents a timestamp you can marshal and umarshal
func (Timestamp) MarshalJSON ¶
MarshalJSON implements the JSONMarshaler interface
func (Timestamp) MarshalText ¶
MarshalText implements the TextMarshaler interface
func (*Timestamp) UnmarshalJSON ¶
UnmarshalJSON implements the JSONUnmarshaler interface
func (*Timestamp) UnmarshalText ¶
UnmarshalText implements the TextUnmarshaler interface
type Translator ¶ added in v0.3.0
type Translator struct {
// contains filtered or unexported fields
}
Translator represents an object capable of translating stuff
func NewTranslator ¶ added in v0.3.0
func NewTranslator(o TranslatorOptions) *Translator
NewTranslator creates a new Translator
func (*Translator) HTTPMiddleware ¶ added in v0.3.0
func (t *Translator) HTTPMiddleware(h http.Handler) http.Handler
HTTPMiddleware is the Translator HTTP middleware
func (*Translator) LanguageCtx ¶ added in v0.4.0
func (t *Translator) LanguageCtx(ctx context.Context) string
LanguageCtx returns the translator language from the context, or the default language if not in the context
func (*Translator) ParseDir ¶ added in v0.3.0
func (t *Translator) ParseDir(dirPath string) (err error)
ParseDir adds translations located in ".json" files in the specified dir
func (*Translator) ParseFile ¶ added in v0.3.0
func (t *Translator) ParseFile(path string) (err error)
ParseFile adds translation located in the provided path
func (*Translator) Translate ¶ added in v0.3.0
func (t *Translator) Translate(language, key string) string
Translate translates a key into a specific language
func (*Translator) TranslateCtx ¶ added in v0.3.0
func (t *Translator) TranslateCtx(ctx context.Context, key string) string
TranslateCtx translates a key using the language specified in the context
type TranslatorOptions ¶ added in v0.3.0
type TranslatorOptions struct {
DefaultLanguage string
}
TranslatorOptions represents Translator options
type Worker ¶ added in v0.0.2
type Worker struct {
// contains filtered or unexported fields
}
Worker represents an object capable of blocking, handling signals and stopping
func NewWorker ¶ added in v0.0.2
func NewWorker(o WorkerOptions) (w *Worker)
NewWorker builds a new worker
func (*Worker) HandleSignals ¶ added in v0.0.2
func (w *Worker) HandleSignals(hs ...SignalHandler)
HandleSignals handles signals
func (*Worker) Logger ¶ added in v0.0.2
func (w *Worker) Logger() SeverityLogger
Logger returns the worker's logger
type WorkerOptions ¶ added in v0.0.3
type WorkerOptions struct {
Logger StdLogger
}
WorkerOptions represents worker options
type WriterAdapter ¶ added in v0.0.3
type WriterAdapter struct {
// contains filtered or unexported fields
}
WriterAdapter represents an object that can adapt a Writer
func NewWriterAdapter ¶ added in v0.0.3
func NewWriterAdapter(o WriterAdapterOptions) *WriterAdapter
NewWriterAdapter creates a new WriterAdapter
func (*WriterAdapter) Close ¶ added in v0.0.3
func (w *WriterAdapter) Close() error
Close closes the adapter properly
type WriterAdapterOptions ¶ added in v0.0.3
WriterAdapterOptions represents WriterAdapter options