model

package
v0.0.0-...-d853fe5 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package pbsupport protobuf support used in db package.

Package pbsupport protobuf support used in db package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DirtyFilter

func DirtyFilter(desc protoreflect.MessageDescriptor, fields []FieldName) map[string]struct{}

DirtyFilter Create dirty filter and ignore deep level fields.

func FindFds

func FindFds(msgDesc protoreflect.MessageDescriptor, keyNames []string) []protoreflect.FieldDescriptor

FindFds find field descriptor, keep order of param KeyNames.

func IsFdMarshalToBlob

func IsFdMarshalToBlob(fd protoreflect.FieldDescriptor) bool

IsFdMarshalToBlob if a field will marshal to blob.

func MarshalToMap

func MarshalToMap(msg proto.Message, fields []FieldName) (map[string]any, error)

MarshalToMap recode split and marshal data to map, scalar will be marshal to string.

func UnmarshalFromMap

func UnmarshalFromMap(msg proto.Message, bytesMap map[string]string) (err error)

UnmarshalFromMap unmarsh data loaded from db.

Types

type FieldName

type FieldName protoreflect.Name

type Watcher

type Watcher interface {
	// 订阅这个Message的字段变更
	Watch(c context.Context, msg proto.Message)
	// Message字段变更时调用,idx是pb中定义的字段编号
	SetNotify(msg proto.Message, n protowire.Number, name FieldName)
	// Message不希望被订阅时调用
	QuitWatch(c context.Context, msg proto.Message)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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