worker

package
v0.0.0-...-045890f Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2019 License: Apache-2.0 Imports: 15 Imported by: 1

README

worker

import "github.com/go-orion/Orion/utils/worker"

Overview

Imported Packages

Index

Package files

config.go types.go worker.go workerinfo.go

type Config

type Config struct {
    LocalMode    bool
    RabbitConfig *RabbitMQConfig
}

Config is the config used to intialize workers

type RabbitMQConfig

type RabbitMQConfig struct {
    UserName    string
    Password    string
    BrokerVHost string
    Host        string
    Port        string
    QueueName   string
}

RabbitMQConfig is the config used for scheduling tasks through rabbitmq

type ScheduleConfig

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

ScheduleConfig is the config used when scheduling a task

type ScheduleOption

type ScheduleOption func(*ScheduleConfig)

ScheduleOption represents different options available for Schedule

func WithQueueName
func WithQueueName(queueName string) ScheduleOption

WithQueueName sets the destination queue for this task

func WithRetry
func WithRetry(n int) ScheduleOption

WithRetry sets the number of Retries for this task

type Work

type Work func(ctx context.Context, payload string) error

Work is the type of task that can be exeucted by Worker

type Worker

type Worker interface {
    Schedule(ctx context.Context, name, payload string, options ...ScheduleOption) error
    RegisterTask(name string, taskFunc Work) error
    RunWorker(name string, concurrency int)
    CloseWorker()
}

Worker is the interface for worker

func NewWorker
func NewWorker(config Config) Worker

NewWorker creates a new worker from given config


Generated by godoc2ghmd

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	LocalMode    bool
	RabbitConfig *RabbitMQConfig
}

Config is the config used to intialize workers

type RabbitMQConfig

type RabbitMQConfig struct {
	UserName    string
	Password    string
	BrokerVHost string
	Host        string
	Port        string
	QueueName   string
}

RabbitMQConfig is the config used for scheduling tasks through rabbitmq

type ScheduleConfig

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

ScheduleConfig is the config used when scheduling a task

type ScheduleOption

type ScheduleOption func(*ScheduleConfig)

ScheduleOption represents different options available for Schedule

func WithQueueName

func WithQueueName(queueName string) ScheduleOption

WithQueueName sets the destination queue for this task

func WithRetry

func WithRetry(n int) ScheduleOption

WithRetry sets the number of Retries for this task

type Work

type Work func(ctx context.Context, payload string) error

Work is the type of task that can be exeucted by Worker

type Worker

type Worker interface {
	Schedule(ctx context.Context, name, payload string, options ...ScheduleOption) error
	RegisterTask(name string, taskFunc Work) error
	RunWorker(name string, concurrency int)
	CloseWorker()
}

Worker is the interface for worker

func NewWorker

func NewWorker(config Config) Worker

NewWorker creates a new worker from given config

Jump to

Keyboard shortcuts

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