proto

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2022 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool added in v1.8.1

func Bool(b bool) *wrapperspb.BoolValue

func Bytes added in v1.8.1

func Bytes(b []byte) *wrapperspb.BytesValue

func Double added in v1.8.1

func Double(f float64) *wrapperspb.DoubleValue

func Duration added in v1.8.1

func Duration(d time.Duration) *durationpb.Duration

func FromJSON

func FromJSON(content []byte, out proto.Message) error

func FromMap

func FromMap(in map[string]interface{}, out proto.Message) error

func FromYAML

func FromYAML(content []byte, pb proto.Message) error

func IsEmpty added in v1.8.1

func IsEmpty(message proto.Message) bool

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 Merge added in v1.8.1

func Merge(dst, src proto.Message)

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 Now added in v1.8.1

func Now() *timestamppb.Timestamp

func String added in v1.8.1

func String(s string) *wrapperspb.StringValue

func Struct added in v1.8.1

func Struct(in map[string]interface{}) (*structpb.Struct, error)

func ToJSON

func ToJSON(pb proto.Message) ([]byte, error)

func ToJSONIndent added in v1.8.1

func ToJSONIndent(pb proto.Message, indent string) ([]byte, error)

func ToMap

func ToMap(pb proto.Message) (map[string]interface{}, 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 ToYAML

func ToYAML(pb proto.Message) ([]byte, error)

func UInt32 added in v1.8.1

func UInt32(u uint32) *wrapperspb.UInt32Value

func UInt64 added in v1.8.1

func UInt64(u uint64) *wrapperspb.UInt64Value

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

Jump to

Keyboard shortcuts

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