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
- func NewHttpRecord(t time.Time, method string, statusCode int, path string, args ...any) slog.Record
- type BufferedAdapter
- type HttpRecord
- type RingBuffer
- func (b *RingBuffer[R]) Add(r R)
- func (b *RingBuffer[R]) AddUnsafe(r R)
- func (b *RingBuffer[R]) Cap() int
- func (b *RingBuffer[R]) Drain() []R
- func (b *RingBuffer[R]) Empty() bool
- func (b *RingBuffer[R]) IsFull() bool
- func (b *RingBuffer[R]) Len() int
- func (b *RingBuffer[R]) Take() (record R, loaded bool)
- func (b *RingBuffer[R]) TakeBatch(count int) []R
- func (b *RingBuffer[R]) TakePreallocatedBatch(batch []R) []R
- func (b *RingBuffer[R]) TakeUnsafe() (record R, loaded bool)
Constants ¶
const (
// HttpRecordKey is the key for HTTP record attributes.
HttpRecordKey = "__logging_http"
)
Variables ¶
This section is empty.
Functions ¶
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 ¶
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]) 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