mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-20 08:51:01 +00:00
23 lines
462 B
Go
23 lines
462 B
Go
package queue
|
|
|
|
import (
|
|
"golang.org/x/net/context"
|
|
)
|
|
|
|
const key = "queue"
|
|
|
|
// Setter defines a context that enables setting values.
|
|
type Setter interface {
|
|
Set(string, interface{})
|
|
}
|
|
|
|
// FromContext returns the Queue associated with this context.
|
|
func FromContext(c context.Context) Queue {
|
|
return c.Value(key).(Queue)
|
|
}
|
|
|
|
// ToContext adds the Queue to this context if it supports
|
|
// the Setter interface.
|
|
func ToContext(c Setter, q Queue) {
|
|
c.Set(key, q)
|
|
}
|