bullpublisher

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2023 License: MIT Imports: 5 Imported by: 0

README

Go Bull publisher

Latest Version PRs Welcome

Go bull publisher is a lib that provides a publisher for bull queues

Installation
go get github.com/kiwfy/golang-bull-publisher
Usage

Below is an example which shows some common use cases for publisher.

package main

import (
	"context"
	"time"

	bullpublisher "github.com/kiwfy/golang-bull-publisher"
	"github.com/redis/go-redis/v9"
)

type testeando struct {
	Name string `json:"name"`
	Data int64  `json:"data"`
}

func main() {
	redis := redis.NewClient(&redis.Options{
		Addr: "localhost:6379",
	})
	context := context.Background()
	publisher := &bullpublisher.Publisher{
		Redis:   redis,
		Context: context,
	}

	publisher.AddJob(
		"teste",
		&testando{
			Name: "levy",
			Data: time.Now().Unix(),
		},
		bullpublisher.Options{
			Attempts:           1,
			Backoff:            0,
			Delay:              0,
			Lifo:               false,
			PreventParsingData: false,
			Priority:           0,
			RemoveOnComplete:   10,
			RemoveOnFail:       1,
			Timeout:            0,
			JobId:              "123t87236482",
			Timestamp:          time.Now().Unix(),
		},
		"process",
	)
}

Kiwfy - Open your code, open your mind!

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	Attempts           int    `json:"attempts"`
	Backoff            int    `json:"backoff"`
	Delay              int64  `json:"delay"`
	Lifo               bool   `json:"lifo"`
	PreventParsingData bool   `json:"preventParsingData"`
	Priority           int    `json:"priority"`
	RemoveOnComplete   int    `json:"removeOnComplete"`
	RemoveOnFail       int    `json:"removeOnFail"`
	Timeout            int    `json:"timeout"`
	JobId              string `json:"jobId"`
	Timestamp          int64  `json:"timestamp"`
}

type Publisher

type Publisher struct {
	Redis   *redis.Client
	Context context.Context
}

func (*Publisher) AddJob

func (publisher *Publisher) AddJob(
	queue string,
	data any,
	opts Options,
	name string,
) error

Jump to

Keyboard shortcuts

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