utils

package
v0.0.0-...-6a3944b Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultArgs int
View Source
var ErrCanceledDuringDrain = errors.New("[chotki] drain was canceled during draining")
View Source
var ErrClosed = errors.New("[chotki] feed/drain queue is closed")
View Source
var ErrOverflow = errors.New("[chotki] feed/drain queue is overflowed")

Functions

This section is empty.

Types

type AvgVal

type AvgVal struct {
	// contains filtered or unexported fields
}

func NewAvgVal

func NewAvgVal(val float64) *AvgVal

func (*AvgVal) Add

func (a *AvgVal) Add(val float64)

func (*AvgVal) Val

func (a *AvgVal) Val() float64

type DefaultLogger

type DefaultLogger struct {
	// contains filtered or unexported fields
}

func NewDefaultLogger

func NewDefaultLogger(level slog.Level) *DefaultLogger

func (*DefaultLogger) Debug

func (d *DefaultLogger) Debug(msg string, args ...any)

func (*DefaultLogger) DebugCtx

func (d *DefaultLogger) DebugCtx(ctx context.Context, msg string, args ...any)

func (*DefaultLogger) Error

func (d *DefaultLogger) Error(msg string, args ...any)

func (*DefaultLogger) ErrorCtx

func (d *DefaultLogger) ErrorCtx(ctx context.Context, msg string, args ...any)

func (*DefaultLogger) Info

func (d *DefaultLogger) Info(msg string, args ...any)

func (*DefaultLogger) InfoCtx

func (d *DefaultLogger) InfoCtx(ctx context.Context, msg string, args ...any)

func (*DefaultLogger) Warn

func (d *DefaultLogger) Warn(msg string, args ...any)

func (*DefaultLogger) WarnCtx

func (d *DefaultLogger) WarnCtx(ctx context.Context, msg string, args ...any)

func (*DefaultLogger) WithArgsFromCtx

func (d *DefaultLogger) WithArgsFromCtx(ctx, lctx context.Context) context.Context

func (*DefaultLogger) WithDefaultArgs

func (d *DefaultLogger) WithDefaultArgs(ctx context.Context, args ...any) context.Context

type FDQueue

type FDQueue[T ~[][]byte] struct {
	// contains filtered or unexported fields
}

func NewFDQueue

func NewFDQueue[T ~[][]byte](limit int, timelimit time.Duration, batchSize int) *FDQueue[T]

func (*FDQueue[T]) Close

func (q *FDQueue[T]) Close() error

func (*FDQueue[T]) Drain

func (q *FDQueue[T]) Drain(ctx context.Context, recs T) error

func (*FDQueue[T]) Feed

func (q *FDQueue[T]) Feed(ctx context.Context) (recs T, err error)

func (*FDQueue[T]) Size

func (q *FDQueue[T]) Size() int

type Heap

type Heap[T constraints.Ordered] struct {
	// contains filtered or unexported fields
}

func (Heap[T]) Fix

func (h Heap[T]) Fix(i int)

Fix re-establishes the heap ordering after the element at index i has changed its value. Changing the value of the element at index i and then calling Fix is equivalent to, but less expensive than, calling Remove(h, i) followed by a Push of the new value. The complexity is O(log n) where n = h.Len().

func (*Heap[T]) Len

func (h *Heap[T]) Len() int

func (*Heap[T]) Pop

func (h *Heap[T]) Pop() (min T)

Pop removes and returns the minimum element (according to Less) from the heap. The complexity is O(log n) where n = h.Len(). Pop is equivalent to Remove(h, 0).

func (*Heap[T]) Push

func (h *Heap[T]) Push(x T)

Push pushes the element x onto the heap. The complexity is O(log n) where n = h.Len().

func (*Heap[T]) Remove

func (h *Heap[T]) Remove(i int) T

Remove removes and returns the element at index i from the heap. The complexity is O(log n) where n = h.Len().

type Logger

type Logger interface {
	Debug(msg string, args ...any)
	Info(msg string, args ...any)
	Warn(msg string, args ...any)
	Error(msg string, args ...any)
	DebugCtx(ctx context.Context, msg string, args ...any)
	InfoCtx(ctx context.Context, msg string, args ...any)
	WarnCtx(ctx context.Context, msg string, args ...any)
	ErrorCtx(ctx context.Context, msg string, args ...any)
	WithDefaultArgs(ctx context.Context, args ...any) context.Context
	WithArgsFromCtx(ctx, lctx context.Context) context.Context
}

Jump to

Keyboard shortcuts

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