package
0.0.0-20190220103131-045890faf5e6
Repository: https://github.com/go-orion/orion.git
Documentation: pkg.go.dev

# 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

# Functions

NewWorker creates a new worker from given config.
WithQueueName sets the destination queue for this task.
WithRetry sets the number of Retries for this task.

# Structs

Config is the config used to intialize workers.
RabbitMQConfig is the config used for scheduling tasks through rabbitmq.
ScheduleConfig is the config used when scheduling a task.

# Interfaces

Worker is the interface for worker.

# Type aliases

ScheduleOption represents different options available for Schedule.
Work is the type of task that can be exeucted by Worker.