Documentation ¶
Index ¶
- Variables
- func NewMessageEncoder(protoMessages []proto.Message) (hedwig.IEncoder, error)
- func NewMessageEncoderFromMessageTypes(protoMessages map[hedwig.MessageTypeMajorVersion]protoreflect.Message) (hedwig.IEncoder, error)
- type MessageOptions
- func (*MessageOptions) Descriptor() ([]byte, []int)deprecated
- func (x *MessageOptions) GetMajorVersion() uint32
- func (x *MessageOptions) GetMessageType() string
- func (x *MessageOptions) GetMinorVersion() uint32
- func (*MessageOptions) ProtoMessage()
- func (x *MessageOptions) ProtoReflect() protoreflect.Message
- func (x *MessageOptions) Reset()
- func (x *MessageOptions) String() string
- type MetadataV1
- func (*MetadataV1) Descriptor() ([]byte, []int)deprecated
- func (x *MetadataV1) GetHeaders() map[string]string
- func (x *MetadataV1) GetPublisher() string
- func (x *MetadataV1) GetTimestamp() *timestamp.Timestamp
- func (*MetadataV1) ProtoMessage()
- func (x *MetadataV1) ProtoReflect() protoreflect.Message
- func (x *MetadataV1) Reset()
- func (x *MetadataV1) String() string
- type PayloadV1
- func (*PayloadV1) Descriptor() ([]byte, []int)deprecated
- func (x *PayloadV1) GetData() *any.Any
- func (x *PayloadV1) GetFormatVersion() string
- func (x *PayloadV1) GetId() string
- func (x *PayloadV1) GetMetadata() *MetadataV1
- func (x *PayloadV1) GetSchema() string
- func (*PayloadV1) ProtoMessage()
- func (x *PayloadV1) ProtoReflect() protoreflect.Message
- func (x *PayloadV1) Reset()
- func (x *PayloadV1) String() string
Constants ¶
This section is empty.
Variables ¶
var (
// optional hedwig.MessageOptions message_options = 51235;
E_MessageOptions = &file_hedwig_protobuf_options_proto_extTypes[0]
)
Extension fields to descriptor.MessageOptions.
var File_hedwig_protobuf_container_proto protoreflect.FileDescriptor
var File_hedwig_protobuf_options_proto protoreflect.FileDescriptor
Functions ¶
func NewMessageEncoder ¶
NewMessageEncoder creates a new encoder from given list of proto-messages Proto messages must declare [hedwig.message_options](https://github.com/cloudchacho/hedwig/blob/main/protobuf/options.proto) option. See [example proto file](../examples/schema.proto) for reference.
This method will try to read message type from message_options, and if not specified, assume that the messages are named as: `<MessageType>V<MajorVersion>`. If that doesn't work for your use case, use NewMessageEncoderFromMessageTypes and provide an explicit mapping.
func NewMessageEncoderFromMessageTypes ¶
func NewMessageEncoderFromMessageTypes(protoMessages map[hedwig.MessageTypeMajorVersion]protoreflect.Message) (hedwig.IEncoder, error)
NewMessageEncoderFromMessageTypes creates a new encoder from explicit message types mapping
Types ¶
type MessageOptions ¶
type MessageOptions struct { // major version for this message type. this is required MajorVersion *uint32 `protobuf:"varint,1,opt,name=major_version,json=majorVersion" json:"major_version,omitempty"` // minor version for this message type. this is optional since 0 is a valid minor version MinorVersion *uint32 `protobuf:"varint,2,opt,name=minor_version,json=minorVersion" json:"minor_version,omitempty"` // message type explicit declaration. this is optional and will be automatically // inferred from message name assuming this format: `<MessageType>V<MajorVersion>`. MessageType *string `protobuf:"bytes,3,opt,name=message_type,json=messageType" json:"message_type,omitempty"` // contains filtered or unexported fields }
func (*MessageOptions) Descriptor
deprecated
func (*MessageOptions) Descriptor() ([]byte, []int)
Deprecated: Use MessageOptions.ProtoReflect.Descriptor instead.
func (*MessageOptions) GetMajorVersion ¶
func (x *MessageOptions) GetMajorVersion() uint32
func (*MessageOptions) GetMessageType ¶
func (x *MessageOptions) GetMessageType() string
func (*MessageOptions) GetMinorVersion ¶
func (x *MessageOptions) GetMinorVersion() uint32
func (*MessageOptions) ProtoMessage ¶
func (*MessageOptions) ProtoMessage()
func (*MessageOptions) ProtoReflect ¶
func (x *MessageOptions) ProtoReflect() protoreflect.Message
func (*MessageOptions) Reset ¶
func (x *MessageOptions) Reset()
func (*MessageOptions) String ¶
func (x *MessageOptions) String() string
type MetadataV1 ¶
type MetadataV1 struct { // Message publisher service Publisher string `protobuf:"bytes,1,opt,name=publisher,proto3" json:"publisher,omitempty"` // Publish timestamp in epoch milliseconds (integer) Timestamp *timestamp.Timestamp `protobuf:"bytes,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"` // Custom headers associated with the message Headers map[string]string `` /* 155-byte string literal not displayed */ // contains filtered or unexported fields }
func (*MetadataV1) Descriptor
deprecated
func (*MetadataV1) Descriptor() ([]byte, []int)
Deprecated: Use MetadataV1.ProtoReflect.Descriptor instead.
func (*MetadataV1) GetHeaders ¶
func (x *MetadataV1) GetHeaders() map[string]string
func (*MetadataV1) GetPublisher ¶
func (x *MetadataV1) GetPublisher() string
func (*MetadataV1) GetTimestamp ¶
func (x *MetadataV1) GetTimestamp() *timestamp.Timestamp
func (*MetadataV1) ProtoMessage ¶
func (*MetadataV1) ProtoMessage()
func (*MetadataV1) ProtoReflect ¶
func (x *MetadataV1) ProtoReflect() protoreflect.Message
func (*MetadataV1) Reset ¶
func (x *MetadataV1) Reset()
func (*MetadataV1) String ¶
func (x *MetadataV1) String() string
type PayloadV1 ¶
type PayloadV1 struct { // Format version for the message FormatVersion string `protobuf:"bytes,1,opt,name=format_version,json=formatVersion,proto3" json:"format_version,omitempty"` // Message identifier Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"` // Metadata associated with the message Metadata *MetadataV1 `protobuf:"bytes,3,opt,name=metadata,proto3" json:"metadata,omitempty"` // Schema to validate the data object with - format: <message type>/<message data version>, e.g. TripCreated/1.0 Schema string `protobuf:"bytes,4,opt,name=schema,proto3" json:"schema,omitempty"` // Message data Data *any.Any `protobuf:"bytes,5,opt,name=data,proto3" json:"data,omitempty"` // contains filtered or unexported fields }
func (*PayloadV1) Descriptor
deprecated
func (*PayloadV1) GetFormatVersion ¶
func (*PayloadV1) GetMetadata ¶
func (x *PayloadV1) GetMetadata() *MetadataV1
func (*PayloadV1) ProtoMessage ¶
func (*PayloadV1) ProtoMessage()
func (*PayloadV1) ProtoReflect ¶
func (x *PayloadV1) ProtoReflect() protoreflect.Message