loader

package module
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2019 License: MIT Imports: 3 Imported by: 0

README

Loader

GoDoc Report card

Loader is a generic utility to execute function via batching.
The intent is to reduce the number of calls to your function or method.

Getting started

$ go get github.com/rafaelsq/loader

Usage

See loader_test.go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Loader

type Loader struct {
	sync.Mutex

	MaxBatch int
	Timeout  time.Duration
	Fn       func(baseCtx context.Context, IDs []int64) (interface{}, error)
	// contains filtered or unexported fields
}

func (*Loader) Get

func (t *Loader) Get(ctx context.Context, id int64) chan Response

type Response

type Response struct {
	Error error
	Value interface{}
}

Jump to

Keyboard shortcuts

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