Documentation
¶
Overview ¶
Package metadata provides immutable request metadata and explicit propagation policies.
Index ¶
- Constants
- Variables
- func WithInbound(ctx context.Context, metadata Metadata) context.Context
- func WithLocal(ctx context.Context, metadata Metadata) context.Context
- func WithOutbound(ctx context.Context, metadata Metadata) context.Context
- type Carrier
- type MapCarrier
- type Metadata
- type Option
- type Policy
- type PolicyOption
Constants ¶
const (
// DefaultMaxBytes is the default metadata key/value budget.
DefaultMaxBytes = 8 * 1024
)
Variables ¶
var ( // ErrInvalidKey means a metadata key cannot be normalized safely. ErrInvalidKey = errors.New("metadata: invalid key") // ErrTooLarge means metadata exceeds its configured byte budget. ErrTooLarge = errors.New("metadata: size limit exceeded") // ErrInvalidOption means a metadata option is invalid. ErrInvalidOption = errors.New("metadata: invalid option") // ErrNilCarrier means a propagation Carrier is nil. ErrNilCarrier = errors.New("metadata: nil carrier") )
Functions ¶
func WithInbound ¶
WithInbound attaches immutable inbound Metadata to ctx.
Types ¶
type MapCarrier ¶
MapCarrier adapts a normalized map to Carrier.
Callers that inject metadata must initialize the map.
func (MapCarrier) Set ¶
func (c MapCarrier) Set(key string, values []string)
Set writes a defensive copy under a normalized key.
func (MapCarrier) Values ¶
func (c MapCarrier) Values(key string) []string
Values returns a defensive copy of a normalized carrier value.
type Metadata ¶
type Metadata struct {
// contains filtered or unexported fields
}
Metadata is an immutable collection of normalized multi-value metadata.
func (Metadata) IsSensitive ¶
IsSensitive reports whether key must be redacted in diagnostic output.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option configures Metadata construction.
func WithMaxBytes ¶
WithMaxBytes sets the maximum combined key/value bytes.
func WithSensitive ¶
WithSensitive marks keys for redaction without granting propagation rights.
type Policy ¶
type Policy struct {
// contains filtered or unexported fields
}
Policy is an immutable allowlist and byte budget for transport propagation.
func NewPolicy ¶
func NewPolicy(allowed []string, options ...PolicyOption) (Policy, error)
NewPolicy constructs an immutable default-deny propagation policy.
type PolicyOption ¶
type PolicyOption interface {
// contains filtered or unexported methods
}
PolicyOption configures a propagation Policy.
func WithPolicyMaxBytes ¶
func WithPolicyMaxBytes(maxBytes int) PolicyOption
WithPolicyMaxBytes sets the maximum propagated key/value bytes.
func WithSensitiveKeys ¶
func WithSensitiveKeys(keys ...string) PolicyOption
WithSensitiveKeys marks allowed propagation keys as sensitive.