kv

package
v3.93.3 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Endpoints

type Endpoints []trace.EndpointInfo

func (Endpoints) String

func (ee Endpoints) String() string

type FieldType

type FieldType int

FieldType indicates type info about the KeyValue. This enum might be extended in future releases. Adapters that don't support some FieldType value should use KeyValue.Fallback() for marshaling.

const (
	// InvalidType indicates that KeyValue was not initialized correctly. Adapters
	// should either ignore such field or issue an error. No value getters should
	// be called on field with such type.
	InvalidType FieldType = iota

	IntType
	Int64Type
	StringType
	BoolType
	DurationType

	// StringsType corresponds to []string
	StringsType

	ErrorType
	// AnyType indicates that the KeyValue is untyped. Adapters should use
	// reflection-based approached to marshal this field.
	AnyType

	// StringerType corresponds to fmt.Stringer
	StringerType
)

func (FieldType) String

func (ft FieldType) String() (typeName string)

type KeyValue

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

KeyValue represents typed log field (a key-value pair). Adapters should determine KeyValue's type based on Type and use the corresponding getter method to retrieve the value:

switch f.Type() {
case logs.IntType:
    var i int = f.Int()
    // handle int value
case logs.StringType:
    var s string = f.String()
    // handle string value
//...
}

Getter methods must not be called on fields with wrong Type (e.g. calling String() on fields with Type != StringType). KeyValue must not be initialized directly as a struct literal.

func Any

func Any(key string, value interface{}) KeyValue

Any constructs untyped KeyValue.

func Bool

func Bool(key string, value bool) KeyValue

Bool constructs KeyValue with BoolType

func Duration

func Duration(key string, value time.Duration) KeyValue

Duration constructs KeyValue with DurationType

func Error

func Error(value error) KeyValue

Error is the same as NamedError("error", value)

func Int

func Int(k string, v int) KeyValue

Int constructs KeyValue with IntType

func Int64

func Int64(k string, v int64) KeyValue

func Latency

func Latency(start time.Time) KeyValue

Latency creates KeyValue "latency": time.Since(start)

func NamedError

func NamedError(key string, value error) KeyValue

NamedError constructs KeyValue with ErrorType

func String

func String(k, v string) KeyValue

String constructs KeyValue with StringType

func Stringer

func Stringer(key string, value fmt.Stringer) KeyValue

Stringer constructs KeyValue with StringerType. If value is nil, resulting KeyValue will be of AnyType instead of StringerType.

func Strings

func Strings(key string, value []string) KeyValue

Strings constructs KeyValue with StringsType

func Version

func Version() KeyValue

Version creates KeyValue "version": version.Version

func (KeyValue) AnyValue

func (f KeyValue) AnyValue() interface{}

AnyValue is a value getter for fields with AnyType type

func (KeyValue) BoolValue

func (f KeyValue) BoolValue() bool

BoolValue is a value getter for fields with BoolType type

func (KeyValue) DurationValue

func (f KeyValue) DurationValue() time.Duration

DurationValue is a value getter for fields with DurationType type

func (KeyValue) ErrorValue

func (f KeyValue) ErrorValue() error

ErrorValue is a value getter for fields with ErrorType type

func (KeyValue) Int64Value

func (f KeyValue) Int64Value() int64

Int64Value is a value getter for fields with Int64Type type

func (KeyValue) IntValue

func (f KeyValue) IntValue() int

IntValue is a value getter for fields with IntType type

func (KeyValue) Key

func (f KeyValue) Key() string

func (KeyValue) String

func (f KeyValue) String() string

Returns default string representation of KeyValue value. It should be used by adapters that don't support f.Type directly.

func (KeyValue) StringValue

func (f KeyValue) StringValue() string

StringValue is a value getter for fields with StringType type

func (KeyValue) Stringer

func (f KeyValue) Stringer() fmt.Stringer

Stringer is a value getter for fields with StringerType type

func (KeyValue) StringsValue

func (f KeyValue) StringsValue() []string

StringsValue is a value getter for fields with StringsType type

func (KeyValue) Type

func (f KeyValue) Type() FieldType

type Metadata

type Metadata map[string][]string

func (Metadata) String

func (m Metadata) String() string

Jump to

Keyboard shortcuts

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