shelf

package
v2.3.6+incompatible Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2018 License: Apache-2.0 Imports: 6 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Package

type Package struct {
	Cancel context.CancelFunc
	Data   interface{}
	// contains filtered or unexported fields
}

Package is a data entry with a context to ensure async execution or cancellation if necessary

func (*Package) Start

func (p *Package) Start(tbk *io.TimeBucketKey, h ShelfHandler)

Start causes the package to begin listening to it's context's done channel which is set by the deadline passed to the context. This is done in a separate goroutine

func (*Package) Stop

func (p *Package) Stop()

Stop the package from running the handler on its data and call its context's cancel function to gracefully deallocate its resources

type Shelf

type Shelf struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Shelf stores packages, which have shelf lives (^^) and are meant to have the shelf's handler executed after some deadline

func NewShelf

func NewShelf(h ShelfHandler) *Shelf

NewShelf initializes a new shelf with the provided handler function

func (*Shelf) Store

func (s *Shelf) Store(tbk *io.TimeBucketKey, data interface{}, deadline time.Time)

Store a new package to the shelf. This operation cancels, and replaces the existing package with the same TimeBucketKey on the shelf, so make sure not to prematurely store new packages before the previous have a chance to finish naturally.

type ShelfHandler

type ShelfHandler *func(tbk io.TimeBucketKey, data interface{}) error

ShelfHandler gets executed by a shelf on its packages

func NewShelfHandler

func NewShelfHandler(f func(tbk io.TimeBucketKey, data interface{}) error) ShelfHandler

NewShelfHandler creates a new ShelfHandler from a supplied function

Jump to

Keyboard shortcuts

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