Skip to content

Commit

Permalink
golint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dustin committed Jan 10, 2014
1 parent b2443c5 commit 3d4d8a7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
17 changes: 9 additions & 8 deletions saturate.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Saturate is a tool for keeping pipelines busy.
// Package saturate is a tool for keeping pipelines busy.
package saturate

import (
"reflect"
"sync"
)

// Input to the worker.
// WorkInput is the input to the worker.
type WorkInput struct {
// The work item the worker should receive.
Input interface{}
Expand All @@ -19,7 +19,7 @@ type destInput struct {
res chan error
}

// Configuration for the worker.
// Config for the worker.
type Config struct {
// Number of concurrent workers per destination.
DestConcurrency int
Expand All @@ -29,19 +29,20 @@ type Config struct {
Retries int
}

// A worker performs a single item of work.
// A Worker performs a single item of work.
type Worker interface {
Work(interface{}) error
}

// Convenience type to make a worker from a function.
// WorkerFunc is a convenience type to make a worker from a function.
type WorkerFunc func(interface{}) error

// Work satisfies the Worker interface for a WorkerFunc
func (w WorkerFunc) Work(i interface{}) error {
return w(i)
}

// Default configuration for Saturators.
// DefaultConfig for Saturators.
var DefaultConfig = Config{
DestConcurrency: 2,
TotalConcurrency: 4,
Expand All @@ -57,7 +58,7 @@ type Saturator struct {
conf *Config
}

// Build a new saturator.
// New builds a new saturator.
func New(dests []string, w func(dest string) Worker,
conf *Config) *Saturator {

Expand Down Expand Up @@ -137,7 +138,7 @@ func (s *Saturator) fanout(input <-chan WorkInput,
}
}

// Do all the tasks specified by the input.
// Saturate distributes all the tasks specified by the input.
//
// Return error if any input task fails execution on all retries.
func (s *Saturator) Saturate(input <-chan WorkInput) error {
Expand Down
6 changes: 3 additions & 3 deletions saturate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"testing"
)

var aFails = errors.New("I'm a. I fail")
var errAFails = errors.New("i'm a. I fail")

func TestSaturation(t *testing.T) {
l := sync.Mutex{}
Expand All @@ -24,7 +24,7 @@ func TestSaturation(t *testing.T) {

// "a" always fails
if name == "a" {
return aFails
return errAFails
}
// Mark that we did it
x := i.(string)
Expand Down Expand Up @@ -79,7 +79,7 @@ func TestSaturationFails(t *testing.T) {
return WorkerFunc(func(i interface{}) error {
// "a" always fails
if name == "a" {
return aFails
return errAFails
}

l.Lock()
Expand Down

0 comments on commit 3d4d8a7

Please sign in to comment.