rabbitmq

package module
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RabbitMQ

type RabbitMQ struct {
	Connection *amqp.Connection
	Channel    *amqp.Channel
	Config     RabbitMQConfig
	Receivers  []port.PubSubReceiver
}

func NewRabbitMQ

func NewRabbitMQ(ctx context.Context, cfg RabbitMQConfig) (*RabbitMQ, error)

func (*RabbitMQ) Connect

func (r *RabbitMQ) Connect() error

func (*RabbitMQ) Disconnect

func (r *RabbitMQ) Disconnect() error

func (*RabbitMQ) Install

func (r *RabbitMQ) Install(args ...any) error

func (*RabbitMQ) Publish

func (r *RabbitMQ) Publish(ctx context.Context, message any, attributes map[string]string) (string, error)

func (*RabbitMQ) RegisterReceiver

func (r *RabbitMQ) RegisterReceiver(receiver port.PubSubReceiver)

func (*RabbitMQ) StartReceiving

func (r *RabbitMQ) StartReceiving(ctx context.Context)

func (*RabbitMQ) Uninstall

func (r *RabbitMQ) Uninstall() error

type RabbitMQConfig

type RabbitMQConfig struct {
	Subscription         string                `mapstructure:"subscription"`
	Topic                string                `mapstructure:"topic"`
	Uri                  string                `mapstructure:"uri"`           // amqp://user:pass@host:port/vhost
	ExchangeType         string                `mapstructure:"exchange_type"` // direct, fanout, topic, headers, none (tanpa exchage = message queue biasa)
	Durable              bool                  `mapstructure:"durable"`
	AutoDelete           bool                  `mapstructure:"auto_delete"`
	Exclusive            bool                  `mapstructure:"exclusive"`
	PrefetchCount        int                   `mapstructure:"prefetch_count"`
	MaxReconnectAttempts int                   `mapstructure:"max_reconnect_attempts"`
	Producer             config.ProducerConfig `mapstructure:"producer"`
	Workers              int                   `mapstructure:"workers" json:"workers"` // jumlah worker paralel untuk proses message
}

func (*RabbitMQConfig) GetMaxReconnectAttempts added in v0.1.8

func (c *RabbitMQConfig) GetMaxReconnectAttempts() int

func (*RabbitMQConfig) GetWorkers added in v0.1.9

func (c *RabbitMQConfig) GetWorkers() int

func (*RabbitMQConfig) SetDefaults

func (c *RabbitMQConfig) SetDefaults() map[string]any

func (*RabbitMQConfig) SetEnvBindings

func (c *RabbitMQConfig) SetEnvBindings() map[string]string

type RabbitMQLoader

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

func (*RabbitMQLoader) Init

func (l *RabbitMQLoader) Init(args ...any) (port.Library, error)

func (*RabbitMQLoader) Name

func (a *RabbitMQLoader) Name() string

func (*RabbitMQLoader) SetName

func (a *RabbitMQLoader) SetName(name string)

type RabbitMQMessage

type RabbitMQMessage struct {
	ID          string
	Data        []byte
	PublishTime time.Time
	Attributes  map[string]string
}

func (*RabbitMQMessage) GetAttributes

func (m *RabbitMQMessage) GetAttributes() map[string]string

func (*RabbitMQMessage) GetData

func (m *RabbitMQMessage) GetData() []byte

func (*RabbitMQMessage) GetID

func (m *RabbitMQMessage) GetID() string

func (*RabbitMQMessage) GetPublishTime

func (m *RabbitMQMessage) GetPublishTime() time.Time

Jump to

Keyboard shortcuts

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