common

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var File_proto_common_v1_common_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type LeasePolicy added in v1.1.1

type LeasePolicy struct {

	// base_lease:
	// Initial lease duration for an attempt (L_base).
	// The attempt starts with this much time before timing out, unless extended.
	BaseLease *durationpb.Duration `protobuf:"bytes,1,opt,name=base_lease,json=baseLease,proto3" json:"base_lease,omitempty"`
	// max_extension:
	// Maximum additional time beyond base_lease that an attempt may obtain via
	// heartbeats (L_maxExt).
	//
	// Effective per-attempt cap:
	//
	//	base_lease + max_extension
	MaxExtension *durationpb.Duration `protobuf:"bytes,2,opt,name=max_extension,json=maxExtension,proto3" json:"max_extension,omitempty"`
	// heartbeat_timeout:
	// Maximum allowed gap between heartbeats (H).
	// If zero/unset, heartbeat-based timeout is disabled.
	HeartbeatTimeout *durationpb.Duration `protobuf:"bytes,3,opt,name=heartbeat_timeout,json=heartbeatTimeout,proto3" json:"heartbeat_timeout,omitempty"`
	// extend_step:
	// Amount of time to extend the lease by when a heartbeat is received,
	// until max_extension is exhausted.
	//
	// Example:
	//
	//	base_lease = 3s
	//	max_extension = 10s
	//	extend_step = 2s
	//
	// The attempt can slide its lease by 2s increments up to ~13s total.
	ExtendStep *durationpb.Duration `protobuf:"bytes,4,opt,name=extend_step,json=extendStep,proto3" json:"extend_step,omitempty"`
	// contains filtered or unexported fields
}

LeasePolicy defines how long a single processing attempt is allowed to run, and how heartbeats can extend that time.

func (*LeasePolicy) Descriptor deprecated added in v1.1.1

func (*LeasePolicy) Descriptor() ([]byte, []int)

Deprecated: Use LeasePolicy.ProtoReflect.Descriptor instead.

func (*LeasePolicy) GetBaseLease added in v1.1.1

func (x *LeasePolicy) GetBaseLease() *durationpb.Duration

func (*LeasePolicy) GetExtendStep added in v1.1.1

func (x *LeasePolicy) GetExtendStep() *durationpb.Duration

func (*LeasePolicy) GetHeartbeatTimeout added in v1.1.1

func (x *LeasePolicy) GetHeartbeatTimeout() *durationpb.Duration

func (*LeasePolicy) GetMaxExtension added in v1.1.1

func (x *LeasePolicy) GetMaxExtension() *durationpb.Duration

func (*LeasePolicy) ProtoMessage added in v1.1.1

func (*LeasePolicy) ProtoMessage()

func (*LeasePolicy) ProtoReflect added in v1.1.1

func (x *LeasePolicy) ProtoReflect() protoreflect.Message

func (*LeasePolicy) Reset added in v1.1.1

func (x *LeasePolicy) Reset()

func (*LeasePolicy) String added in v1.1.1

func (x *LeasePolicy) String() string

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) Descriptor() ([]byte, []int)

Deprecated: Use Payload.ProtoReflect.Descriptor instead.

func (*Payload) GetContentType

func (x *Payload) GetContentType() string

func (*Payload) GetData

func (x *Payload) GetData() *structpb.Struct

func (*Payload) GetMetadata

func (x *Payload) GetMetadata() map[string]*structpb.Value

func (*Payload) GetSchemaId

func (x *Payload) GetSchemaId() string

func (*Payload) GetSchemaVersion

func (x *Payload) GetSchemaVersion() int32

func (*Payload) ProtoMessage

func (*Payload) ProtoMessage()

func (*Payload) ProtoReflect

func (x *Payload) ProtoReflect() protoreflect.Message

func (*Payload) Reset

func (x *Payload) Reset()

func (*Payload) String

func (x *Payload) String() string

Jump to

Keyboard shortcuts

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