Versions in this module Expand all Collapse all v1 v1.0.0 Feb 20, 2021 Changes in this version + const ChanAddStrategyBlockWhenStarted + const ChanAddStrategyNoBlock + const ChanOrderFIFO + const ChanOrderFILO + const ExecStatusCrashed + const ExecStatusRunning + const ExecStatusStopped + const StatNameWorkRatio + var DefaultDirMode os.FileMode = 0755 + var ErrHTTPSenderUnmarshaledError = errors.New("astikit: unmarshaled error") + 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 StrSlicePtr(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 struct + func NewBiMap() *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 struct + func NewBitsWriter(o BitsWriterOptions) (w *BitsWriter) + func (w *BitsWriter) SetWriteCallback(cb BitsWriterWriteCallback) + func (w *BitsWriter) Write(i interface{}) error + func (w *BitsWriter) WriteN(i interface{}, n int) error + type BitsWriterBatch struct + func NewBitsWriterBatch(w *BitsWriter) BitsWriterBatch + func (b *BitsWriterBatch) Err() error + func (b *BitsWriterBatch) Write(i interface{}) + func (b *BitsWriterBatch) WriteN(i interface{}, n int) + type BitsWriterOptions struct + ByteOrder binary.ByteOrder + WriteCallback BitsWriterWriteCallback + Writer io.Writer + type BitsWriterWriteCallback func([]byte) + type BufferPool struct + func NewBufferPool() *BufferPool + func (p *BufferPool) New() *BufferPoolItem + type BufferPoolItem struct + func (i *BufferPoolItem) Close() error + type BytesIterator struct + func NewBytesIterator(bs []byte) *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 struct + func NewChan(o ChanOptions) *Chan + func (c *Chan) Add(i func()) + func (c *Chan) Reset() + func (c *Chan) Start(ctx context.Context) + func (c *Chan) Stats() []StatOptions + func (c *Chan) Stop() + type ChanOptions struct + AddStrategy string + Order string + ProcessAll bool + type CloseFunc func() error + type Closer struct + func NewCloser() *Closer + func (c *Closer) Add(f CloseFunc) + func (c *Closer) Close() error + func (c *Closer) NewChild() (child *Closer) + type CompleteLogger interface + func AdaptStdLogger(i StdLogger) CompleteLogger + type CopyFileFunc func(ctx context.Context, dst string, srcStat os.FileInfo, srcFile *os.File) error + func SSHCopyFileFunc(fn SSHSessionFunc) CopyFileFunc + type CounterAvgStat struct + func NewCounterAvgStat() *CounterAvgStat + func (s CounterAvgStat) Add(delta float64) + func (s CounterAvgStat) Start() + func (s CounterAvgStat) Stop() + func (s CounterAvgStat) Value(delta time.Duration) interface{} + type CounterRateStat struct + func NewCounterRateStat() *CounterRateStat + func (s CounterRateStat) Add(delta float64) + func (s CounterRateStat) Start() + func (s CounterRateStat) Stop() + func (s CounterRateStat) Value(delta time.Duration) interface{} + type CtxReader struct + func NewCtxReader(ctx context.Context, r io.Reader) *CtxReader + func (r *CtxReader) Read(p []byte) (n int, err error) + type DurationPercentageStat struct + func NewDurationPercentageStat() *DurationPercentageStat + func (s DurationPercentageStat) Begin() + func (s DurationPercentageStat) End() + func (s DurationPercentageStat) Start() + func (s DurationPercentageStat) Stop() + func (s DurationPercentageStat) Value(delta time.Duration) (o interface{}) + type Errors struct + func NewErrors(errs ...error) *Errors + func (errs *Errors) Add(err error) + func (errs *Errors) Error() string + func (errs *Errors) IsNil() bool + func (errs *Errors) Loop(fn func(idx int, err error) bool) + type Eventer struct + func NewEventer(o EventerOptions) *Eventer + func (e *Eventer) Dispatch(name string, payload interface{}) + func (e *Eventer) On(name string, h EventerHandler) + func (e *Eventer) Reset() + func (e *Eventer) Start(ctx context.Context) + func (e *Eventer) Stop() + type EventerHandler func(payload interface{}) + type EventerOptions struct + Chan ChanOptions + type ExecCmdOptions struct + Args []string + CmdAdapter func(cmd *exec.Cmd, h *ExecHandler) error + Name string + StopFunc func(cmd *exec.Cmd) error + type ExecHandler struct + func ExecCmd(w *Worker, o ExecCmdOptions) (h *ExecHandler, err error) + func (h *ExecHandler) Status() string + func (h *ExecHandler) Stop() + type FlagStrings struct + Map map[string]bool + Slice *[]string + func NewFlagStrings() FlagStrings + func (f FlagStrings) Set(i string) error + func (f FlagStrings) String() string + type GoroutineLimiter struct + func NewGoroutineLimiter(o GoroutineLimiterOptions) (l *GoroutineLimiter) + func (l *GoroutineLimiter) Close() error + func (l *GoroutineLimiter) Do(fn GoroutineLimiterFunc) (err error) + type GoroutineLimiterFunc func() + type GoroutineLimiterOptions struct + Max int + type HTTPClient interface + Do func(req *http.Request) (*http.Response, error) + type HTTPDownloader struct + func NewHTTPDownloader(o HTTPDownloaderOptions) (d *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 struct + Limiter GoroutineLimiterOptions + ResponseFunc HTTPResponseFunc + Sender HTTPSenderOptions + type HTTPDownloaderSrc struct + Body io.Reader + Header http.Header + Method string + URL string + type HTTPMiddleware func(http.Handler) http.Handler + func HTTPMiddlewareBasicAuth(username, password string) HTTPMiddleware + func HTTPMiddlewareCORSHeaders() HTTPMiddleware + func HTTPMiddlewareContentType(contentType string) HTTPMiddleware + func HTTPMiddlewareHeaders(vs map[string]string) HTTPMiddleware + type HTTPResponseFunc func(resp *http.Response) error + type HTTPSendJSONOptions struct + BodyError interface{} + BodyIn interface{} + BodyOut interface{} + Headers map[string]string + Method string + URL string + type HTTPSender struct + func NewHTTPSender(o HTTPSenderOptions) (s *HTTPSender) + func (s *HTTPSender) Send(req *http.Request) (*http.Response, error) + func (s *HTTPSender) SendJSON(o HTTPSendJSONOptions) (err error) + func (s *HTTPSender) SendWithTimeout(req *http.Request, timeout time.Duration) (resp *http.Response, err error) + type HTTPSenderOptions struct + Client HTTPClient + Logger StdLogger + RetryFunc HTTPSenderRetryFunc + RetryMax int + RetrySleep time.Duration + Timeout time.Duration + type HTTPSenderRetryFunc func(resp *http.Response) error + type Limiter struct + func NewLimiter() *Limiter + func (l *Limiter) Add(name string, cap int, period time.Duration) *LimiterBucket + func (l *Limiter) Bucket(name string) (b *LimiterBucket, ok bool) + func (l *Limiter) Close() + type LimiterBucket struct + func (b *LimiterBucket) Close() + func (b *LimiterBucket) Inc() bool + type PCMChannelsConverter struct + func NewPCMChannelsConverter(srcNumChannels, dstNumChannels int, fn PCMSampleFunc) *PCMChannelsConverter + func (c *PCMChannelsConverter) Add(i int) (err error) + func (c *PCMChannelsConverter) Reset() + type PCMSampleFunc func(s int) error + type PCMSampleRateConverter struct + func NewPCMSampleRateConverter(srcSampleRate, dstSampleRate, numChannels int, fn PCMSampleFunc) *PCMSampleRateConverter + func (c *PCMSampleRateConverter) Add(i int) (err error) + func (c *PCMSampleRateConverter) Reset() + type PCMSilenceDetector struct + func NewPCMSilenceDetector(o PCMSilenceDetectorOptions) (d *PCMSilenceDetector) + func (d *PCMSilenceDetector) Add(samples []int) (validSamples [][]int) + func (d *PCMSilenceDetector) Reset() + type PCMSilenceDetectorOptions struct + MaxSilenceLevel float64 + MinSilenceDuration time.Duration + SampleRate int + StepDuration time.Duration + type PadOption func(p *bytesPadder) + type RWMutex struct + func NewRWMutex(o RWMutexOptions) *RWMutex + func (m *RWMutex) IsDeadlocked(timeout time.Duration) (bool, string) + func (m *RWMutex) Lock() + func (m *RWMutex) RLock() + func (m *RWMutex) RUnlock() + func (m *RWMutex) Unlock() + type RWMutexOptions struct + Logger StdLogger + Name string + type Rational struct + func NewRational(num, den int) *Rational + func (r *Rational) Den() int + func (r *Rational) MarshalText() (b []byte, err error) + func (r *Rational) Num() int + func (r *Rational) ToFloat64() float64 + func (r *Rational) UnmarshalText(b []byte) (err error) + type SSHSession interface + Run func(string) error + Start func(string) error + StdinPipe func() (io.WriteCloser, error) + Wait func() error + type SSHSessionFunc func() (s SSHSession, c *Closer, err error) + type ServeHTTPOptions struct + Addr string + Handler http.Handler + type SeverityCtxLogger interface + DebugC func(ctx context.Context, v ...interface{}) + DebugCf func(ctx context.Context, format string, v ...interface{}) + ErrorC func(ctx context.Context, v ...interface{}) + ErrorCf func(ctx context.Context, format string, v ...interface{}) + FatalC func(ctx context.Context, v ...interface{}) + FatalCf func(ctx context.Context, format string, v ...interface{}) + InfoC func(ctx context.Context, v ...interface{}) + InfoCf func(ctx context.Context, format string, v ...interface{}) + WarnC func(ctx context.Context, v ...interface{}) + WarnCf func(ctx context.Context, format string, v ...interface{}) + type SeverityLogger interface + Debug func(v ...interface{}) + Debugf func(format string, v ...interface{}) + Error func(v ...interface{}) + Errorf func(format string, v ...interface{}) + Info func(v ...interface{}) + Infof func(format string, v ...interface{}) + Warn func(v ...interface{}) + Warnf func(format string, v ...interface{}) + type SignalHandler func(s os.Signal) + func LoggerSignalHandler(l SeverityLogger, ignoredSignals ...os.Signal) SignalHandler + func TermSignalHandler(f func()) SignalHandler + type SortInt64Slice []int64 + func (p SortInt64Slice) Len() int + func (p SortInt64Slice) Less(i, j int) bool + func (p SortInt64Slice) Swap(i, j int) + type StatHandler interface + Start func() + Stop func() + Value func(delta time.Duration) interface{} + type StatMetadata struct + Description string + Label string + Name string + Unit string + type StatOptions struct + Handler StatHandler + Metadata *StatMetadata + type StatValue struct + Value interface{} + type Stater struct + func NewStater(o StaterOptions) *Stater + func (s *Stater) AddStats(os ...StatOptions) + func (s *Stater) DelStats(os ...StatOptions) + func (s *Stater) Start(ctx context.Context) + func (s *Stater) Stop() + type StaterOptions struct + HandleFunc StatsHandleFunc + Period time.Duration + type StatsHandleFunc func(stats []StatValue) + type StdLogger interface + Fatal func(v ...interface{}) + Fatalf func(format string, v ...interface{}) + Print func(v ...interface{}) + Printf func(format string, v ...interface{}) + type Task struct + func (t *Task) Do(f func()) + func (t *Task) Done() + func (t *Task) NewSubTask() *Task + func (t *Task) Wait() + type TaskFunc func() *Task + type Templater struct + func NewTemplater() *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 struct + func NewTimestamp(t time.Time) *Timestamp + func (t *Timestamp) UnmarshalJSON(text []byte) error + func (t *Timestamp) UnmarshalText(text []byte) (err error) + func (t Timestamp) MarshalJSON() ([]byte, error) + func (t Timestamp) MarshalText() (text []byte, err error) + type Translator struct + func NewTranslator(o TranslatorOptions) *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 struct + DefaultLanguage string + type Worker struct + func NewWorker(o WorkerOptions) (w *Worker) + func (w *Worker) Context() context.Context + func (w *Worker) HandleSignals(hs ...SignalHandler) + func (w *Worker) Logger() SeverityLogger + func (w *Worker) NewTask() *Task + func (w *Worker) Stop() + func (w *Worker) Wait() + type WorkerOptions struct + Logger StdLogger + type WriterAdapter struct + func NewWriterAdapter(o WriterAdapterOptions) *WriterAdapter + func (w *WriterAdapter) Close() error + func (w *WriterAdapter) Write(i []byte) (n int, err error) + type WriterAdapterOptions struct + Callback func(i []byte) + Split []byte