Documentation
¶
Overview ¶
Package common 提供跨服务复用的 Protobuf 类型及其 Go 辅助方法。
Index ¶
- Constants
- Variables
- type Any
- type Attribute
- func (*Attribute) Descriptor() ([]byte, []int)deprecated
- func (x *Attribute) GetName() string
- func (x *Attribute) GetValue() *structpb.Value
- func (msg *Attribute) MarshalJSON() ([]byte, error)
- func (*Attribute) ProtoMessage()
- func (x *Attribute) ProtoReflect() protoreflect.Message
- func (x *Attribute) Reset()
- func (x *Attribute) String() string
- func (msg *Attribute) UnmarshalJSON(b []byte) error
- type BoolValue
- type BytesValue
- type DoubleValue
- type Duration
- type Empty
- type FieldBehavior
- type FieldMask
- type FloatValue
- type HttpBody
- type Id
- type Ids
- func (*Ids) Descriptor() ([]byte, []int)deprecated
- func (x *Ids) GetIds() []string
- func (msg *Ids) MarshalJSON() ([]byte, error)
- func (*Ids) ProtoMessage()
- func (x *Ids) ProtoReflect() protoreflect.Message
- func (x *Ids) Reset()
- func (x *Ids) String() string
- func (msg *Ids) UnmarshalJSON(b []byte) error
- type Int32Value
- type Int64Value
- type ListValue
- type Metadata
- func (*Metadata) Descriptor() ([]byte, []int)deprecated
- func (x *Metadata) GetCreatedAt() *timestamppb.Timestamp
- func (x *Metadata) GetCreatedBy() string
- func (x *Metadata) GetDeleteAt() *timestamppb.Timestamp
- func (x *Metadata) GetUpdatedAt() *timestamppb.Timestamp
- func (x *Metadata) GetUpdatedBy() string
- func (msg *Metadata) MarshalJSON() ([]byte, error)
- func (*Metadata) ProtoMessage()
- func (x *Metadata) ProtoReflect() protoreflect.Message
- func (x *Metadata) Reset()
- func (x *Metadata) String() string
- func (msg *Metadata) UnmarshalJSON(b []byte) error
- type NullValue
- type Paging
- func (*Paging) Descriptor() ([]byte, []int)deprecated
- func (x *Paging) GetLimit() int
- func (x *Paging) GetOffset() int
- func (x *Paging) GetOffsetLimit() (int, int)
- func (x *Paging) GetPage() int32
- func (x *Paging) GetPageSize() int32
- func (x *Paging) GetTotal() int32
- func (msg *Paging) MarshalJSON() ([]byte, error)
- func (*Paging) ProtoMessage()
- func (x *Paging) ProtoReflect() protoreflect.Message
- func (x *Paging) Reset()
- func (x *Paging) String() string
- func (msg *Paging) UnmarshalJSON(b []byte) error
- func (x *Paging) WithTotal(total int64) *Paging
- type Status
- type StringValue
- type Struct
- type TimeRange
- func (*TimeRange) Descriptor() ([]byte, []int)deprecated
- func (x *TimeRange) GetEnd() *timestamppb.Timestamp
- func (x *TimeRange) GetStart() *timestamppb.Timestamp
- func (msg *TimeRange) MarshalJSON() ([]byte, error)
- func (*TimeRange) ProtoMessage()
- func (x *TimeRange) ProtoReflect() protoreflect.Message
- func (x *TimeRange) Reset()
- func (x *TimeRange) String() string
- func (msg *TimeRange) UnmarshalJSON(b []byte) error
- type Timestamp
- type UInt32Value
- type UInt64Value
- type Value
- type Value_BoolValue
- type Value_ListValue
- type Value_NullValue
- type Value_NumberValue
- type Value_StringValue
- type Value_StructValue
Constants ¶
const FieldBehavior_FIELD_BEHAVIOR_UNSPECIFIED = annotations.FieldBehavior_FIELD_BEHAVIOR_UNSPECIFIED
const FieldBehavior_IDENTIFIER = annotations.FieldBehavior_IDENTIFIER
const FieldBehavior_IMMUTABLE = annotations.FieldBehavior_IMMUTABLE
const FieldBehavior_INPUT_ONLY = annotations.FieldBehavior_INPUT_ONLY
const FieldBehavior_NON_EMPTY_DEFAULT = annotations.FieldBehavior_NON_EMPTY_DEFAULT
const FieldBehavior_OPTIONAL = annotations.FieldBehavior_OPTIONAL
const FieldBehavior_OUTPUT_ONLY = annotations.FieldBehavior_OUTPUT_ONLY
const FieldBehavior_REQUIRED = annotations.FieldBehavior_REQUIRED
const FieldBehavior_UNORDERED_LIST = annotations.FieldBehavior_UNORDERED_LIST
const NullValue_NULL_VALUE = structpb.NullValue_NULL_VALUE
Variables ¶
var ( // NewAny 及 Any 前缀方法提供 google.protobuf.Any 的常用构造和转换能力。 NewAny = anypb.New AnyMarshalFrom = anypb.MarshalFrom AnyUnmarshalNew = anypb.UnmarshalNew AnyUnmarshalTo = anypb.UnmarshalTo // NewDuration 根据 time.Duration 构造 google.protobuf.Duration。 NewDuration = durationpb.New // NewList 和 NewStruct 将普通 Go 数据转换为对应的结构化 Protobuf 值。 NewList = structpb.NewList NewStruct = structpb.NewStruct // NewValue 及其同组方法构造 google.protobuf.Value 及具体值类型。 NewValue = structpb.NewValue NewBoolValue = structpb.NewBoolValue NewListValue = structpb.NewListValue NewNullValue = structpb.NewNullValue NewNumberValue = structpb.NewNumberValue NewStringValue = structpb.NewStringValue NewStructValue = structpb.NewStructValue // NewTimestamp 根据 time.Time 构造 google.protobuf.Timestamp。 NewTimestamp = timestamppb.New // Bool 至 UInt64 提供 google.protobuf 包装类型的便捷构造方法。 Bool = wrapperspb.Bool Bytes = wrapperspb.Bytes Double = wrapperspb.Double Float = wrapperspb.Float Int32 = wrapperspb.Int32 Int64 = wrapperspb.Int64 String = wrapperspb.String UInt32 = wrapperspb.UInt32 UInt64 = wrapperspb.UInt64 )
var DefaultLimit = 20
DefaultLimit 是未指定有效每页数量时使用的默认值。
var E_FieldBehavior = annotations.E_FieldBehavior
var FieldBehavior_name = annotations.FieldBehavior_name
var FieldBehavior_value = annotations.FieldBehavior_value
var File_common_common_proto protoreflect.FileDescriptor
var NullValue_name = structpb.NullValue_name
var NullValue_value = structpb.NullValue_value
Functions ¶
This section is empty.
Types ¶
type Attribute ¶
type Attribute struct {
// 名称
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
// 数据
Value *structpb.Value `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"`
// contains filtered or unexported fields
}
名称和值组成的动态属性
func (*Attribute) Descriptor
deprecated
func (*Attribute) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (*Attribute) ProtoMessage ¶
func (*Attribute) ProtoMessage()
func (*Attribute) ProtoReflect ¶
func (x *Attribute) ProtoReflect() protoreflect.Message
func (*Attribute) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type BoolValue ¶
type BoolValue = wrapperspb.BoolValue
type BytesValue ¶
type BytesValue = wrapperspb.BytesValue
type DoubleValue ¶
type DoubleValue = wrapperspb.DoubleValue
type Duration ¶
type Duration = durationpb.Duration
type Empty ¶
type Empty struct {
// contains filtered or unexported fields
}
空消息,用于不需要请求参数或响应数据的 RPC
func (*Empty) Descriptor
deprecated
func (*Empty) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (*Empty) ProtoMessage ¶
func (*Empty) ProtoMessage()
func (*Empty) ProtoReflect ¶
func (x *Empty) ProtoReflect() protoreflect.Message
func (*Empty) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type FieldBehavior ¶
type FieldBehavior = annotations.FieldBehavior
type FieldMask ¶
type FieldMask = fieldmaskpb.FieldMask
type FloatValue ¶
type FloatValue = wrapperspb.FloatValue
type Id ¶
type Id struct {
// 资源标识
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
// contains filtered or unexported fields
}
单个资源标识
func (*Id) Descriptor
deprecated
func (*Id) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (*Id) ProtoMessage ¶
func (*Id) ProtoMessage()
func (*Id) ProtoReflect ¶
func (x *Id) ProtoReflect() protoreflect.Message
func (*Id) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type Ids ¶
type Ids struct {
// 资源标识列表
Ids []string `protobuf:"bytes,1,rep,name=ids,proto3" json:"ids,omitempty"`
// contains filtered or unexported fields
}
多个资源标识
func (*Ids) Descriptor
deprecated
func (*Ids) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (*Ids) ProtoMessage ¶
func (*Ids) ProtoMessage()
func (*Ids) ProtoReflect ¶
func (x *Ids) ProtoReflect() protoreflect.Message
func (*Ids) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type Int32Value ¶
type Int32Value = wrapperspb.Int32Value
type Int64Value ¶
type Int64Value = wrapperspb.Int64Value
type Metadata ¶
type Metadata struct {
// 创建人
CreatedBy string `protobuf:"bytes,1,opt,name=created_by,json=createdBy,proto3" json:"created_by,omitempty"`
// 创建时间
CreatedAt *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"`
// 更新人
UpdatedBy string `protobuf:"bytes,3,opt,name=updated_by,json=updatedBy,proto3" json:"updated_by,omitempty"`
// 更新时间
UpdatedAt *timestamppb.Timestamp `protobuf:"bytes,4,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"`
// 软删除时间
DeleteAt *timestamppb.Timestamp `protobuf:"bytes,5,opt,name=delete_at,json=deleteAt,proto3" json:"delete_at,omitempty"`
// contains filtered or unexported fields
}
资源的创建、更新和软删除元数据
func (*Metadata) Descriptor
deprecated
func (*Metadata) GetCreatedAt ¶
func (x *Metadata) GetCreatedAt() *timestamppb.Timestamp
func (*Metadata) GetCreatedBy ¶
func (*Metadata) GetDeleteAt ¶
func (x *Metadata) GetDeleteAt() *timestamppb.Timestamp
func (*Metadata) GetUpdatedAt ¶
func (x *Metadata) GetUpdatedAt() *timestamppb.Timestamp
func (*Metadata) GetUpdatedBy ¶
func (*Metadata) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (*Metadata) ProtoMessage ¶
func (*Metadata) ProtoMessage()
func (*Metadata) ProtoReflect ¶
func (x *Metadata) ProtoReflect() protoreflect.Message
func (*Metadata) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type Paging ¶
type Paging struct {
// 请求页码,从 1 开始
Page int32 `protobuf:"varint,1,opt,name=page,proto3" json:"page,omitempty"`
// 每页请求数量
PageSize int32 `protobuf:"varint,2,opt,name=page_size,json=pageSize,proto3" json:"page_size,omitempty"`
// 总记录数
Total int32 `protobuf:"varint,3,opt,name=total,proto3" json:"total,omitempty"`
// contains filtered or unexported fields
}
基于页码的请求和响应分页信息
func (*Paging) Descriptor
deprecated
func (*Paging) GetOffsetLimit ¶
GetOffsetLimit 返回从零开始的偏移量和规范化后的每页数量。
func (*Paging) GetPageSize ¶
func (*Paging) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (*Paging) ProtoMessage ¶
func (*Paging) ProtoMessage()
func (*Paging) ProtoReflect ¶
func (x *Paging) ProtoReflect() protoreflect.Message
func (*Paging) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type StringValue ¶
type StringValue = wrapperspb.StringValue
type TimeRange ¶
type TimeRange struct {
// 开始时间
Start *timestamppb.Timestamp `protobuf:"bytes,1,opt,name=start,proto3" json:"start,omitempty"`
// 结束时间
End *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=end,proto3" json:"end,omitempty"`
// contains filtered or unexported fields
}
包含首尾边界的时间范围
func (*TimeRange) Descriptor
deprecated
func (*TimeRange) GetEnd ¶
func (x *TimeRange) GetEnd() *timestamppb.Timestamp
func (*TimeRange) GetStart ¶
func (x *TimeRange) GetStart() *timestamppb.Timestamp
func (*TimeRange) MarshalJSON ¶
MarshalJSON implements json.Marshaler.
func (*TimeRange) ProtoMessage ¶
func (*TimeRange) ProtoMessage()
func (*TimeRange) ProtoReflect ¶
func (x *TimeRange) ProtoReflect() protoreflect.Message
func (*TimeRange) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
type Timestamp ¶
type Timestamp = timestamppb.Timestamp
type UInt32Value ¶
type UInt32Value = wrapperspb.UInt32Value
type UInt64Value ¶
type UInt64Value = wrapperspb.UInt64Value
type Value_BoolValue ¶
type Value_BoolValue = structpb.Value_BoolValue
type Value_ListValue ¶
type Value_ListValue = structpb.Value_ListValue
type Value_NullValue ¶
type Value_NullValue = structpb.Value_NullValue
type Value_NumberValue ¶
type Value_NumberValue = structpb.Value_NumberValue
type Value_StringValue ¶
type Value_StringValue = structpb.Value_StringValue
type Value_StructValue ¶
type Value_StructValue = structpb.Value_StructValue