internal

package
v0.0.0-...-d6baa2e Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NEW     ReqAction = "NEW"
	CANCEL            = "CANCEL"
	REPLACE           = "REPLACE"
)

Variables

View Source
var JobQueue = make(chan Job)

JobQueue is a buffered channel that we can send work requests on.

Functions

This section is empty.

Types

type Dispatcher

type Dispatcher struct {
	// A pool of workers channels that are registered with the dispatcher
	WorkerPool chan chan Job
	// contains filtered or unexported fields
}

func NewDispatcher

func NewDispatcher(maxWorkers int) *Dispatcher

func (*Dispatcher) Run

func (d *Dispatcher) Run()

type Job

type Job struct {
	Payload Payload
}

Job represents the job to be run

type KafkaConsumer

type KafkaConsumer struct {
	Consumer *kafka.Consumer
	Topics   []string
	// contains filtered or unexported fields
}

KafkaConsumer represents the kafka consumer

func NewKafkaConsumer

func NewKafkaConsumer(broker, group string, topics []string) KafkaConsumer

func (KafkaConsumer) ConsumeTopics

func (k KafkaConsumer) ConsumeTopics()

func (KafkaConsumer) Stop

func (k KafkaConsumer) Stop()

Stop signals the worker to stop listening for work requests.

type Payload

type Payload struct {
	ID     string          `json:"id"`
	Type   ReqType         `json:"type"`
	Action ReqAction       `json:"action"`
	Data   json.RawMessage `json:"data"`
}

type ReqAction

type ReqAction string

type ReqType

type ReqType string

type Response

type Response struct {
	ErrorCode    int32
	ErrorMessage *string
	Payload      *Payload
}

Response struct{}

type Worker

type Worker struct {
	WorkerPool chan chan Job
	JobChannel chan Job
	// contains filtered or unexported fields
}

Worker represents the worker that executes the job

func NewWorker

func NewWorker(workerPool chan chan Job) Worker

func (Worker) Start

func (w Worker) Start()

Start method starts the run loop for the worker, listening for a quit channel in case we need to stop it

func (Worker) Stop

func (w Worker) Stop()

Stop signals the worker to stop listening for work requests.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳