Documentation
¶
Overview ¶
Package docker provides a Docker driver for Fn. Provides an implementation of
github.com/fnproject/fn/api/agent/drivers.Driver
that knows how to run Docker images.
Index ¶
- Constants
- Variables
- func RecordImageCleanerStats(ctx context.Context, sample *ImageCacherStats)
- func RecordInstanceId(ctx context.Context, id string)
- func RecordWaitContainerResult(ctx context.Context, exitCode int)
- func RegisterViews(tagKeys []string, latencyDist []float64)
- type Auther
- type CachedImage
- type DockerDriver
- type DockerPool
- type DockerPoolStats
- type ImageCacher
- type ImageCacherStats
- type PoolTaskStateType
Constants ¶
View Source
const ( FnAgentClassifierLabel = "fn-agent-classifier" FnAgentInstanceLabel = "fn-agent-instance" )
View Source
const ( LimitPerSec = 10 LimitBurst = 20 )
Variables ¶
View Source
var (
ErrorPoolEmpty = errors.New("docker pre fork pool empty")
)
Functions ¶
func RecordImageCleanerStats ¶ added in v0.3.647
func RecordImageCleanerStats(ctx context.Context, sample *ImageCacherStats)
func RecordInstanceId ¶ added in v0.3.647
func RegisterViews ¶
RegisterViews creates and registers views with provided tag keys
Types ¶
type Auther ¶
type Auther interface {
// DockerAuth should return docker auth credentials that will authenticate
// against a docker registry for a given drivers.ContainerTask.Image(). An
// error may be returned which will cause the task not to be run, this can be
// useful for an implementer to do things like testing auth configurations
// before returning them; e.g. if the implementer would like to impose
// certain restrictions on images or if credentials must be acquired right
// before runtime and there's an error doing so. If these credentials don't
// work, the docker pull will fail and the task will be set to error status.
DockerAuth() (*docker.AuthConfiguration, error)
}
A drivers.ContainerTask should implement the Auther interface if it would like to use not-necessarily-public docker images for any or all task invocations.
type CachedImage ¶ added in v0.3.645
type DockerDriver ¶
type DockerDriver struct {
// contains filtered or unexported fields
}
func (*DockerDriver) Close ¶
func (drv *DockerDriver) Close() error
func (*DockerDriver) CreateCookie ¶
func (drv *DockerDriver) CreateCookie(ctx context.Context, task drivers.ContainerTask) (drivers.Cookie, error)
func (*DockerDriver) PrepareCookie ¶
Obsoleted.
type DockerPool ¶
type DockerPool interface {
// fetch a pre-allocated free id from the pool
// may return too busy error.
AllocPoolId() (string, error)
// Release the id back to the pool
FreePoolId(id string)
// stop and terminate the pool
Close() error
// returns inuse versus free
Usage() DockerPoolStats
}
func NewDockerPool ¶
func NewDockerPool(conf drivers.Config, driver *DockerDriver) DockerPool
type DockerPoolStats ¶
type DockerPoolStats struct {
// contains filtered or unexported fields
}
type ImageCacher ¶ added in v0.3.645
type ImageCacher interface {
// IsMaxCapacity returns true if total size of all images exceeds the limit
// and if there's an image in LRU cache that can be removed.
IsMaxCapacity() bool
// GetNotifier returns a channel that can be monitored. The channel will return
// data every time IsMaxCapacity() flips from false to true state.
GetNotifier() <-chan struct{}
// Removes an image from the LRU cache if cache is not empty
Pop() *CachedImage
// Update adds an image to the LRU cache if the image is not marked in-use
Update(img *CachedImage)
// Mark/Unmark an image in-use. If an image is in-use, it will
// not be a candidate in LRU. When the reference count of the
// image drops to zero (via MarkFree() calls), the image will
// be added back to LRU.
MarkBusy(img *CachedImage)
MarkFree(img *CachedImage)
// Stats Monitoring
GetStats() *ImageCacherStats
}
func NewImageCache ¶ added in v0.3.645
func NewImageCache(exemptTags []string, maxSize uint64) ImageCacher
type ImageCacherStats ¶ added in v0.3.647
type PoolTaskStateType ¶
type PoolTaskStateType int
const ( PoolTaskStateInit PoolTaskStateType = iota // initializing PoolTaskStateReady // ready to be run )
Click to show internal directories.
Click to hide internal directories.