mq

package module
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2021 License: MIT Imports: 16 Imported by: 0

README

MsgQueue

GoDoc Widget Build Status codecov Go Report Card

A simple msg queue

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	STAGE_name = map[int32]string{
		0: "PENDING",
		1: "SUCCESS",
		2: "FAILED",
	}
	STAGE_value = map[string]int32{
		"PENDING": 0,
		"SUCCESS": 1,
		"FAILED":  2,
	}
)

Enum value maps for STAGE.

Functions

This section is empty.

Types

type JobBoard

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

func NewJobBoard

func NewJobBoard(taskMgr TaskMgr) *JobBoard

func (*JobBoard) Dispatch

func (b *JobBoard) Dispatch(channel string, task *Task) error

type JobWorker

type JobWorker struct {
	JobWorkerOpts
	// contains filtered or unexported fields
}

func NewJobWorker

func NewJobWorker(taskMgr TaskMgr, opts JobWorkerOpts) *JobWorker

func (*JobWorker) Context added in v1.3.0

func (w *JobWorker) Context() context.Context

func (*JobWorker) Register

func (w *JobWorker) Register(router *courier.Router)

func (*JobWorker) Serve

func (w *JobWorker) Serve(router *courier.Router) error

func (*JobWorker) WithContextInjector added in v1.3.0

func (w *JobWorker) WithContextInjector(contextInjector func(ctx context.Context) context.Context) *JobWorker

type JobWorkerOpts

type JobWorkerOpts struct {
	Channel    string
	NumWorkers int
	OnFinish   func(ctx context.Context, task *Task)
}

type STAGE

type STAGE int32
const (
	STAGE_PENDING STAGE = 0
	STAGE_SUCCESS STAGE = 1
	STAGE_FAILED  STAGE = 2
)

func (STAGE) Descriptor added in v1.3.1

func (STAGE) Descriptor() protoreflect.EnumDescriptor

func (STAGE) Enum added in v1.3.1

func (x STAGE) Enum() *STAGE

func (STAGE) EnumDescriptor deprecated

func (STAGE) EnumDescriptor() ([]byte, []int)

Deprecated: Use STAGE.Descriptor instead.

func (STAGE) Number added in v1.3.1

func (x STAGE) Number() protoreflect.EnumNumber

func (STAGE) String

func (x STAGE) String() string

func (STAGE) Type added in v1.3.1

func (STAGE) Type() protoreflect.EnumType

type Task

type Task struct {
	Subject string `protobuf:"bytes,1,opt,name=subject,proto3" json:"subject,omitempty"`
	Id      string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"`
	Argv    []byte `protobuf:"bytes,3,opt,name=argv,proto3" json:"argv,omitempty"`
	Stage   STAGE  `protobuf:"varint,4,opt,name=stage,proto3,enum=proto.STAGE" json:"stage,omitempty"`
	// contains filtered or unexported fields
}

func NewTask

func NewTask(subject string, argv []byte, id string) *Task

func (*Task) Descriptor deprecated

func (*Task) Descriptor() ([]byte, []int)

Deprecated: Use Task.ProtoReflect.Descriptor instead.

func (*Task) GetArgv

func (x *Task) GetArgv() []byte

func (*Task) GetId

func (x *Task) GetId() string

func (*Task) GetStage

func (x *Task) GetStage() STAGE

func (*Task) GetSubject

func (x *Task) GetSubject() string

func (*Task) ProtoMessage

func (*Task) ProtoMessage()

func (*Task) ProtoReflect added in v1.3.1

func (x *Task) ProtoReflect() protoreflect.Message

func (*Task) Reset

func (x *Task) Reset()

func (*Task) String

func (x *Task) String() string

type TaskMgr

type TaskMgr interface {
	Push(channel string, task *Task) error
	Shift(channel string) (*Task, error)
	Remove(channel string, id string) error
	Destroy(channel string) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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