messagex

package
v0.0.95 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	IDHeaderKey         = "_clinia_message_id"
	RetryCountHeaderKey = "_clinia_retry_count"
)
View Source
const (
	TopicSeparator   = "."
	TopicRetrySuffix = TopicSeparator + "retry"
)

Variables

This section is empty.

Functions

func WithID

func WithID(id string) newMessageOption

WithID sets the ID of the message. A ksuid will be generated if no ID is provided.

func WithMetadata

func WithMetadata(m MessageMetadata) newMessageOption

WithMetadata sets the metadata of the message.

Types

type ConsumerGroup

type ConsumerGroup string

func (ConsumerGroup) ConsumerGroup

func (group ConsumerGroup) ConsumerGroup(scope string) string

ConsumerGroup returns the consumer group name with the given scope. If the scope is empty, it returns the consumer group name as is. This should be used when interacting with the concrete pubsubs (e.g. Kafka).

type Message

type Message struct {
	ID       string
	Metadata MessageMetadata
	Payload  []byte
}

Message intentionally has no json marshalling fields as we want to pass by our own kgox.DefaultMarshaler

func NewMessage

func NewMessage(payload []byte, opts ...newMessageOption) *Message

NewMessage creates a new Message with the given payload and options.

Parameters:

  • payload: The payload of the message as a byte slice.
  • opts: Optional parameters to customize the creation of the message. By default, a new UUID is generated for the message.

Returns:

  • *Message: A pointer to the created Message.

func (*Message) Copy added in v0.0.80

func (m *Message) Copy() *Message

func (*Message) ExtractTraceContext added in v0.0.82

func (m *Message) ExtractTraceContext(ctx context.Context) context.Context

func (*Message) InjectTraceContext added in v0.0.82

func (m *Message) InjectTraceContext(ctx context.Context)

func (*Message) WithSpan added in v0.0.79

func (m *Message) WithSpan(ctx context.Context, tracer trace.Tracer, spanPrefix string, opts ...trace.SpanStartOption) (context.Context, trace.Span)

type MessageMetadata

type MessageMetadata map[string]string

type Topic

type Topic string

func BaseTopicFromName added in v0.0.80

func BaseTopicFromName(topicName string) Topic

Expect topic to be format `{scope}.{topic}.{consumer-group}.retry` or `{scope}.{topic}` If the scope is missing, this function will return a wrong result

func NewTopic

func NewTopic(topic string) (Topic, error)

func TopicFromName

func TopicFromName(topicName string) Topic

func (Topic) GenerateRetryTopic added in v0.0.80

func (t Topic) GenerateRetryTopic(consumerGroup ConsumerGroup) Topic

func (Topic) TopicName

func (t Topic) TopicName(scope string) string

TopicName returns the topic name with the given scope. If the scope is empty, it returns the topic name as is. This should be used when interacting with the concrete pubsubs (e.g. Kafka).

type TraceContextPropagator added in v0.0.81

type TraceContextPropagator struct {
	// contains filtered or unexported fields
}

TraceContextPropagator is responsible for injecting and extracting trace context into and from message metadata.

func NewTraceContextPropagator added in v0.0.81

func NewTraceContextPropagator() TraceContextPropagator

func (*TraceContextPropagator) Extract added in v0.0.81

Extract extracts the trace context from the message metadata and returns a new context with the extracted trace context.

func (*TraceContextPropagator) Inject added in v0.0.81

func (t *TraceContextPropagator) Inject(ctx context.Context, m *Message)

Inject injects the trace context from the provided context into the message metadata.

Jump to

Keyboard shortcuts

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