stompt

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: 4 Imported by: 0

README

Package stompt

Пакет stompt предназначен для упрощения написания тестов, использующих STOMP-сообщения через ActiveMQ.

Types

Client

Тип Client инкапсулирует параметры подключения к STOMP-брокеру и предоставляет методы для генерации конфигураций публикаторов и консьюмеров.

Methods:

New(t *test.Test) *Client

Создаёт новый STOMP-клиент с параметрами подключения из переменных окружения ACTIVEMQ_STOMP_ADDRESS, ACTIVEMQ_USERNAME, ACTIVEMQ_PASSWORD, либо со значениями по умолчанию (127.0.0.1:61613, test, test).

(c *Client) ConsumerConfig(queue string) stompx.ConsumerConfig

Возвращает конфигурацию STOMP-консьюмера для указанной очереди. Очередь автоматически префиксируется идентификатором теста.

(c *Client) PublisherConfig(queue string) stompx.PublisherConfig

Возвращает конфигурацию STOMP-публикатора для указанной очереди. Очередь автоматически префиксируется идентификатором теста.

(c *Client) Upgrade(consumers ...consumer.Config)

Запускает консьюмеров через stompx.NewConsumerGroup, автоматически регистрируя Close() в t.Cleanup. Используется для запуска STOMP-консьюмеров в рамках тестов.

Usage

Example usage in test
package mypkg_test

import (
	"testing"
	"github.com/txix-open/isp-kit/stompt"
	"github.com/txix-open/isp-kit/test"
	"github.com/txix-open/isp-kit/stompx/consumer"
)

func TestStompExample(t *testing.T) {
	testCtx := test.New(t)
	client := stompt.New(testCtx)

	cfg := client.ConsumerConfig("example")
	cfg.Handler = consumer.HandlerFunc(func(ctx context.Context, msg consumer.Message) error {
		// Обработка сообщения
		return nil
	})

	client.Upgrade(cfg)
}

Documentation

Overview

Package stompt provides test helpers for STOMP messaging operations (typically used with ActiveMQ). It creates isolated queues for each test.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client provides a test helper for STOMP messaging operations. It manages isolated queues (prefixed with test ID) for each test.

func New

func New(t *test.Test) *Client

New creates a new STOMP test client. Connection parameters can be overridden using environment variables: ACTIVEMQ_STOMP_ADDRESS, ACTIVEMQ_USERNAME, ACTIVEMQ_PASSWORD.

func (*Client) ConsumerConfig

func (c *Client) ConsumerConfig(queue string) stompx.ConsumerConfig

ConsumerConfig returns a ConsumerConfig for the specified queue, with the queue name prefixed by the test ID for isolation.

func (*Client) PublisherConfig

func (c *Client) PublisherConfig(queue string) stompx.PublisherConfig

PublisherConfig returns a PublisherConfig for the specified queue, with the queue name prefixed by the test ID for isolation.

func (*Client) Upgrade

func (c *Client) Upgrade(config stompx.Config)

Upgrade creates a new STOMP group and upgrades it with the provided configuration. The group is automatically closed when the test completes. Panics if upgrade fails.

Jump to

Keyboard shortcuts

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