std

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2024 License: BSD-3-Clause Imports: 10 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Invoker = func(payloadType reflect.Type, payloadValue, funcValue reflect.Value, funcType reflect.Type) error {

	var result []reflect.Value
	if payloadType.Kind() == reflect.Ptr {
		result = funcValue.Call([]reflect.Value{payloadValue})
	} else {
		result = funcValue.Call([]reflect.Value{reflect.Indirect(payloadValue)})
	}
	if len(result) > 0 {
		intf := result[0].Interface()
		if e, ok := intf.(error); ok {
			return e
		}
	}

	return nil
}

Functions

func GetHandler

func GetHandler(name string) (interface{}, bool)

func GetPayloadName

func GetPayloadName(payload interface{}) string

func InvokeHandler

func InvokeHandler(payload interface{}) (e error)

func Listen added in v0.0.4

func Listen(job interface{}, fn interface{})

func MarshalPayload

func MarshalPayload(payload interface{}) ([]byte, error)

Types

type Job

type Job struct {
	ID          string
	PayloadType string
	Payload     []byte
}

func ToJob

func ToJob(payload interface{}) (j Job, e error)

func (Job) Invoke

func (j Job) Invoke(before ...func(payloadType reflect.Type, payloadValue reflect.Value)) (e error)

type NsqHandler added in v0.0.8

type NsqHandler struct {
}

func (NsqHandler) HandleMessage added in v0.0.8

func (NsqHandler) HandleMessage(m *nsq.Message) error

type Worker

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

func NewWorker

func NewWorker(concurrency int, connection contracts.Connection) *Worker

func (*Worker) Close

func (w *Worker) Close() error

func (*Worker) Run

func (w *Worker) Run(done chan struct{}, handler contracts.ErrorHandler) error

Jump to

Keyboard shortcuts

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