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 FindMessageType(typeUrl string) (protoreflect.MessageType, error)
- func FromJSON(content []byte, out proto.Message) error
- func FromYAML(content []byte, pb proto.Message) error
- func MarshalAnyDeterministic(pb proto.Message) (*anypb.Any, error)
- func Merge(dst, src proto.Message)
- func MergeAnys(dst *anypb.Any, src *anypb.Any) (*anypb.Any, error)
- func MustMarshalAny(pb proto.Message) *anypb.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 NewValueForStruct(in interface{}) (*structpb.Value, error)
- func Now() *timestamppb.Timestamp
- func Replace(dst, src proto.Message)
- 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 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 proto.Message) error
- type MergeFunction
- type OptionFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bool ¶
func Bool(b bool) *wrapperspb.BoolValue
func Bytes ¶
func Bytes(b []byte) *wrapperspb.BytesValue
func Double ¶
func Double(f float64) *wrapperspb.DoubleValue
func FindMessageType ¶
func FindMessageType(typeUrl string) (protoreflect.MessageType, error)
func FromYAML ¶
Note: we continue to use github.com/golang/protobuf/jsonpb because it unmarshals types the way we expect in go. See https://github.com/golang/protobuf/issues/1374
func MarshalAnyDeterministic ¶
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 ¶
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 MustMarshalJSON ¶
func MustNewValueForStruct ¶
func MustStruct ¶
func MustTimestampFromProto ¶
func MustTimestampFromProto(ts *timestamppb.Timestamp) *time.Time
func MustTimestampProto ¶
func MustTimestampProto(t time.Time) *timestamppb.Timestamp
func NewValueForStruct ¶
func Now ¶
func Now() *timestamppb.Timestamp
func String ¶
func String(s string) *wrapperspb.StringValue
func UInt32 ¶
func UInt32(u uint32) *wrapperspb.UInt32Value
func UInt64 ¶
func UInt64(u uint64) *wrapperspb.UInt64Value
Types ¶
type MergeFunction ¶
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 ¶
type OptionFn func(options mergeOptions) mergeOptions
func MergeFunctionOptionFn ¶
func MergeFunctionOptionFn(name protoreflect.FullName, function MergeFunction) OptionFn