utils

package
v0.0.0-...-116b653 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultArgs int
View Source
var ErrClosed = errors.New("[chotki] feed/drain queue is closed")

Functions

This section is empty.

Types

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[S ~[]E, E any] struct {
	// contains filtered or unexported fields
}

func NewFDQueue

func NewFDQueue[S ~[]E, E any](limit int, timelimit time.Duration, batchSize int) *FDQueue[S, E]

func (*FDQueue[S, E]) Close

func (q *FDQueue[S, E]) Close() error

func (*FDQueue[S, E]) Drain

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

func (*FDQueue[S, E]) Feed

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

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