runner

package module
v0.0.0-...-307fc03 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2017 License: MIT Imports: 1 Imported by: 3

README

Runner Build Status GoDoc Go Report Card

Runner runs anything with a Run() method. Perfect for API servers with background tasks, health check endpoints, or anything else that does long-lived, blocking work.

package main

import "github.com/kochman/runner"

func main() {
    r := runner.New()
    r.Add(myRunnable{})
    r.Add(anotherRunnable{})
    r.Run()
}

Documentation

Overview

Package runner provides a way for programs to easily be concurrent.

Anything that implements the Runnable interface can be added to a Runner, and then the Runner can run all of its Runnables. Runner also implements the Runnable interface, so they can be nested as necessary.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Runnable

type Runnable interface {
	Run()
}

A Runnable has a Run method that can block forever.

type Runner

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

Runner tracks and runs Runnables.

func New

func New() *Runner

New creates a new Runner

func (*Runner) Add

func (r *Runner) Add(runnable Runnable)

Add adds a Runnable to the Runner.

func (*Runner) Run

func (r *Runner) Run()

Run runs all added Runnables concurrently.

Jump to

Keyboard shortcuts

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