watch

package
Version: v0.0.0-...-d6856c1 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2020 License: Apache-2.0 Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var JobQueue chan JobRequest

JobQueue : All jobs get queued here

View Source
var WorkerQueue chan chan JobRequest

WorkerQueue is a buffered channel of these channel type Each Worker/Job has an unbuffered channel to listen on

Functions

func AddJob

func AddJob(ctx context.Context, index int64, oper int32, key, value string)

AddJob adds a Job to the worker queue

func AssignJob

func AssignJob(job JobRequest)

AssignJob schedules Jobs to Workers

func InitDispatcher

func InitDispatcher(numWorkers int, callback Callback)

InitDispatcher initializes the dispatcher

func RunDispatcher

func RunDispatcher()

RunDispatcher runs the dispatcher

func WatcherInit

func WatcherInit(numJobs int)

WatcherInit intializes the Watcher

Types

type Callback

type Callback func(ctx context.Context, oper int32, key, newValue string)

Callback from Watch functions

type JobRequest

type JobRequest struct {
	JobID int64
	// contains filtered or unexported fields
}

JobRequest hold the Job

type Worker

type Worker struct {
	WorkerID    int
	JobChan     chan JobRequest
	ExitChan    chan bool
	WorkerQueue chan chan JobRequest
	Callback    Callback
}

Worker holds worker object

func CreateWorker

func CreateWorker(id int, workerQueue chan chan JobRequest, callback Callback) Worker

CreateWorker creates a New Worker - Create a JobRequest Channel to listen on - Create an ExitChan to terminate - Add self to the WorkerQueue so we get JobRequests

func (*Worker) Exit

func (g *Worker) Exit()

Exit quits a worker routine

func (*Worker) Run

func (g *Worker) Run()

Run runs a worker

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL