Documentation
¶
Index ¶
- Constants
- func BoolPtr(i bool) *bool
- func BytePtr(i byte) *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 DurationPtr(i time.Duration) *time.Duration
- func FlagCmd() (o string)
- func Float64Ptr(i float64) *float64
- func Int64Ptr(i int64) *int64
- func IntPtr(i int) *int
- func PCMLevel(samples []int) float64
- func PCMNormalize(samples []int, bitDepth int) (o []int)
- func ServeHTTP(w *Worker, o ServeHTTPOptions)
- func Sleep(ctx context.Context, d time.Duration) (err error)
- func StrPtr(i string) *string
- func UInt8Ptr(i uint8) *uint8
- func UInt32Ptr(i uint32) *uint32
- type Chan
- type ChanOptions
- type CloseFunc
- type Closer
- type CounterAvgStat
- type DurationPercentageStat
- type Errors
- type ExecCmdOptions
- type ExecHandler
- type HTTPClient
- type HTTPMiddleware
- type HTTPSender
- type HTTPSenderOptions
- type HTTPSenderRetryFunc
- type Limiter
- type LimiterBucket
- type PCMChannelsConverter
- type PCMSampleFunc
- type PCMSampleRateConverter
- type PCMSilenceDetector
- type PCMSilenceDetectorOptions
- type Rational
- type ServeHTTPOptions
- type SeverityLogger
- type SignalHandler
- 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 Worker
- type WorkerOptions
- type WriterAdapter
- type WriterAdapterOptions
Constants ¶
const ( ExecStatusCrashed = "crashed" ExecStatusRunning = "running" ExecStatusStopped = "stopped" )
Statuses
const ( ChanAddStrategyBlockWhenStarted = "block.when.started" ChanAddStrategyNoBlock = "no.block" ChanOrderFIFO = "fifo" ChanOrderFILO = "filo" )
Orders
Variables ¶
This section is empty.
Functions ¶
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 DurationPtr ¶ added in v0.0.3
DurationPtr transforms a time.Duration into a *time.Duration
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 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
func ServeHTTP ¶ added in v0.0.2
func ServeHTTP(w *Worker, o ServeHTTPOptions)
ServeHTTP spawns an HTTP server
Types ¶
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 adding new funcs is blocking.
// Possible strategies are :
// - calling Add() never blocks (default). Use the ChanAddStrategyNoBlock constant.
// - calling Add() only blocks if the chan has been started and the ctx
// has not been canceled. Use the ChanAddStrategyBlockWhenStarted constant.
AddStrategy string
// Order in which the funcs will be processed. See constants with the pattern ChanOrder*
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 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 per second
func NewCounterAvgStat ¶ added in v0.0.4
func NewCounterAvgStat() *CounterAvgStat
NewCounterAvgStat creates a new counter avg stat
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 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
func (*ExecHandler) Stop ¶ added in v0.0.2
func (h *ExecHandler) Stop()
type HTTPClient ¶ added in v0.0.4
HTTPClient represents an HTTP client
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
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
type HTTPSenderOptions ¶ added in v0.0.4
type HTTPSenderOptions struct {
Client HTTPClient
Logger StdLogger
RetryFunc HTTPSenderRetryFunc
RetryMax int
RetrySleep 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
}
func NewPCMChannelsConverter ¶ added in v0.0.3
func NewPCMChannelsConverter(srcNumChannels, dstNumChannels int, fn PCMSampleFunc) *PCMChannelsConverter
func (*PCMChannelsConverter) Add ¶ added in v0.0.3
func (c *PCMChannelsConverter) Add(i int) (err error)
func (*PCMChannelsConverter) Reset ¶ added in v0.0.3
func (c *PCMChannelsConverter) Reset()
type PCMSampleFunc ¶ added in v0.0.3
type PCMSampleRateConverter ¶ added in v0.0.3
type PCMSampleRateConverter struct {
// contains filtered or unexported fields
}
func NewPCMSampleRateConverter ¶ added in v0.0.3
func NewPCMSampleRateConverter(srcSampleRate, dstSampleRate, numChannels int, fn PCMSampleFunc) *PCMSampleRateConverter
func (*PCMSampleRateConverter) Add ¶ added in v0.0.3
func (c *PCMSampleRateConverter) Add(i int) (err error)
func (*PCMSampleRateConverter) Reset ¶ added in v0.0.3
func (c *PCMSampleRateConverter) Reset()
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 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 ServeHTTPOptions ¶ added in v0.0.2
ServeHTTPOptions represents serve options
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{})
}
func AdaptStdLogger ¶ added in v0.0.4
func AdaptStdLogger(i StdLogger) SeverityLogger
type SignalHandler ¶ added in v0.0.2
SignalHandler represents a func that can handle a 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 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{})
}
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 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()
Close closes the adapter properly
type WriterAdapterOptions ¶ added in v0.0.3
WriterAdapterOptions represents WriterAdapter options