Documentation
¶
Overview ¶
Package ddb provides DynamoDB utility for Protobuf messages
Index ¶
- Variables
- func BoolMapKey(s string) (bool, error)
- func IntMapKey[K ~int32 | ~int64](s string) (K, error)
- func Marshal(in any, os ...Option) (types.AttributeValue, error)
- func MarshalMappedMessage[K comparable, T any, TP ProtoMessage[T]](x map[K]TP, os ...Option) (types.AttributeValue, error)
- func MarshalMessage(x proto.Message, os ...Option) (a types.AttributeValue, err error)
- func MarshalRepeatedMessage[T any, TP ProtoMessage[T]](x []TP, os ...Option) (av types.AttributeValue, err error)
- func MarshalSet[T ~uint64 | ~uint32 | ~int32 | ~int64 | string | []byte](s []T, os ...Option) (types.AttributeValue, error)
- func StringMapKey(s string) (string, error)
- func UintMapKey[K ~uint32 | ~uint64](s string) (K, error)
- func Unmarshal(av types.AttributeValue, out any, os ...Option) error
- func UnmarshalMappedMessage[K comparable, T any, TP ProtoMessage[T]](m types.AttributeValue, fv func(s string) (K, error), os ...Option) (xm map[K]TP, err error)
- func UnmarshalMessage(m types.AttributeValue, x proto.Message, os ...Option) (err error)
- func UnmarshalRepeatedMessage[T any, TP ProtoMessage[T]](m types.AttributeValue, os ...Option) (xl []TP, err error)
- type Option
- type ProtoMessage
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUnsupportedEmbedEncoding is returned when a unsupported embed encoding is used ErrUnsupportedEmbedEncoding = fmt.Errorf("unsupported embed encoding, supports: %s %s", ddbv1.Encoding_ENCODING_JSON, ddbv1.Encoding_ENCODING_DYNAMO) )
Functions ¶
func BoolMapKey ¶ added in v0.2.0
BoolMapKey parses 's' as a boolean 'true' or 'false' value
func Marshal ¶ added in v0.2.0
func Marshal(in any, os ...Option) (types.AttributeValue, error)
Marshal will marshal basic types, and composite types that only hold basic types. It defers to the offical AWS sdk but is still put here to make it easier to change behaviour in the future.
func MarshalMappedMessage ¶ added in v0.2.0
func MarshalMappedMessage[K comparable, T any, TP ProtoMessage[T]](x map[K]TP, os ...Option) (types.AttributeValue, error)
MarshalMappedMessage takes a map of messages and marshals it to a dynamodb representation
func MarshalMessage ¶ added in v0.2.0
MarshalMessage will marshal a protobuf message 'm' into an attribute value. It supports several well-known Protobuf types and if 'x' implements its own MarshalDynamoItem method it will be called to delegate the marshalling.
func MarshalRepeatedMessage ¶ added in v0.2.0
func MarshalRepeatedMessage[T any, TP ProtoMessage[T]](x []TP, os ...Option) (av types.AttributeValue, err error)
MarshalRepeatedMessage provides a generic function for marshalling a repeated field as long as the generated code provides the concrete type as the Type parameter.
func MarshalSet ¶ added in v0.2.0
func MarshalSet[T ~uint64 | ~uint32 | ~int32 | ~int64 | string | []byte](s []T, os ...Option) (types.AttributeValue, error)
MarshalSet will marshal a slice of 'T' to a dynamo set.
func StringMapKey ¶ added in v0.2.0
StringMapKey parses 's' as a string map key
func UintMapKey ¶ added in v0.2.0
UintMapKey parses 's' as an unsigned integer value
func Unmarshal ¶ added in v0.2.0
func Unmarshal(av types.AttributeValue, out any, os ...Option) error
Unmarshal will marshal basic types, and composite types that only hold basic types. It takes into account the embed encoding option.
func UnmarshalMappedMessage ¶ added in v0.2.0
func UnmarshalMappedMessage[K comparable, T any, TP ProtoMessage[T]](m types.AttributeValue, fv func(s string) (K, error), os ...Option) (xm map[K]TP, err error)
UnmarshalMappedMessage decodes the dynamodb representation of a map of messages
func UnmarshalMessage ¶ added in v0.2.0
UnmarshalMessage will attempt to unmarshal 'm' into a protobuf message 'x'. It provides special support for several well-known protobuf message types. If 'x' implements the MarshalDynamoItem method it will be called to delegate the unmarshalling.
func UnmarshalRepeatedMessage ¶ added in v0.2.0
func UnmarshalRepeatedMessage[T any, TP ProtoMessage[T]](m types.AttributeValue, os ...Option) (xl []TP, err error)
UnmarshalRepeatedMessage provides a generic function for unmarshalling a repeated field of messages from the DynamoDB representation.
Types ¶
type ProtoMessage ¶ added in v0.2.0
ProtoMessage is a constraint to a protobuf message pointer.