Documentation ¶
Index ¶
- func DebugJSONAttributes(data map[string]any, isDebug bool) []attribute.KeyValue
- func DecodeBoolean(value any) (bool, error)
- func DecodeDateTime(value any) (time.Time, error)
- func DecodeDuration(value any) (time.Duration, error)
- func DecodeFloat[T float32 | float64](value any) (T, error)
- func DecodeInt[T int | int8 | int16 | int32 | int64](value any) (T, error)
- func DecodeNullableBoolean(value any) (*bool, error)
- func DecodeNullableDateTime(value any) (*time.Time, error)
- func DecodeNullableDuration(value any) (*time.Duration, error)
- func DecodeNullableFloat[T float32 | float64](value any) (*T, error)
- func DecodeNullableInt[T int | int8 | int16 | int32 | int64](value any) (*T, error)
- func DecodeNullableString(value any) (*string, error)
- func DecodeNullableUUID(value any) (*uuid.UUID, error)
- func DecodeNullableUint[T uint | uint8 | uint16 | uint32 | uint64](value any) (*T, error)
- func DecodeString(value any) (string, error)
- func DecodeUUID(value any) (uuid.UUID, error)
- func DecodeUint[T uint | uint8 | uint16 | uint32 | uint64](value any) (T, error)
- func EncodeMap[T MapEncoder](input T) map[string]any
- func EncodeMaps[T MapEncoder](inputs []T) []map[string]any
- func EncodeNullableMaps[T MapEncoder](inputs *[]T) []map[string]any
- func EncodeObject(input any) (map[string]any, error)
- func EncodeObjectSlice[T any](input []T) ([]map[string]any, error)
- func EncodeObjectWithColumnSelection[T any](fields map[string]schema.Field, data T) (map[string]any, error)
- func EncodeObjects(input any) ([]map[string]any, error)
- func EncodeObjectsWithColumnSelection[T any](fields map[string]schema.Field, data []T) ([]map[string]any, error)
- func EvalFunctionSelectionFieldValue(request *schema.QueryRequest) (schema.NestedField, error)
- func EvalNestedColumnArray(fields *schema.NestedArray, value any) (any, error)
- func EvalNestedColumnArrayIntoSlice[T any](fields *schema.NestedArray, value []T) (any, error)
- func EvalNestedColumnFields(fields schema.NestedField, value any) (any, error)
- func EvalNestedColumnObject(fields *schema.NestedObject, value any) (any, error)
- func EvalObjectWithColumnSelection(fields map[string]schema.Field, data map[string]any) (map[string]any, error)
- func EvalObjectsWithColumnSelection(fields map[string]schema.Field, data []map[string]any) ([]map[string]any, error)
- func GetAny(object map[string]any, key string) (any, bool)
- func GetArbitraryJSON(object map[string]any, key string) (any, error)
- func GetBool(object map[string]any, key string) (bool, error)
- func GetDateTime(object map[string]any, key string) (time.Time, error)
- func GetDefault[T comparable](value T, defaultValue T) T
- func GetDefaultPtr[T any](value *T, defaultValue *T) *T
- func GetDefaultValuePtr[T comparable](value *T, defaultValue T) T
- func GetDuration(object map[string]any, key string) (time.Duration, error)
- func GetFloat[T float32 | float64](object map[string]any, key string) (T, error)
- func GetInt[T int | int8 | int16 | int32 | int64](object map[string]any, key string) (T, error)
- func GetNullableArbitraryJSON(object map[string]any, key string) (*any, error)
- func GetNullableBool(object map[string]any, key string) (*bool, error)
- func GetNullableDateTime(object map[string]any, key string) (*time.Time, error)
- func GetNullableDuration(object map[string]any, key string) (*time.Duration, error)
- func GetNullableFloat[T float32 | float64](object map[string]any, key string) (*T, error)
- func GetNullableInt[T int | int8 | int16 | int32 | int64](object map[string]any, key string) (*T, error)
- func GetNullableObjectRawJSON(object map[string]any, key string) (*json.RawMessage, error)
- func GetNullableObjectUUID(object map[string]any, key string) (*uuid.UUID, error)
- func GetNullableString(object map[string]any, key string) (*string, error)
- func GetNullableUint[T uint | uint8 | uint16 | uint32 | uint64](object map[string]any, key string) (*T, error)
- func GetObjectRawJSON(object map[string]any, key string) (json.RawMessage, error)
- func GetObjectUUID(object map[string]any, key string) (uuid.UUID, error)
- func GetString(object map[string]any, key string) (string, error)
- func GetUint[T uint | uint8 | uint16 | uint32 | uint64](object map[string]any, key string) (T, error)
- func IsNil(value any) bool
- func JSONAttribute(key string, data any) attribute.KeyValue
- func ResolveArgumentVariables(arguments map[string]schema.Argument, variables map[string]any) (map[string]any, error)
- func ToPtr[V any](value V) *V
- type Decoder
- func (d Decoder) DecodeNullableObjectValue(target any, object map[string]any, key string) error
- func (d Decoder) DecodeNullableValue(target any, value any) error
- func (d Decoder) DecodeObjectValue(target any, object map[string]any, key string) error
- func (d Decoder) DecodeValue(target any, value any) error
- type MapEncoder
- type ObjectDecoder
- type Scalar
- type ValueDecoder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DebugJSONAttributes ¶ added in v0.3.0
DebugJSONAttributes create OpenTelemetry attributes with JSON data. They are only visible on debug mode
func DecodeBoolean ¶
DecodeBoolean tries to convert an unknown value to a bool value
func DecodeDateTime ¶
DecodeDateTime tries to convert an unknown value to a time.Time value
func DecodeDuration ¶
DecodeDuration tries to convert an unknown value to a duration value
func DecodeFloat ¶
DecodeFloat tries to convert an unknown value to a float value
func DecodeNullableBoolean ¶
DecodeNullableBoolean tries to convert an unknown value to a bool pointer
func DecodeNullableDateTime ¶
DecodeNullableDateTime tries to convert an unknown value to a time.Time pointer
func DecodeNullableDuration ¶
DecodeNullableDuration tries to convert an unknown value to a duration pointer
func DecodeNullableFloat ¶
DecodeNullableFloat tries to convert an unknown value to a float pointer
func DecodeNullableInt ¶
DecodeNullableInt tries to convert an unknown value to a nullable integer
func DecodeNullableString ¶
DecodeNullableString tries to convert an unknown value to a string pointer
func DecodeNullableUUID ¶ added in v0.3.1
DecodeNullableUUID decodes UUID pointer from string or bytes
func DecodeNullableUint ¶
DecodeNullableUint tries to convert an unknown value to a nullable unsigned integer pointer
func DecodeString ¶
DecodeString tries to convert an unknown value to a string value
func DecodeUUID ¶ added in v0.3.1
DecodeUUID decodes UUID from string
func DecodeUint ¶
DecodeUint tries to convert an unknown value to an unsigned integer value
func EncodeMap ¶
func EncodeMap[T MapEncoder](input T) map[string]any
EncodeMap encodes an object to a map[string]any, using json tag to convert object keys
func EncodeMaps ¶
func EncodeMaps[T MapEncoder](inputs []T) []map[string]any
EncodeMaps encode objects to a slice of map[string]any, using json tag to convert object keys
func EncodeNullableMaps ¶
func EncodeNullableMaps[T MapEncoder](inputs *[]T) []map[string]any
EncodeNullableMaps encode objects to a slice of map[string]any, using json tag to convert object keys
func EncodeObject ¶
EncodeObject encodes an unknown type to a map[string]any, using json tag to convert object keys
func EncodeObjectSlice ¶
EncodeObjectSlice encodes array of unknown type to map[string]any slice, using json tag to convert object keys
func EncodeObjectWithColumnSelection ¶
func EncodeObjectWithColumnSelection[T any](fields map[string]schema.Field, data T) (map[string]any, error)
EncodeObjectWithColumnSelection encodes an object with column fields selection without relationship
func EncodeObjects ¶
EncodeObjects encodes an object rows to a slice of map[string]any, using json tag to convert object keys
func EncodeObjectsWithColumnSelection ¶
func EncodeObjectsWithColumnSelection[T any](fields map[string]schema.Field, data []T) ([]map[string]any, error)
EncodeObjectsWithColumnSelection encodes objects with column fields selection without relationship
func EvalFunctionSelectionFieldValue ¶ added in v0.1.3
func EvalFunctionSelectionFieldValue(request *schema.QueryRequest) (schema.NestedField, error)
EvalFunctionSelectionFieldValue evaluates the __value field in a function query According to the NDC spec, selection fields of the function type must follow this structure:
{ "fields": { "__value": { "type": "column", "column": "__value", "fields": { "type": "object", "fields": { "fieldA": { "type": "column", "column": "fieldA", "fields": null } } // or null } } } }
func EvalNestedColumnArray ¶
func EvalNestedColumnArray(fields *schema.NestedArray, value any) (any, error)
EvalNestedColumnArray evaluate and prune nested fields from array without relationship
func EvalNestedColumnArrayIntoSlice ¶
func EvalNestedColumnArrayIntoSlice[T any](fields *schema.NestedArray, value []T) (any, error)
EvalNestedColumnArrayIntoSlice evaluate and prune nested fields from array without relationship
func EvalNestedColumnFields ¶
func EvalNestedColumnFields(fields schema.NestedField, value any) (any, error)
EvalNestedColumnFields evaluate and prune nested fields without relationship
func EvalNestedColumnObject ¶
func EvalNestedColumnObject(fields *schema.NestedObject, value any) (any, error)
EvalNestedColumnObject evaluate and prune nested fields from an object without relationship
func EvalObjectWithColumnSelection ¶
func EvalObjectWithColumnSelection(fields map[string]schema.Field, data map[string]any) (map[string]any, error)
EvalObjectWithColumnSelection evaluate and prune column fields without relationship
func EvalObjectsWithColumnSelection ¶
func EvalObjectsWithColumnSelection(fields map[string]schema.Field, data []map[string]any) ([]map[string]any, error)
EvalObjectsWithColumnSelection evaluate and prune column fields of array objects without relationship
func GetArbitraryJSON ¶ added in v0.3.1
GetArbitraryJSON get an arbitrary json value from object by key
func GetDateTime ¶
GetDateTime get a time.Time value from object by key
func GetDefault ¶ added in v0.3.0
func GetDefault[T comparable](value T, defaultValue T) T
GetDefault returns the value or default one if value is empty
func GetDefaultPtr ¶ added in v0.3.0
func GetDefaultPtr[T any](value *T, defaultValue *T) *T
GetDefaultPtr returns the first pointer or default one if GetDefaultPtr is nil
func GetDefaultValuePtr ¶ added in v0.3.0
func GetDefaultValuePtr[T comparable](value *T, defaultValue T) T
GetDefaultValuePtr return the value of pointer or default one if the value of pointer is null or empty
func GetDuration ¶
GetDuration get a time.Duration value from object by key
func GetNullableArbitraryJSON ¶ added in v0.3.1
GetNullableArbitraryJSON get an arbitrary json pointer from object by key
func GetNullableBool ¶
GetNullableBool get a bool pointer from object by key
func GetNullableDateTime ¶
GetNullableDateTime get a time.Time pointer from object by key
func GetNullableDuration ¶
GetNullableDuration get a time.Duration pointer from object by key
func GetNullableFloat ¶
GetNullableFloat get a float pointer from object by key
func GetNullableInt ¶
func GetNullableInt[T int | int8 | int16 | int32 | int64](object map[string]any, key string) (*T, error)
GetNullableInt get an integer pointer from object by key
func GetNullableObjectRawJSON ¶ added in v0.5.3
GetNullableObjectRawJSON get a raw json.RawMessage pointer from object by key
func GetNullableObjectUUID ¶ added in v0.5.0
GetNullableObjectUUID get an UUID pointer from object by key
func GetNullableString ¶
GetNullableString get a string pointer from object by key
func GetNullableUint ¶
func GetNullableUint[T uint | uint8 | uint16 | uint32 | uint64](object map[string]any, key string) (*T, error)
GetNullableUint get an unsigned integer pointer from object by key
func GetObjectRawJSON ¶ added in v0.5.3
GetObjectRawJSON get a raw json.RawMessage value from object by key
func GetObjectUUID ¶ added in v0.5.0
GetObjectUUID get an UUID value from object by key
func GetUint ¶
func GetUint[T uint | uint8 | uint16 | uint32 | uint64](object map[string]any, key string) (T, error)
GetUint get an unsigned integer value from object by key
func JSONAttribute ¶ added in v0.3.0
JSONAttribute creates a OpenTelemetry attribute with JSON data
Types ¶
type Decoder ¶ added in v0.1.1
type Decoder struct {
// contains filtered or unexported fields
}
Decoder is a wrapper of mapstructure decoder
func NewDecoder ¶ added in v0.1.1
func NewDecoder(decodeHooks ...mapstructure.DecodeHookFunc) *Decoder
NewDecoder creates a Decoder instance
func (Decoder) DecodeNullableObjectValue ¶ added in v0.1.1
DecodeNullableObjectValue get and decode a nullable value from object by key
func (Decoder) DecodeNullableValue ¶ added in v0.1.1
DecodeNullableValue tries to convert and set an unknown value into the target, fallback to mapstructure decoder
func (Decoder) DecodeObjectValue ¶ added in v0.1.1
DecodeObjectValue get and decode a value from object by key
type MapEncoder ¶
MapEncoder abstracts a type with the ToMap method to encode type to map
type ObjectDecoder ¶
ObjectDecoder abstracts a type with the FromValue method to decode an object value
type Scalar ¶
type Scalar interface {
ScalarName() string
}
Scalar abstracts a scalar interface to determine when evaluating
type ValueDecoder ¶
ValueDecoder abstracts a type with the FromValue method to decode any value