queue

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2016 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("queue item not found")

ErrNotFound indicates the requested work item does not exist in the queue.

Functions

func Publish

func Publish(c context.Context, w *Work) error

Publish inserts work at the tail of this queue, waiting for space to become available if the queue is full.

func Remove

func Remove(c context.Context, w *Work) error

Remove removes the specified work item from this queue, if it is present.

func ToContext

func ToContext(c Setter, q Queue)

ToContext adds the Queue to this context if it supports the Setter interface.

Types

type CloseNotifier

type CloseNotifier interface {
	// CloseNotify returns a channel that receives a single value
	// when the client connection has gone away.
	CloseNotify() <-chan bool
}

CloseNotifier defines a datastructure that is capable of notifying a subscriber when its connection is closed.

type Queue

type Queue interface {
	// Publish inserts work at the tail of this queue, waiting for
	// space to become available if the queue is full.
	Publish(*Work) error

	// Remove removes the specified work item from this queue,
	// if it is present.
	Remove(*Work) error

	// PullClose retrieves and removes the head of this queue,
	// waiting if necessary until work becomes available.
	Pull() *Work

	// PullClose retrieves and removes the head of this queue,
	// waiting if necessary until work becomes available. The
	// CloseNotifier should be provided to clone the channel
	// if the subscribing client terminates its connection.
	PullClose(CloseNotifier) *Work
}

func FromContext

func FromContext(c context.Context) Queue

FromContext returns the Queue associated with this context.

func New

func New() Queue

type Setter

type Setter interface {
	Set(string, interface{})
}

Setter defines a context that enables setting values.

type Work

type Work struct {
	Signed    bool            `json:"signed"`
	Verified  bool            `json:"verified"`
	Yaml      string          `json:"config"`
	YamlEnc   string          `json:"secret"`
	Repo      *model.Repo     `json:"repo"`
	Build     *model.Build    `json:"build"`
	BuildLast *model.Build    `json:"build_last"`
	Job       *model.Job      `json:"job"`
	Netrc     *model.Netrc    `json:"netrc"`
	Keys      *model.Key      `json:"keys"`
	System    *model.System   `json:"system"`
	Secrets   []*model.Secret `json:"secrets"`
	User      *model.User     `json:"user"`
}

Work represents an item for work to be processed by a worker.

func Pull

func Pull(c context.Context) *Work

PullClose retrieves and removes the head of this queue, waiting if necessary until work becomes available.

func PullClose

func PullClose(c context.Context, cn CloseNotifier) *Work

PullClose retrieves and removes the head of this queue, waiting if necessary until work becomes available. The CloseNotifier should be provided to clone the channel if the subscribing client terminates its connection.

Jump to

Keyboard shortcuts

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