mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-12-22 08:27:06 +00:00
21 lines
443 B
Go
21 lines
443 B
Go
package bus
|
|
|
|
import "golang.org/x/net/context"
|
|
|
|
const key = "bus"
|
|
|
|
// Setter defines a context that enables setting values.
|
|
type Setter interface {
|
|
Set(string, interface{})
|
|
}
|
|
|
|
// FromContext returns the Bus associated with this context.
|
|
func FromContext(c context.Context) Bus {
|
|
return c.Value(key).(Bus)
|
|
}
|
|
|
|
// ToContext adds the Bus to this context if it supports
|
|
// the Setter interface.
|
|
func ToContext(c Setter, b Bus) {
|
|
c.Set(key, b)
|
|
}
|