portableMq

package module
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2020 License: Apache-2.0 Imports: 17 Imported by: 0

README

portableMq

install:

go get -u github.com/aircraft95/portableMq

use:

package main

import (
	"fmt"
	"github.com/aircraft95/portableMq"
	"github.com/mediocregopher/radix/v3"
	"time"
)


func main() {
	connFunc := func(network, addr string) (radix.Conn, error) {
		return radix.Dial(network, addr,
			radix.DialTimeout(1*time.Minute),
		)
	}
	redisPool, _ := radix.NewPool("tcp", ":6379", 10, radix.PoolConnFunc(connFunc))
	job := portableMq.NewJob("test", "/fail-queue.json", 1, redisPool, func(message portableMq.Message) bool {
		data := message.Data
		fmt.Println(data)
		return true
	})
	data := map[string]interface{}{
		"name": "mike",
		"age":  32,
	}
        //Immediate message
	_ = job.Push(data)
  
        //DelayPush message
	_ = job.DelayPush(data, 50)

	time.Sleep(time.Second * 100)

}

Documentation

Overview

golang+redis 简单版mq ,有ack功能

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetJob

func GetJob(name string) (*job, error)

func InitJobPool added in v1.2.0

func InitJobPool(beforeCloseCallback func()) error

func NewJob

func NewJob(name, persistentPath string, num int64, conn *radix.Pool, handler handlerFunc) *job

example:

job := mq.NewJob("test", "/fail-queue.json", 1, redis.GetPool(), func(message mq.Message) bool {
	data := message.Data
	fmt.Println(data)
	return true
})

Types

type Message

type Message struct {
	Id   string
	Data interface{}
}

Jump to

Keyboard shortcuts

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