utilds

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Errorf

func Errorf(code string, format string, args ...interface{}) error

Errorf creates a formatted error wrapped in a CodedError. This is a convenience function that combines fmt.Errorf with MakeCodedError.

func GetErrorCode

func GetErrorCode(err error) string

GetErrorCode extracts the error code from anywhere in the error chain. Returns empty string if no CodedError is found.

Types

type CodedError

type CodedError struct {
	Code string
	Err  error
}

CodedError wraps an error with a string code for categorization. The code can be extracted from anywhere in an error chain using GetErrorCode.

func MakeCodedError

func MakeCodedError(code string, err error) CodedError

MakeCodedError creates a new CodedError with the given code and error.

func (CodedError) Error

func (e CodedError) Error() string

func (CodedError) Unwrap

func (e CodedError) Unwrap() error

type IdList

type IdList[T any] struct {
	// contains filtered or unexported fields
}

func (*IdList[T]) GetList

func (il *IdList[T]) GetList() []T

func (*IdList[T]) Register

func (il *IdList[T]) Register(val T) string

func (*IdList[T]) RegisterWithId

func (il *IdList[T]) RegisterWithId(id string, val T)

func (*IdList[T]) Unregister

func (il *IdList[T]) Unregister(id string)

type MultiReaderLineBuffer

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

func MakeMultiReaderLineBuffer

func MakeMultiReaderLineBuffer(maxLines int) *MultiReaderLineBuffer

func (*MultiReaderLineBuffer) AddLine

func (mrlb *MultiReaderLineBuffer) AddLine(line string)

func (*MultiReaderLineBuffer) GetLineCount

func (mrlb *MultiReaderLineBuffer) GetLineCount() int

func (*MultiReaderLineBuffer) GetLines

func (mrlb *MultiReaderLineBuffer) GetLines() []string

func (*MultiReaderLineBuffer) GetTotalLineCount

func (mrlb *MultiReaderLineBuffer) GetTotalLineCount() int

func (*MultiReaderLineBuffer) ReadAll

func (mrlb *MultiReaderLineBuffer) ReadAll(r io.Reader)

func (*MultiReaderLineBuffer) SetLineCallback

func (mrlb *MultiReaderLineBuffer) SetLineCallback(callback func(string))

callback is synchronous. will block the consuming of lines and guaranteed to run in order. it is also guaranteed only one callback will be running at a time (protected by the internal line lock)

type QuickReorderQueue

type QuickReorderQueue[T any] struct {
	// contains filtered or unexported fields
}

func MakeQuickReorderQueue

func MakeQuickReorderQueue[T any](bufSize int, timeout time.Duration) *QuickReorderQueue[T]

func (*QuickReorderQueue[T]) C

func (q *QuickReorderQueue[T]) C() <-chan T

func (*QuickReorderQueue[T]) Close

func (q *QuickReorderQueue[T]) Close()

func (*QuickReorderQueue[T]) QueueItem

func (q *QuickReorderQueue[T]) QueueItem(sessionId string, seqNum int, data T) error

func (*QuickReorderQueue[T]) SetNextSeqNum

func (q *QuickReorderQueue[T]) SetNextSeqNum(seqNum int)

type ReaderLineBuffer

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

func MakeReaderLineBuffer

func MakeReaderLineBuffer(reader io.Reader, maxLines int) *ReaderLineBuffer

func (*ReaderLineBuffer) GetLineCount

func (rlb *ReaderLineBuffer) GetLineCount() int

func (*ReaderLineBuffer) GetLines

func (rlb *ReaderLineBuffer) GetLines() []string

func (*ReaderLineBuffer) GetTotalLineCount

func (rlb *ReaderLineBuffer) GetTotalLineCount() int

func (*ReaderLineBuffer) IsDone

func (rlb *ReaderLineBuffer) IsDone() bool

func (*ReaderLineBuffer) ReadAll

func (rlb *ReaderLineBuffer) ReadAll()

func (*ReaderLineBuffer) ReadLine

func (rlb *ReaderLineBuffer) ReadLine() (string, error)

func (*ReaderLineBuffer) SetLineCallback

func (rlb *ReaderLineBuffer) SetLineCallback(callback func(string))

type SyncCache

type SyncCache[T any] struct {
	// contains filtered or unexported fields
}

func MakeSyncCache

func MakeSyncCache[T any](computeFn func() (T, error)) *SyncCache[T]

func (*SyncCache[T]) Get

func (sc *SyncCache[T]) Get(force bool) (T, error)

type VersionTs

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

func (*VersionTs) GetVersionTs

func (v *VersionTs) GetVersionTs() int64

type WorkQueue

type WorkQueue[T any] struct {
	// contains filtered or unexported fields
}

func NewWorkQueue

func NewWorkQueue[T any](workFn func(T)) *WorkQueue[T]

func (*WorkQueue[T]) Close

func (wq *WorkQueue[T]) Close(immediate bool)

func (*WorkQueue[T]) Enqueue

func (wq *WorkQueue[T]) Enqueue(item T) bool

func (*WorkQueue[T]) Wait

func (wq *WorkQueue[T]) Wait()

Jump to

Keyboard shortcuts

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