xray

package
v0.0.0-...-3503691 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2025 License: 0BSD Imports: 10 Imported by: 1

Documentation

Overview

Package xray provides standard means for introspecting the internal operational state of an [api.Linker].

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextAdd

func ContextAdd(ctx context.Context, value any)

ContextAdd a value to the xray context, it can be retrieved later with Get.

func ContextGet

func ContextGet[T any](ctx context.Context) T

ContextGet a value from the xray context, if it exists. Otherwise a zero value is returned.

func ContextHas

func ContextHas[T any](ctx context.Context) bool

ContextHas returns true if the xray context has a value of the given type.

func ContextOff

func ContextOff(ctx context.Context) context.Context

ContextOff returns a new xray context that will not record any values.

func Error

func Error(err error, skip int) error

Error wraps the provided error with the caller's file and line number. Skipping the provided number of frames.

func New

func New(err error) error

New wraps the provided error with the caller's file and line number.

func NewContext

func NewContext(ctx context.Context) context.Context

NewContext returns a new xray context, that can have values added to a queue for future introspection.

Types

type Reader

type Reader interface {
	io.Reader
	io.Closer

	String() string
	Bytes() []byte
}

Reader with additional methods for introspecting what has been read.

func NewReader

func NewReader(ctx context.Context, r io.Reader) Reader

NewReader will wrap the provided io.Reader to ensure that it implements Reader if an xray is enabled.

type Writer

type Writer interface {
	io.Writer
	io.Closer

	String() string
	Bytes() []byte
}

Writer with additional methods for introspecting what has been written.

func NewWriter

func NewWriter(ctx context.Context, w io.Writer) Writer

NewWriter will wrap the provided io.Writer to ensure that it implements Writer if an xray is enabled.

Jump to

Keyboard shortcuts

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