Documentation
¶
Index ¶
- Variables
- type Payload
- func (*Payload) Descriptor() ([]byte, []int)deprecated
- func (x *Payload) GetContentType() string
- func (x *Payload) GetData() *structpb.Struct
- func (x *Payload) GetMetadata() map[string]*structpb.Value
- func (x *Payload) GetSchemaId() string
- func (x *Payload) GetSchemaVersion() int32
- func (*Payload) ProtoMessage()
- func (x *Payload) ProtoReflect() protoreflect.Message
- func (x *Payload) Reset()
- func (x *Payload) String() string
Constants ¶
This section is empty.
Variables ¶
var File_proto_common_v1_common_proto protoreflect.FileDescriptor
Functions ¶
This section is empty.
Types ¶
type Payload ¶
type Payload struct {
// metadata: Custom key-value pairs for message routing, filtering, and tracking.
// Common uses: correlation IDs, trace context, source system, user ID, tenant ID.
// These values are indexed and can be queried without deserializing the data field.
Metadata map[string]*structpb.Value `` /* 143-byte string literal not displayed */
// data: The actual message payload as structured data (JSON, Protobuf, etc.).
// This is your business data - orders, events, tasks, notifications, etc.
// Stored as google.protobuf.Struct for flexibility across different data formats.
Data *structpb.Struct `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"`
// content_type: MIME type indicating the data format.
// Examples: "application/json", "application/xml", "text/plain", "application/protobuf"
// Used for automatic deserialization and processing by workers.
ContentType string `protobuf:"bytes,3,opt,name=content_type,json=contentType,proto3" json:"content_type,omitempty"`
// schema_id: Reference to a registered schema for validation.
// If provided, ChronoQueue validates the data against this schema before accepting the message.
// Example: "order.created.v1", "user.profile.v2"
// Use RegisterSchema API to define schemas.
SchemaId string `protobuf:"bytes,4,opt,name=schema_id,json=schemaId,proto3" json:"schema_id,omitempty"`
// schema_version: Version number of the schema to use.
// Allows schema evolution while maintaining backward compatibility.
// If omitted, uses the latest active version of schema_id.
SchemaVersion int32 `protobuf:"varint,5,opt,name=schema_version,json=schemaVersion,proto3" json:"schema_version,omitempty"`
// contains filtered or unexported fields
}
Payload represents the user data and metadata for a message.
The Payload is the core data container in ChronoQueue that allows you to: - Store arbitrary structured data (JSON, XML, binary, etc.) - Attach custom metadata for filtering, routing, or tracking - Enforce schema validation for data quality
Example usage in Go:
payload := &common.Payload{
Metadata: map[string]*structpb.Value{
"source": structpb.NewStringValue("web-api"),
"user_id": structpb.NewStringValue("user-123"),
"correlation_id": structpb.NewStringValue("req-xyz"),
},
Data: dataStruct, // Your business data
ContentType: "application/json",
SchemaId: "order.v1", // Optional: enforce schema
SchemaVersion: 1,
}
Best practices: - Use metadata for: correlation IDs, trace context, routing info, custom headers - Use content_type to indicate data format (aids debugging and processing) - Use schema_id for validation in production to catch data quality issues early - Keep payloads under 256KB for optimal performance (configurable per queue)
func (*Payload) Descriptor
deprecated
func (*Payload) GetContentType ¶
func (*Payload) GetSchemaId ¶
func (*Payload) GetSchemaVersion ¶
func (*Payload) ProtoMessage ¶
func (*Payload) ProtoMessage()
func (*Payload) ProtoReflect ¶
func (x *Payload) ProtoReflect() protoreflect.Message