juju: github.com/juju/juju/worker/storageprovisioner/internal/schedule Index | Files

package schedule

import "github.com/juju/juju/worker/storageprovisioner/internal/schedule"


Package Files


type Schedule Uses

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 Uses

func NewSchedule(clock clock.Clock) *Schedule

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

func (*Schedule) Add Uses

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 Uses

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 Uses

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 Uses

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.

Package schedule imports 4 packages (graph) and is imported by 32 packages. Updated 2018-10-03. Refresh now. Tools for package owners.