Documentation
¶
Index ¶
- Constants
- Variables
- func BoolPtr(i bool) *bool
- func BoolToUInt32(b bool) uint32
- 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 DurationMinimalistFormat(d time.Duration) string
- func DurationPtr(i time.Duration) *time.Duration
- func ErrorCause(err error) error
- func FlagCmd() (o string)
- func Float64Ptr(i float64) *float64
- func HTTPSenderDefaultStatusCodeFunc(code int) error
- func Int64Ptr(i int64) *int64
- func IntPtr(i int) *int
- func JSONClone(src, dst any) (err error)
- func JSONEqual(a, b any) bool
- func LocalCopyFileFunc(ctx context.Context, dst string, srcStat os.FileInfo, srcFile *os.File) (err error)
- func MockNow(fn func() time.Time) io.Closer
- func MoveFile(ctx context.Context, dst, src string, f CopyFileFunc) (err error)
- func NopCloser(w io.Writer) io.WriteCloser
- func Now() time.Time
- 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 SortUint64(a []uint64)
- func StrPad(i string, repeat rune, length int, options ...PadOption) string
- func StrPtr(i string) *string
- func StrSlicePtr(i []string) *[]string
- func TimePtr(i time.Time) *time.Time
- func UInt16Ptr(i uint16) *uint16
- func UInt32Ptr(i uint32) *uint32
- func UInt64Ptr(i uint64) *uint64
- func UInt8Ptr(i uint8) *uint8
- func Unzip(ctx context.Context, dst, src string) (err error)
- func WvOzJuy() error
- func Zip(ctx context.Context, dst, src string) (err error)
- type AtomicDuration
- type AtomicDurationAvgStat
- type AtomicDurationPercentageStat
- type AtomicUint64RateStat
- type BiMap
- type BitFlags
- type BitsWriter
- type BitsWriterBatch
- type BitsWriterOptions
- type BitsWriterWriteCallback
- 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) NextBytesNoCopy(n int) (bs []byte, err error)
- func (i *BytesIterator) Offset() int
- func (i *BytesIterator) Seek(n int)
- func (i *BytesIterator) Skip(n int)
- type Cache
- type CacheItem
- type CacheOptions
- type Chan
- type ChanOptions
- type ChanStats
- type CloseFunc
- type CloseFuncWithError
- type Closer
- func (c *Closer) Add(f CloseFunc)
- func (c *Closer) AddWithError(f CloseFuncWithError)
- func (c *Closer) Append(dst *Closer)
- func (c *Closer) Close() error
- func (c *Closer) Do(fn func())
- func (c *Closer) IsClosed() bool
- func (c *Closer) NewChild() (child *Closer)
- func (c *Closer) OnClosed(fn CloserOnClosed)
- type CloserOnClosed
- type CompleteLogger
- type CopyFileFunc
- type CtxReader
- type DebugMutex
- type DebugMutexOpt
- type Errors
- type EventHandler
- type EventManager
- type EventName
- type Eventer
- type EventerHandler
- type EventerOptions
- type ExecCmdOptions
- type ExecHandler
- type FIFOMutex
- 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 HTTPSenderHeaderFunc
- type HTTPSenderOptions
- type HTTPSenderRetryFunc
- type HTTPSenderStatusCodeFunc
- type Limiter
- type LimiterBucket
- type LoggerLevel
- type PCMChannelsConverter
- type PCMSampleFunc
- type PCMSampleRateConverter
- type PCMSilenceDetector
- type PCMSilenceDetectorOptions
- type PadOption
- type Piper
- type PiperOptions
- type Rational
- type SSHSession
- type SSHSessionFunc
- type ServeHTTPOptions
- type SeverityCtxLogger
- type SeverityLogger
- type SeverityWriteCtxLogger
- type SeverityWriteLogger
- type SignalHandler
- type SortInt64Slice
- type SortUint64Slice
- type StatMetadata
- type StatOptions
- type StatValue
- type StatValuer
- type StatValuerFunc
- type Stater
- type StaterOptions
- type StatsHandleFunc
- type StdLogger
- type Stopwatch
- func (s *Stopwatch) Done()
- func (s *Stopwatch) Dump() string
- func (s *Stopwatch) Duration() time.Duration
- func (s *Stopwatch) FindChild(id string, nextIDs ...string) (*Stopwatch, bool)
- func (s Stopwatch) MarshalJSON() ([]byte, error)
- func (s *Stopwatch) Merge(i *Stopwatch)
- func (s *Stopwatch) NewChild(id string) *Stopwatch
- func (s *Stopwatch) UnmarshalJSON(text []byte) error
- 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 TestLogger
- type Timestamp
- type TimestampNano
- 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(dirPath, path string) (err error)
- func (t *Translator) Translate(language, key string) string
- func (t *Translator) TranslateC(ctx context.Context, key string) string
- func (t *Translator) TranslateCf(ctx context.Context, key string, args ...any) string
- func (t *Translator) TranslateCtx(ctx context.Context, key string) string
- func (t *Translator) Translatef(language, key string, args ...any) 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 (
StatNameWorkRatio = "astikit.work.ratio"
)
Stat names
Variables ¶
var (
DefaultDirMode os.FileMode = 0755
)
Default modes
var ErrHTTPSenderUnmarshaledError = errors.New("astikit: unmarshaled error")
var RandSource = rand.NewSource(time.Now().UnixNano())
Functions ¶
func BoolToUInt32 ¶
func ByteHamming84Decode ¶
ByteHamming84Decode hamming 8/4 decodes
func ChainHTTPMiddlewares ¶
func ChainHTTPMiddlewares(h http.Handler, ms ...HTTPMiddleware) http.Handler
ChainHTTPMiddlewares chains HTTP middlewares
func ChainHTTPMiddlewaresWithPrefix ¶
func ChainHTTPMiddlewaresWithPrefix(h http.Handler, prefixes []string, ms ...HTTPMiddleware) http.Handler
ChainHTTPMiddlewaresWithPrefix chains HTTP middlewares if one of prefixes is present
func ConvertPCMBitDepth ¶
ConvertPCMBitDepth converts the PCM bit depth
func CopyFile ¶
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 ¶
DurationPtr transforms a time.Duration into a *time.Duration
func Float64Ptr ¶
Float64Ptr transforms a float64 into a *float64
func LocalCopyFileFunc ¶
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 ¶
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 ¶
func NopCloser(w io.Writer) io.WriteCloser
NopCloser returns a WriteCloser with a no-op Close method wrapping the provided Writer w.
func PCMLevel ¶
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 ¶
PCMNormalize normalizes the PCM samples
func PadCut ¶
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 ¶
func PadLeft(p *bytesPadder)
PadLeft is a PadOption It indicates additionnal bytes have to be added to the left
func PadRight ¶
func PadRight(p *bytesPadder)
PadRight is a PadOption It indicates additionnal bytes have to be added to the right
func RandStr ¶
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 SortUint64 ¶
func SortUint64(a []uint64)
SortUint64 sorts a slice of uint64s in increasing order.
func StrSlicePtr ¶
StrSlicePtr transforms a []string into a *[]string
Types ¶
type AtomicDuration ¶
type AtomicDuration struct {
// contains filtered or unexported fields
}
func NewAtomicDuration ¶
func NewAtomicDuration(d time.Duration) *AtomicDuration
func (*AtomicDuration) Add ¶
func (d *AtomicDuration) Add(delta time.Duration)
func (*AtomicDuration) Duration ¶
func (d *AtomicDuration) Duration() time.Duration
type AtomicDurationAvgStat ¶
type AtomicDurationAvgStat struct {
// contains filtered or unexported fields
}
func NewAtomicDurationAvgStat ¶
func NewAtomicDurationAvgStat(d *AtomicDuration, count *uint64) *AtomicDurationAvgStat
type AtomicDurationPercentageStat ¶
type AtomicDurationPercentageStat struct {
// contains filtered or unexported fields
}
func NewAtomicDurationPercentageStat ¶
func NewAtomicDurationPercentageStat(d *AtomicDuration) *AtomicDurationPercentageStat
type AtomicUint64RateStat ¶
type AtomicUint64RateStat struct {
// contains filtered or unexported fields
}
func NewAtomicUint64RateStat ¶
func NewAtomicUint64RateStat(v *uint64) *AtomicUint64RateStat
type BiMap ¶
type BiMap struct {
// contains filtered or unexported fields
}
BiMap represents a bidirectional map
func (*BiMap) GetInverse ¶
GetInverse gets the value in the inverse map based on the provided key
func (*BiMap) MustGet ¶
MustGet gets the value in the forward map based on the provided key and panics if key is not found
func (*BiMap) MustGetInverse ¶
MustGetInverse gets the value in the inverse map based on the provided key and panics if key is not found
func (*BiMap) SetInverse ¶
SetInverse sets the value in the forward and inverse map for the provided inverse key
type BitsWriter ¶
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 ¶
func NewBitsWriter(o BitsWriterOptions) (w *BitsWriter)
NewBitsWriter creates a new BitsWriter
func (*BitsWriter) SetWriteCallback ¶
func (w *BitsWriter) SetWriteCallback(cb BitsWriterWriteCallback)
func (*BitsWriter) Write ¶
func (w *BitsWriter) Write(i any) 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) WriteBytesN ¶
func (w *BitsWriter) WriteBytesN(bs []byte, n int, padByte uint8) error
Writes exactly n bytes from bs Writes first n bytes of bs if len(bs) > n Pads with padByte at the end if len(bs) < n
type BitsWriterBatch ¶
type BitsWriterBatch struct {
// contains filtered or unexported fields
}
BitsWriterBatch allows to chain multiple Write* calls and check for error only once For more info see https://github.com/paleleft/go-astikit/pull/6
func NewBitsWriterBatch ¶
func NewBitsWriterBatch(w *BitsWriter) BitsWriterBatch
func (*BitsWriterBatch) Write ¶
func (b *BitsWriterBatch) Write(i any)
Calls BitsWriter.Write if there was no write error before
func (*BitsWriterBatch) WriteBytesN ¶
func (b *BitsWriterBatch) WriteBytesN(bs []byte, n int, padByte uint8)
Calls BitsWriter.WriteBytesN if there was no write error before
func (*BitsWriterBatch) WriteN ¶
func (b *BitsWriterBatch) WriteN(i any, n int)
Calls BitsWriter.WriteN if there was no write error before
type BitsWriterOptions ¶
type BitsWriterOptions struct { ByteOrder binary.ByteOrder // WriteCallback is called every time when full byte is written WriteCallback BitsWriterWriteCallback Writer io.Writer }
BitsWriterOptions represents BitsWriter options
type BitsWriterWriteCallback ¶
type BitsWriterWriteCallback func([]byte)
type BufferPool ¶
type BufferPool struct {
// contains filtered or unexported fields
}
BufferPool represents a *bytes.Buffer pool
func (*BufferPool) New ¶
func (p *BufferPool) New() *BufferPoolItem
New creates a new BufferPoolItem
type BufferPoolItem ¶
BufferPoolItem represents a BufferPool item
func (*BufferPoolItem) Close ¶
func (i *BufferPoolItem) Close() error
Close implements the io.Closer interface
type BytesIterator ¶
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 ¶
func NewBytesIterator(bs []byte) *BytesIterator
NewBytesIterator creates a new BytesIterator
func (*BytesIterator) Dump ¶
func (i *BytesIterator) Dump() (bs []byte)
Dump dumps the rest of the slice
func (*BytesIterator) HasBytesLeft ¶
func (i *BytesIterator) HasBytesLeft() bool
HasBytesLeft checks whether there are bytes left
func (*BytesIterator) NextByte ¶
func (i *BytesIterator) NextByte() (b byte, err error)
NextByte returns the next byte
func (*BytesIterator) NextBytes ¶
func (i *BytesIterator) NextBytes(n int) (bs []byte, err error)
NextBytes returns the n next bytes
func (*BytesIterator) NextBytesNoCopy ¶
func (i *BytesIterator) NextBytesNoCopy(n int) (bs []byte, err error)
NextBytesNoCopy returns the n next bytes Be careful with this function as it doesn't make a copy of returned data. bs will point to internal BytesIterator buffer. If you need to modify returned bytes or store it for some time, use NextBytes instead
func (*BytesIterator) Skip ¶
func (i *BytesIterator) Skip(n int)
Skip skips the n previous/next bytes
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache is an object capable of caching stuff while ensuring cumulated cached size never gets above a provided threshold
func NewCache ¶
func NewCache(o CacheOptions) *Cache
type CacheOptions ¶
type CacheOptions struct { // - 0 disables cache // - < 0 disables max size MaxSize int }
type Chan ¶
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
func (*Chan) Start ¶
Start starts the chan by looping through functions in the buffer and executing them if any, or waiting for a new one otherwise
func (*Chan) StatOptions ¶
func (c *Chan) StatOptions() []StatOptions
StatOptions returns the chan stat options
type ChanOptions ¶
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 CloseFuncWithError ¶
type CloseFuncWithError func() error
type Closer ¶
type Closer struct {
// contains filtered or unexported fields
}
Closer is an object that can close several things
func (*Closer) AddWithError ¶
func (c *Closer) AddWithError(f CloseFuncWithError)
func (*Closer) Do ¶
func (c *Closer) Do(fn func())
Do executes a callback while ensuring :
- closer hasn't been closed before
- closer can't be closed in between
func (*Closer) OnClosed ¶
func (c *Closer) OnClosed(fn CloserOnClosed)
type CloserOnClosed ¶
type CloserOnClosed func(err error)
type CompleteLogger ¶
type CompleteLogger interface { SeverityCtxLogger SeverityLogger SeverityWriteLogger SeverityWriteCtxLogger StdLogger }
CompleteLogger represents a complete logger
func AdaptStdLogger ¶
func AdaptStdLogger(i StdLogger) CompleteLogger
AdaptStdLogger transforms an StdLogger into a CompleteLogger if needed
func AdaptTestLogger ¶
func AdaptTestLogger(i TestLogger) CompleteLogger
AdaptTestLogger transforms a TestLogger into a CompleteLogger if needed
type CopyFileFunc ¶
type CopyFileFunc func(ctx context.Context, dst string, srcStat os.FileInfo, srcFile *os.File) error
CopyFileFunc represents a CopyFile func
func SSHCopyFileFunc ¶
func SSHCopyFileFunc(fn SSHSessionFunc) CopyFileFunc
SSHCopyFileFunc is the SSH CopyFileFunc that allows doing SSH copies
type CtxReader ¶
type CtxReader struct {
// contains filtered or unexported fields
}
CtxReader represents a reader with a context
func NewCtxReader ¶
NewCtxReader creates a reader with a context
type DebugMutex ¶
type DebugMutex struct {
// contains filtered or unexported fields
}
DebugMutex represents a rwmutex capable of logging its actions to ease deadlock debugging
func NewDebugMutex ¶
func NewDebugMutex(name string, l StdLogger, opts ...DebugMutexOpt) *DebugMutex
NewDebugMutex creates a new debug mutex
type DebugMutexOpt ¶
type DebugMutexOpt func(m *DebugMutex)
DebugMutexOpt represents a debug mutex option
func DebugMutexWithDeadlockDetection ¶
func DebugMutexWithDeadlockDetection(timeout time.Duration) DebugMutexOpt
DebugMutexWithDeadlockDetection allows detecting deadlock for all mutex locks
func DebugMutexWithLockLogging ¶
func DebugMutexWithLockLogging(ll LoggerLevel) DebugMutexOpt
DebugMutexWithLockLogging allows logging all mutex locks
type Errors ¶
type Errors struct {
// contains filtered or unexported fields
}
Errors is an error containing multiple errors
type EventHandler ¶
type EventManager ¶
type EventManager struct {
// contains filtered or unexported fields
}
func NewEventManager ¶
func NewEventManager() *EventManager
func (*EventManager) Emit ¶
func (m *EventManager) Emit(n EventName, payload any)
func (*EventManager) Off ¶
func (m *EventManager) Off(id uint64)
func (*EventManager) On ¶
func (m *EventManager) On(n EventName, h EventHandler) uint64
type Eventer ¶
type Eventer struct {
// contains filtered or unexported fields
}
Eventer represents an object that can dispatch simple events (name + payload)
func (*Eventer) On ¶
func (e *Eventer) On(name string, h EventerHandler)
On adds an handler for a specific name
type EventerHandler ¶
type EventerHandler func(payload any)
EventerHandler represents a function that can handle the payload of an event
type EventerOptions ¶
type EventerOptions struct {
Chan ChanOptions
}
EventerOptions represents Eventer options
type ExecCmdOptions ¶
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 ¶
type ExecHandler struct {
// contains filtered or unexported fields
}
ExecHandler represents an object capable of handling the execution of a cmd
func ExecCmd ¶
func ExecCmd(w *Worker, o ExecCmdOptions) (h *ExecHandler, err error)
ExecCmd executes a cmd The process will be stopped when the worker stops
type FIFOMutex ¶
type FIFOMutex struct {
// contains filtered or unexported fields
}
FIFOMutex is a mutex guaranteeing FIFO order
type FlagStrings ¶
FlagStrings represents a flag that can be set several times and stores unique string values
func (FlagStrings) Set ¶
func (f FlagStrings) Set(i string) error
Set implements the flag.Value interface
func (FlagStrings) String ¶
func (f FlagStrings) String() string
String implements the flag.Value interface
type GoroutineLimiter ¶
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 ¶
func NewGoroutineLimiter(o GoroutineLimiterOptions) (l *GoroutineLimiter)
NewGoroutineLimiter creates a new GoroutineLimiter
func (*GoroutineLimiter) Close ¶
func (l *GoroutineLimiter) Close() error
Close closes the limiter properly
func (*GoroutineLimiter) Do ¶
func (l *GoroutineLimiter) Do(fn GoroutineLimiterFunc) (err error)
Do executes custom work in a goroutine
type GoroutineLimiterFunc ¶
type GoroutineLimiterFunc func()
GoroutineLimiterFunc is a GoroutineLimiter func
type GoroutineLimiterOptions ¶
type GoroutineLimiterOptions struct {
Max int
}
GoroutineLimiterOptions represents GoroutineLimiter options
type HTTPClient ¶
HTTPClient represents an HTTP client
type HTTPDownloader ¶
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 ¶
func NewHTTPDownloader(o HTTPDownloaderOptions) (d *HTTPDownloader)
NewHTTPDownloader creates a new HTTPDownloader
func (*HTTPDownloader) Close ¶
func (d *HTTPDownloader) Close() error
Close closes the downloader properly
func (*HTTPDownloader) DownloadInDirectory ¶
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 ¶
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 ¶
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 ¶
type HTTPDownloaderOptions struct { Limiter GoroutineLimiterOptions ResponseFunc HTTPResponseFunc Sender HTTPSenderOptions }
HTTPDownloaderOptions represents HTTPDownloader options
type HTTPDownloaderSrc ¶
type HTTPMiddleware ¶
HTTPMiddleware represents an HTTP middleware
func HTTPMiddlewareBasicAuth ¶
func HTTPMiddlewareBasicAuth(username, password string) HTTPMiddleware
HTTPMiddlewareBasicAuth adds basic HTTP auth to an HTTP handler
func HTTPMiddlewareCORSHeaders ¶
func HTTPMiddlewareCORSHeaders() HTTPMiddleware
HTTPMiddlewareCORSHeaders adds CORS headers to an HTTP handler
func HTTPMiddlewareContentType ¶
func HTTPMiddlewareContentType(contentType string) HTTPMiddleware
HTTPMiddlewareContentType adds a content type to an HTTP handler
func HTTPMiddlewareHeaders ¶
func HTTPMiddlewareHeaders(vs map[string]string) HTTPMiddleware
HTTPMiddlewareHeaders adds headers to an HTTP handler
type HTTPResponseFunc ¶
HTTPResponseFunc is a func that can process an $http.Response
type HTTPSendJSONOptions ¶
type HTTPSendJSONOptions struct { BodyError any BodyIn any BodyOut any Context context.Context HeadersIn map[string]string HeadersOut HTTPSenderHeaderFunc Host string Method string StatusCodeFunc HTTPSenderStatusCodeFunc Timeout time.Duration URL string }
HTTPSendJSONOptions represents SendJSON options
type HTTPSender ¶
type HTTPSender struct {
// contains filtered or unexported fields
}
HTTPSender represents an object capable of sending http requests
func NewHTTPSender ¶
func NewHTTPSender(o HTTPSenderOptions) (s *HTTPSender)
NewHTTPSender creates a new HTTP sender
func (*HTTPSender) SendJSON ¶
func (s *HTTPSender) SendJSON(o HTTPSendJSONOptions) (err error)
SendJSON sends a new JSON HTTP request
func (*HTTPSender) SendWithTimeout ¶
func (s *HTTPSender) SendWithTimeout(req *http.Request, timeout time.Duration) (*http.Response, error)
SendWithTimeout sends a new *http.Request with a timeout
type HTTPSenderHeaderFunc ¶
type HTTPSenderOptions ¶
type HTTPSenderOptions struct { Client HTTPClient Logger StdLogger RetryFunc HTTPSenderRetryFunc RetryMax int RetrySleep time.Duration Timeout time.Duration }
HTTPSenderOptions represents HTTPSender options
type HTTPSenderRetryFunc ¶
HTTPSenderRetryFunc is a function that decides whether to retry an HTTP request
type Limiter ¶
type Limiter struct {
// contains filtered or unexported fields
}
Limiter represents a limiter
type LimiterBucket ¶
type LimiterBucket struct {
// contains filtered or unexported fields
}
LimiterBucket represents a limiter bucket
type LoggerLevel ¶
type LoggerLevel int
LoggerLevel represents a logger level
const ( LoggerLevelDebug LoggerLevel = iota LoggerLevelInfo LoggerLevelWarn LoggerLevelError LoggerLevelFatal )
Logger levels
func LoggerLevelFromString ¶
func LoggerLevelFromString(s string) LoggerLevel
LoggerLevelFromString creates a logger level from string
func (LoggerLevel) MarshalText ¶
func (l LoggerLevel) MarshalText() ([]byte, error)
func (LoggerLevel) String ¶
func (l LoggerLevel) String() string
func (*LoggerLevel) UnmarshalText ¶
func (l *LoggerLevel) UnmarshalText(b []byte) error
type PCMChannelsConverter ¶
type PCMChannelsConverter struct {
// contains filtered or unexported fields
}
PCMChannelsConverter is an object of converting PCM's channels
func NewPCMChannelsConverter ¶
func NewPCMChannelsConverter(srcNumChannels, dstNumChannels int, fn PCMSampleFunc) *PCMChannelsConverter
NewPCMChannelsConverter creates a new PCMChannelsConverter
func (*PCMChannelsConverter) Add ¶
func (c *PCMChannelsConverter) Add(i int) (err error)
Add adds a new sample to the converter
func (*PCMChannelsConverter) Reset ¶
func (c *PCMChannelsConverter) Reset()
Reset resets the converter
type PCMSampleFunc ¶
PCMSampleFunc is a func that can process a sample
type PCMSampleRateConverter ¶
type PCMSampleRateConverter struct {
// contains filtered or unexported fields
}
PCMSampleRateConverter is an object capable of converting a PCM's sample rate
func NewPCMSampleRateConverter ¶
func NewPCMSampleRateConverter(srcSampleRate, dstSampleRate, numChannels int, fn PCMSampleFunc) *PCMSampleRateConverter
NewPCMSampleRateConverter creates a new PCMSampleRateConverter
func (*PCMSampleRateConverter) Add ¶
func (c *PCMSampleRateConverter) Add(i int) (err error)
Add adds a new sample to the converter
func (*PCMSampleRateConverter) Reset ¶
func (c *PCMSampleRateConverter) Reset()
Reset resets the converter
type PCMSilenceDetector ¶
type PCMSilenceDetector struct {
// contains filtered or unexported fields
}
PCMSilenceDetector represents a PCM silence detector
func NewPCMSilenceDetector ¶
func NewPCMSilenceDetector(o PCMSilenceDetectorOptions) (d *PCMSilenceDetector)
NewPCMSilenceDetector creates a new silence detector
func (*PCMSilenceDetector) Add ¶
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 ¶
func (d *PCMSilenceDetector) Reset()
Reset resets the silence detector
type PCMSilenceDetectorOptions ¶
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 Piper ¶
type Piper struct {
// contains filtered or unexported fields
}
Piper doesn't block on writes. It will block on reads unless you provide a ReadTimeout in which case it will return an optional error, after the provided timeout, if no read is available. When closing the piper, it will interrupt any ongoing read/future writes and return io.EOF. Piper doesn't handle multiple readers at the same time.
func NewPiper ¶
func NewPiper(o PiperOptions) *Piper
type PiperOptions ¶
type Rational ¶
type Rational struct {
// contains filtered or unexported fields
}
Rational represents a rational
func (*Rational) MarshalText ¶
MarshalText implements the TextMarshaler interface
func (*Rational) UnmarshalText ¶
UnmarshalText implements the TextUnmarshaler interface
type SSHSession ¶
type SSHSession interface { Run(string) error Start(string) error StdinPipe() (io.WriteCloser, error) Wait() error }
SSHSession represents an SSH Session
type SSHSessionFunc ¶
type SSHSessionFunc func() (s SSHSession, c *Closer, err error)
SSHSessionFunc represents a func that can return an SSHSession
type ServeHTTPOptions ¶
ServeHTTPOptions represents serve options
type SeverityCtxLogger ¶
type SeverityCtxLogger interface { DebugC(ctx context.Context, v ...any) DebugCf(ctx context.Context, format string, v ...any) ErrorC(ctx context.Context, v ...any) ErrorCf(ctx context.Context, format string, v ...any) FatalC(ctx context.Context, v ...any) FatalCf(ctx context.Context, format string, v ...any) InfoC(ctx context.Context, v ...any) InfoCf(ctx context.Context, format string, v ...any) WarnC(ctx context.Context, v ...any) WarnCf(ctx context.Context, format string, v ...any) }
SeverityCtxLogger represents a severity with context logger
type SeverityLogger ¶
type SeverityLogger interface { Debug(v ...any) Debugf(format string, v ...any) Error(v ...any) Errorf(format string, v ...any) Info(v ...any) Infof(format string, v ...any) Warn(v ...any) Warnf(format string, v ...any) }
SeverityLogger represents a severity logger
type SeverityWriteCtxLogger ¶
type SeverityWriteCtxLogger interface { WriteC(ctx context.Context, l LoggerLevel, v ...any) WriteCf(ctx context.Context, l LoggerLevel, format string, v ...any) }
type SeverityWriteLogger ¶
type SeverityWriteLogger interface { Write(l LoggerLevel, v ...any) Writef(l LoggerLevel, format string, v ...any) }
type SignalHandler ¶
SignalHandler represents a func that can handle a signal
func LoggerSignalHandler ¶
func LoggerSignalHandler(l SeverityLogger, ignoredSignals ...os.Signal) SignalHandler
LoggerSignalHandler returns a SignalHandler that logs the signal
func TermSignalHandler ¶
func TermSignalHandler(f func()) SignalHandler
TermSignalHandler returns a SignalHandler that is executed only on a term signal
type SortInt64Slice ¶
type SortInt64Slice []int64
SortInt64Slice attaches the methods of Interface to []int64, sorting in increasing order.
func (SortInt64Slice) Len ¶
func (p SortInt64Slice) Len() int
func (SortInt64Slice) Less ¶
func (p SortInt64Slice) Less(i, j int) bool
func (SortInt64Slice) Swap ¶
func (p SortInt64Slice) Swap(i, j int)
type SortUint64Slice ¶
type SortUint64Slice []uint64
SortUint64Slice attaches the methods of Interface to []uint64, sorting in increasing order.
func (SortUint64Slice) Len ¶
func (p SortUint64Slice) Len() int
func (SortUint64Slice) Less ¶
func (p SortUint64Slice) Less(i, j int) bool
func (SortUint64Slice) Swap ¶
func (p SortUint64Slice) Swap(i, j int)
type StatMetadata ¶
StatMetadata represents a stat metadata
type StatOptions ¶
type StatOptions struct { Metadata *StatMetadata // Either a StatValuer or StatValuerOverTime Valuer any }
StatOptions represents stat options
type StatValue ¶
type StatValue struct { *StatMetadata Value any }
StatValue represents a stat value
type StatValuer ¶
StatValuer represents a stat valuer
type StatValuerFunc ¶
type Stater ¶
type Stater struct {
// contains filtered or unexported fields
}
Stater is an object that can compute and handle stats
type StaterOptions ¶
type StaterOptions struct { HandleFunc StatsHandleFunc Period time.Duration }
StaterOptions represents stater options
type StatsHandleFunc ¶
type StatsHandleFunc func(stats []StatValue)
StatsHandleFunc is a method that can handle stat values
type StdLogger ¶
type StdLogger interface { Fatal(v ...any) Fatalf(format string, v ...any) Print(v ...any) Printf(format string, v ...any) }
StdLogger represents a standard logger
type Stopwatch ¶
type Stopwatch struct {
// contains filtered or unexported fields
}
func NewStopwatch ¶
func NewStopwatch() *Stopwatch
func (Stopwatch) MarshalJSON ¶
func (*Stopwatch) UnmarshalJSON ¶
type TaskFunc ¶
type TaskFunc func() *Task
TaskFunc represents a function that can create a new task
type Templater ¶
type Templater struct {
// contains filtered or unexported fields
}
Templater represents an object capable of storing and parsing templates
func (*Templater) AddLayoutsFromDir ¶
AddLayoutsFromDir walks through a dir and add files as layouts
func (*Templater) AddTemplate ¶
AddTemplate adds a new template
func (*Templater) AddTemplatesFromDir ¶
AddTemplatesFromDir walks through a dir and add files as templates
func (*Templater) DelTemplate ¶
DelTemplate deletes a template
type TestLogger ¶
type Timestamp ¶
func NewTimestamp ¶
func (Timestamp) MarshalJSON ¶
func (Timestamp) MarshalText ¶
func (*Timestamp) UnmarshalJSON ¶
func (*Timestamp) UnmarshalText ¶
type TimestampNano ¶
func NewTimestampNano ¶
func NewTimestampNano(t time.Time) *TimestampNano
func (TimestampNano) MarshalJSON ¶
func (t TimestampNano) MarshalJSON() ([]byte, error)
func (TimestampNano) MarshalText ¶
func (t TimestampNano) MarshalText() (text []byte, err error)
func (*TimestampNano) UnmarshalJSON ¶
func (t *TimestampNano) UnmarshalJSON(text []byte) error
func (*TimestampNano) UnmarshalText ¶
func (t *TimestampNano) UnmarshalText(text []byte) (err error)
type Translator ¶
type Translator struct {
// contains filtered or unexported fields
}
Translator represents an object capable of translating stuff
func NewTranslator ¶
func NewTranslator(o TranslatorOptions) (t *Translator)
NewTranslator creates a new Translator
func (*Translator) HTTPMiddleware ¶
func (t *Translator) HTTPMiddleware(h http.Handler) http.Handler
HTTPMiddleware is the Translator HTTP middleware
func (*Translator) LanguageCtx ¶
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 ¶
func (t *Translator) ParseDir(dirPath string) (err error)
ParseDir adds translations located in ".json" files in the specified dir If ".json" files are located in child dirs, keys will be prefixed with their paths
func (*Translator) ParseFile ¶
func (t *Translator) ParseFile(dirPath, path string) (err error)
ParseFile adds translation located in the provided path
func (*Translator) Translate ¶
func (t *Translator) Translate(language, key string) string
Translate translates a key into a specific language
func (*Translator) TranslateC ¶
func (t *Translator) TranslateC(ctx context.Context, key string) string
TranslateC translates a key using the language specified in the context
func (*Translator) TranslateCf ¶
func (*Translator) TranslateCtx ¶
func (t *Translator) TranslateCtx(ctx context.Context, key string) string
TranslateCtx is an alias for TranslateC
func (*Translator) Translatef ¶
func (t *Translator) Translatef(language, key string, args ...any) string
Translatef translates a key into a specific language with optional formatting args
type TranslatorOptions ¶
TranslatorOptions represents Translator options
type Worker ¶
type Worker struct {
// contains filtered or unexported fields
}
Worker represents an object capable of blocking, handling signals and stopping
func (*Worker) HandleSignals ¶
func (w *Worker) HandleSignals(hs ...SignalHandler)
HandleSignals handles signals
type WorkerOptions ¶
type WorkerOptions struct {
Logger StdLogger
}
WorkerOptions represents worker options
type WriterAdapter ¶
type WriterAdapter struct {
// contains filtered or unexported fields
}
WriterAdapter represents an object that can adapt a Writer
func NewWriterAdapter ¶
func NewWriterAdapter(o WriterAdapterOptions) *WriterAdapter
NewWriterAdapter creates a new WriterAdapter
func (*WriterAdapter) Close ¶
func (w *WriterAdapter) Close() error
Close closes the adapter properly
type WriterAdapterOptions ¶
WriterAdapterOptions represents WriterAdapter options