internal

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package internal contains experimental and undecided APIs for the logging package. These APIs support internal features (e.g., QueueLogger, HTTP logging, adapter type identification) but are not part of the public github.com/happy-sdk/happy/pkg/logging API. They are subject to change without notice and intended for package maintainers only.

Index

Constants

View Source
const (
	// HttpRecordKey is the key for HTTP record attributes.
	HttpRecordKey = "__logging_http"
)

Variables

This section is empty.

Functions

func NewHttpRecord

func NewHttpRecord(t time.Time, method string, statusCode int, path string, args ...any) slog.Record

NewHttpRecord creates a slog.Record for an HTTP event.

Types

type BufferedAdapter

type BufferedAdapter[R any] interface {
	// GetBufferedAdapterName returns the name of the buffered adapter type.
	GetBufferedAdapterName() string
	// AcceptsHTTP reports if the adapter accepts HTTP records.
	AcceptsHTTP() bool

	RecordHandle(record R) error
}

BufferedAdapter extends Adapter with internal buffered features.

type HttpRecord

type HttpRecord struct {
	Method string
	Code   int
	Path   string
}

HttpRecord holds HTTP-specific log data.

type RingBuffer

type RingBuffer[R any] struct {
	// contains filtered or unexported fields
}

RingBuffer is a high-performance lock-free ring buffer for generic records.

func NewRingBuffer

func NewRingBuffer[R any](size uint64) *RingBuffer[R]

NewRingBuffer creates a RingBuffer of size (power of 2)

func (*RingBuffer[R]) Add

func (b *RingBuffer[R]) Add(r R)

Add appends an item to the buffer (optimized with relaxed ordering).

func (*RingBuffer[R]) AddUnsafe

func (b *RingBuffer[R]) AddUnsafe(r R)

AddUnsafe is a faster version that doesn't check for overflow Use only when you can guarantee the buffer won't overflow

func (*RingBuffer[R]) Cap

func (b *RingBuffer[R]) Cap() int

Cap returns the buffer capacity.

func (*RingBuffer[R]) Drain

func (b *RingBuffer[R]) Drain() []R

Drain retrieves and removes all available items.

func (*RingBuffer[R]) Empty

func (b *RingBuffer[R]) Empty() bool

Empty reports if the buffer is empty.

func (*RingBuffer[R]) IsFull

func (b *RingBuffer[R]) IsFull() bool

IsFull reports if the buffer is full (useful for bounded operations)

func (*RingBuffer[R]) Len

func (b *RingBuffer[R]) Len() int

Len returns the current number of items in the buffer.

func (*RingBuffer[R]) Take

func (b *RingBuffer[R]) Take() (record R, loaded bool)

Take retrieves and removes the oldest item.

func (*RingBuffer[R]) TakeBatch

func (b *RingBuffer[R]) TakeBatch(count int) []R

TakeBatch retrieves up to count items (optimized version).

func (*RingBuffer[R]) TakePreallocatedBatch

func (b *RingBuffer[R]) TakePreallocatedBatch(batch []R) []R

TakePreallocatedBatch reuses a provided slice to avoid allocations

func (*RingBuffer[R]) TakeUnsafe

func (b *RingBuffer[R]) TakeUnsafe() (record R, loaded bool)

TakeUnsafe is a faster version using unsafe pointer

Jump to

Keyboard shortcuts

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