mw

package module
v0.0.0-...-1711722 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2024 License: MIT Imports: 7 Imported by: 0

README

mw

Multi Worker Golang

Example

    manager := mw.New()
    worker := mw.NewRabbitMQRouter(
		"handlerName",
		"queueName",
		conn,
		handler,
		mw.WithTimeout(timeout),
		mw.WithAutoCommit(),
		mw.WithMultiplierWorkerPool(2),
	)

    manager.Register(worker)
    manager.Run()

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() *manager

func NewConnectRabbitMQ

func NewConnectRabbitMQ(uri string) (*amqp.Connection, error)

Types

type Event

type Event interface {
	SetContext(context.Context)
	Context() context.Context
	Bind(interface{}) error
	ID() string
}

type HandlerFunction

type HandlerFunction func(Event) error

type RabbitMQRouterOptions

type RabbitMQRouterOptions func(*rabbitMQRouter)

func WithAutoCommit

func WithAutoCommit() RabbitMQRouterOptions

func WithMultiplierWorkerPool

func WithMultiplierWorkerPool(n int) RabbitMQRouterOptions

func WithTimeout

func WithTimeout(t time.Duration) RabbitMQRouterOptions

type Router

type Router interface {
	Commit(Event) error
	Producer(chan<- Event)
	Handler() HandlerFunction
	Pool() int
}

func NewRabbitMQRouter

func NewRabbitMQRouter(queue, name string, conn *amqp.Connection, handler HandlerFunction, options ...RabbitMQRouterOptions) Router

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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