mq

package module
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2019 License: MIT Imports: 15 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",
}
View Source
var STAGE_value = map[string]int32{
	"PENDING": 0,
	"SUCCESS": 1,
	"FAILED":  2,
}

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) Register

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

func (*JobWorker) Serve

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

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) EnumDescriptor

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

func (STAGE) String

func (x STAGE) String() string

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=mq.STAGE" json:"stage,omitempty"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func NewTask

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

func (*Task) Descriptor

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

func (*Task) GetArgv

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

func (*Task) GetId

func (m *Task) GetId() string

func (*Task) GetStage

func (m *Task) GetStage() STAGE

func (*Task) GetSubject

func (m *Task) GetSubject() string

func (*Task) ProtoMessage

func (*Task) ProtoMessage()

func (*Task) Reset

func (m *Task) Reset()

func (*Task) String

func (m *Task) String() string

func (*Task) XXX_DiscardUnknown

func (m *Task) XXX_DiscardUnknown()

func (*Task) XXX_Marshal

func (m *Task) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Task) XXX_Merge

func (m *Task) XXX_Merge(src proto.Message)

func (*Task) XXX_Size

func (m *Task) XXX_Size() int

func (*Task) XXX_Unmarshal

func (m *Task) XXX_Unmarshal(b []byte) error

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