sneaker

package module
v2.2.2 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2020 License: MIT Imports: 5 Imported by: 0

README

SneakerWorker for Golang

Dependencies 依赖
  • RabbitMQ
Usage 使用方法

1.在你的项目中的config目录下创建以下两个文件

amqp.yml
workers.yml

This is a example.

2.workers

example 示例

3.main

example 示例

workers.yml配置说明
---
- name: TreatWorker  # worker的名称
  exchange: sneaker.example.default  # 消息经过的Exchange
  routing_key: sneaker.example.treat  # 消息经过的routing_key
  queue: sneaker.example.treat  # 消息进入的queue
  durable: true
  ack: true  # 是否ack
  threads: 1  # 并发处理数量
  steps:  # 重试队列的延时配置
    - 5000       # 5 Second
    - 30000      # 30 Second
    - 60000      # 1 Minute

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SubscribeMessageByQueue

func SubscribeMessageByQueue(RabbitMqConnect *amqp.Connection, worker Worker, arguments amqp.Table) (err error)

Types

type Exception

type Exception struct {
	Msg string
}

type RabbitMqConnect

type RabbitMqConnect struct {
	*amqp.Connection
}

func (*RabbitMqConnect) DeclareExchange

func (conn *RabbitMqConnect) DeclareExchange(name, kind string, durable, autoDelete, internal, noWait bool, arguments amqp.Table) error

func (*RabbitMqConnect) DeclareQueue

func (conn *RabbitMqConnect) DeclareQueue(queueName string, durable, autoDelete, internal, noWait bool, arguments amqp.Table) error

func (*RabbitMqConnect) PublishMessageToQueue

func (conn *RabbitMqConnect) PublishMessageToQueue(queue, contentType string, message *[]byte, arguments amqp.Table, deliveryMode uint8, expiration string) error

func (*RabbitMqConnect) PublishMessageWithRouteKey

func (conn *RabbitMqConnect) PublishMessageWithRouteKey(exchange, routeKey, contentType string, message *[]byte, arguments amqp.Table, deliveryMode uint8, expiration string) error

func (*RabbitMqConnect) QueueBind

func (conn *RabbitMqConnect) QueueBind(name, key, exchange string, noWait bool, arguments amqp.Table) error

type Worker

type Worker interface {
	GetName() string
	GetExchange() string
	GetExchangeType() string
	GetRoutingKey() string
	GetQueue() string
	GetDurable() bool
	GetDelay() bool
	GetOptions() map[string]string
	GetArguments() map[string]string
	GetSteps() []int32
	GetThreads() int
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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