custodian

package
v0.0.0-...-1d5e6b2 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2016 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Custodian

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

Custodian provides a timeout service for objects. The timeout is the same for all enqueued objects. Order is retained.

func New

func New(timeout time.Duration, notifyCb CustodyNotify) *Custodian

New creates a new Custodian. Timeout specifies the timeout of the Custodian, notifyCb specifies the callback function that is called by the Custodian when a timeout expires.

func (*Custodian) Elements

func (c *Custodian) Elements() []CustodyPair

Elements returns all objects that are currently under custody.

func (*Custodian) InCustody

func (c *Custodian) InCustody(id string) bool

InCustody returns true if an object is in custody

func (*Custodian) Register

func (c *Custodian) Register(id string, data interface{})

Register enqueues a new object to the custodian. The data object is referred to by id.

func (*Custodian) Remove

func (c *Custodian) Remove(id string) bool

Remove removes an object from custody. No callback will be invoked on this object anymore.

func (*Custodian) RemoveAll

func (c *Custodian) RemoveAll() []CustodyPair

RemoveAll deletes all objects from custody. No callbacks will be invoked. RemoveAll returns all objects that have been under custody.

func (*Custodian) Stop

func (c *Custodian) Stop()

Stop closes down all Custodian activity. Only used for tests.

type CustodyNotify

type CustodyNotify func(id string, data interface{})

CustodyNotify is the callback function type as called by the Custodian when the timeout expires

type CustodyPair

type CustodyPair struct {
	ID   string
	Data interface{}
}

CustodyPair is a tuple of enqueued id and data object

Jump to

Keyboard shortcuts

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