Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Schedule

type Schedule struct {

	// contains filtered or unexported fields

}

Schedule provides a schedule for storage operations, with the following properties:

- fast to add and remove items by key: O(log(n)); n is the total number of items
- fast to identify/remove the next scheduled item: O(log(n))

func NewSchedule

func NewSchedule(clock clock.Clock) *Schedule

NewSchedule constructs a new schedule, using the given Clock for the Next method.

func (*Schedule) Add

func (s *Schedule) Add(key, value interface{}, t time.Time)

Add adds an item with the specified value, with the corresponding key and time to the schedule. Add will panic if there already exists an item with the same key.

func (*Schedule) Next

func (s *Schedule) Next() <-chan time.Time

Next returns a channel which will send after the next scheduled item's time has been reached. If there are no scheduled items, nil is returned.

func (*Schedule) Ready

func (s *Schedule) Ready(now time.Time) []interface{}

Ready returns the parameters for items that are scheduled at or before "now", and removes them from the schedule. The resulting slices are in order of time; items scheduled for the same time have no defined relative order.

func (*Schedule) Remove

func (s *Schedule) Remove(key interface{})

Remove removes the item corresponding to the specified key from the schedule. If no item with the specified key exists, this is a no-op.

Source Files