rabbitmq

package
v1.67.2 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2026 License: MIT Imports: 2 Imported by: 0

README

Package rabbitmq

Пакет rabbitmq содержит вспомогательные утилиты и адаптеры для взаимодействия с AMQP 0.9.1 (RabbitMQ), в частности для работы с заголовками сообщений (TableCarrier) и построения строки назначения (Destination).

Types

TableCarrier

Тип TableCarrier является адаптером типа amqp091.Table и реализует интерфейс TextMapCarrier из OpenTelemetry. Он позволяет работать с AMQP-заголовками в виде пары ключ-значение.

Methods:

(c TableCarrier) Get(key string) string

Получить строковое значение по ключу. Если ключ отсутствует, возвращается пустая строка.

(c TableCarrier) Set(key string, value string)

Установить строковое значение по заданному ключу. Преобразование обратно в тип interface{} осуществляется автоматически.

(c TableCarrier) Keys() []string

Возвращает список всех ключей в TableCarrier.

Functions

func Destination(exchange string, routingKey string) string

Формирует строку назначения на основе переданных exchange и routingKey. Если exchange пустой, возвращается только routingKey. В противном случае результат имеет вид exchange/routingKey.

Usage

Default usage flow
package main

import (
	"fmt"

	"github.com/txix-open/isp-kit/transport/rabbitmq"
)

func main() {
	table := rabbitmq.TableCarrier{}
	table.Set("trace_id", "12345")
	fmt.Println("Trace ID:", table.Get("trace_id"))
	fmt.Println("Keys:", table.Keys())

	dest := rabbitmq.Destination("logs", "info")
	fmt.Println("Destination:", dest)
}

Documentation

Overview

Package rabbitmq provides utilities for RabbitMQ tracing integration.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Destination

func Destination(exchange string, routingKey string) string

Destination creates a destination identifier from an exchange and routing key. If the exchange is empty, it returns just the routing key; otherwise, it returns the exchange and routing key joined by a forward slash.

Types

type TableCarrier

type TableCarrier amqp091.Table

TableCarrier implements the TextMapCarrier interface for AMQP message headers.

func (TableCarrier) Get

func (c TableCarrier) Get(key string) string

Get returns the string representation of the value associated with the given key. It returns an empty string if the key does not exist.

func (TableCarrier) Keys

func (c TableCarrier) Keys() []string

Keys returns all keys in the message headers.

func (TableCarrier) Set

func (c TableCarrier) Set(key string, value string)

Set associates a key-value pair in the message headers.

Directories

Path Synopsis
Package consumer_tracing provides RabbitMQ consumer middleware for distributed tracing.
Package consumer_tracing provides RabbitMQ consumer middleware for distributed tracing.
Package publisher_tracing provides RabbitMQ publisher middleware for distributed tracing.
Package publisher_tracing provides RabbitMQ publisher middleware for distributed tracing.

Jump to

Keyboard shortcuts

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