Documentation
¶
Index ¶
- func Bool(b bool) *wrapperspb.BoolValue
- func Bytes(b []byte) *wrapperspb.BytesValue
- func Double(f float64) *wrapperspb.DoubleValue
- func Duration(d time.Duration) *durationpb.Duration
- func FromJSON(content []byte, out proto.Message) error
- func FromMap(in map[string]interface{}, out proto.Message) error
- func FromYAML(content []byte, pb proto.Message) error
- func IsEmpty(message proto.Message) bool
- func MarshalAnyDeterministic(pb proto.Message) (*any.Any, error)
- func Merge(dst, src proto.Message)
- func MergeAnys(dst *any.Any, src *any.Any) (*any.Any, error)
- func MustMarshalAny(pb proto.Message) *any.Any
- func MustMarshalJSON(in proto.Message) []byte
- func MustNewValueForStruct(in interface{}) *structpb.Value
- func MustStruct(in map[string]interface{}) *structpb.Struct
- func MustTimestampFromProto(ts *timestamppb.Timestamp) *time.Time
- func MustTimestampProto(t time.Time) *timestamppb.Timestamp
- func MustToStruct(message proto.Message) *structpb.Struct
- func MustUnmarshalJSON(content []byte, out proto.Message) proto.Message
- func NewValueForStruct(in interface{}) (*structpb.Value, error)
- func Now() *timestamppb.Timestamp
- func String(s string) *wrapperspb.StringValue
- func Struct(in map[string]interface{}) (*structpb.Struct, error)
- func ToJSON(pb proto.Message) ([]byte, error)
- func ToJSONIndent(pb proto.Message, indent string) ([]byte, error)
- func ToMap(pb proto.Message) (map[string]interface{}, error)
- func ToStruct(message proto.Message) (*structpb.Struct, error)
- func ToTyped(protoStruct *structpb.Struct, message proto.Message) error
- func ToYAML(pb proto.Message) ([]byte, error)
- func UInt32(u uint32) *wrapperspb.UInt32Value
- func UInt64(u uint64) *wrapperspb.UInt64Value
- func UnmarshalAnyTo(src *anypb.Any, dst proto2.Message) error
- func UnmarshalAnyToV2(src *anypb.Any, dst proto.Message) error
- type MergeFunction
- type OptionFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalAnyDeterministic ¶
func MarshalAnyDeterministic(pb proto.Message) (*any.Any, error)
When saving Snapshot in SnapshotCache we generate version based on proto.Equal() Therefore we need deterministic way of marshaling Any which is part of the Protobuf on which we execute Equal()
Based on proto.MarshalAny
func MergeAnys ¶
func MergeAnys(dst *any.Any, src *any.Any) (*any.Any, error)
MergeAnys merges two Any messages of the same type. We cannot just use proto#Merge on Any directly because values are encoded in byte slices. Instead we have to unmarshal types, merge them and marshal again.
func MustMarshalAny ¶ added in v1.8.1
func MustMarshalAny(pb proto.Message) *any.Any
func MustMarshalJSON ¶ added in v1.8.1
func MustMarshalJSON(in proto.Message) []byte
func MustNewValueForStruct ¶ added in v1.8.1
func MustNewValueForStruct(in interface{}) *structpb.Value
func MustStruct ¶ added in v1.8.1
func MustStruct(in map[string]interface{}) *structpb.Struct
func MustTimestampFromProto ¶
func MustTimestampFromProto(ts *timestamppb.Timestamp) *time.Time
func MustTimestampProto ¶
func MustTimestampProto(t time.Time) *timestamppb.Timestamp
func MustToStruct ¶
func MustToStruct(message proto.Message) *structpb.Struct
func MustUnmarshalJSON ¶ added in v1.8.1
func MustUnmarshalJSON(content []byte, out proto.Message) proto.Message
func NewValueForStruct ¶ added in v1.8.1
func NewValueForStruct(in interface{}) (*structpb.Value, error)
func ToJSONIndent ¶ added in v1.8.1
func ToJSONIndent(pb proto.Message, indent string) ([]byte, error)
func ToStruct ¶
func ToStruct(message proto.Message) (*structpb.Struct, error)
Converts loosely typed Struct to strongly typed Message
func ToTyped ¶
func ToTyped(protoStruct *structpb.Struct, message proto.Message) error
Converts loosely typed Struct to strongly typed Message
func UnmarshalAnyTo ¶ added in v1.8.1
func UnmarshalAnyTo(src *anypb.Any, dst proto2.Message) error
func UnmarshalAnyToV2 ¶ added in v1.8.1
func UnmarshalAnyToV2(src *anypb.Any, dst proto.Message) error
Types ¶
type MergeFunction ¶ added in v1.8.1
type MergeFunction func(dst, src protoreflect.Message)
var ReplaceMergeFn MergeFunction = func(dst, src protoreflect.Message) {
dst.Range(func(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool {
dst.Clear(fd)
return true
})
src.Range(func(fd protoreflect.FieldDescriptor, v protoreflect.Value) bool {
dst.Set(fd, v)
return true
})
}
ReplaceMergeFn instead of merging all subfields one by one, takes src and set it to dest
type OptionFn ¶ added in v1.8.1
type OptionFn func(options mergeOptions) mergeOptions
func MergeFunctionOptionFn ¶ added in v1.8.1
func MergeFunctionOptionFn(name protoreflect.FullName, function MergeFunction) OptionFn
Click to show internal directories.
Click to hide internal directories.