utils

package
v0.0.0-...-f477fce Latest Latest
Warning

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

Go to latest
Published: May 27, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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) Error

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

func (*DefaultLogger) Info

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

func (*DefaultLogger) Warn

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

type FDQueue

type FDQueue[S ~[]E, E any] struct {
	// contains filtered or unexported fields
}

func NewFDQueue

func NewFDQueue[S ~[]E, E any](limit int, timeout time.Duration) *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(recs S) error

func (*FDQueue[S, E]) Feed

func (q *FDQueue[S, E]) Feed() (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)
}

Jump to

Keyboard shortcuts

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