async

package
v0.0.0-...-fe73bcc Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2018 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package async implements job.Handler interface.

Example
package main

import (
	"fmt"

	"github.com/armen/dp/job"
	"github.com/armen/dp/job/handler/async"
)

func main() {
	var msg = make(chan string)

	jh := async.New()
	jh.Confirm(func(j job.Job) {
		msg <- fmt.Sprintln("Confirmed", j)
	})

	jh.Submit("Job 1")
	jh.Submit("Job 2")
	jh.Submit("Job 3")

	fmt.Print(<-msg)
	fmt.Print(<-msg)
	fmt.Print(<-msg)

}
Output:

Confirmed Job 1
Confirmed Job 2
Confirmed Job 3

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JobHandler

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

JobHandler stores the state of an asynchronous job handler.

func New

func New() *JobHandler

New instantiates a new asynchronous job handler.

func (*JobHandler) Confirm

func (jh *JobHandler) Confirm(f func(job.Job))

Confirm registers the confirm handler.

func (*JobHandler) Process

func (jh *JobHandler) Process(f func(job.Job))

Process registers the process handler.

func (*JobHandler) Submit

func (jh *JobHandler) Submit(j job.Job)

Submit submits a job to be processed.

Jump to

Keyboard shortcuts

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