Documentation
¶
Index ¶
- Constants
- Variables
- func ComputeChecksum(data []byte) string
- func ComputeChecksumConcurrent(data []byte, numWorkers int) string
- func GetEnv(key string) string
- func Getenv(key string) string
- func ParseImageTag(imageTag string) (string, string)
- func SumChecksum(sums ...[]byte) string
- func TarDir(src fs.ReadDirFS) (*bytes.Buffer, error)
- func TarDirConcurrent(src fs.ReadDirFS, fileCount int, totalSize int64) (*bytes.Buffer, error)
- func TarDirSequential(src fs.ReadDirFS) (*bytes.Buffer, error)
- type BatchImageOperations
- type Build
- type BuildGroup
- type BuildGroups
- type BuildImagePayload
- type BuildType
- type ConcurrentContainerManager
- func (ccm *ConcurrentContainerManager) CreateContainersParallel(ctx context.Context, requests []ContainerCreateRequest) <-chan ContainerCreateResult
- func (ccm *ConcurrentContainerManager) PullImagesParallel(ctx context.Context, requests []ImagePullRequest) <-chan ImagePullResult
- func (ccm *ConcurrentContainerManager) Start()
- func (ccm *ConcurrentContainerManager) StartContainersParallel(ctx context.Context, containerIDs []string) <-chan ContainerOperationResult
- func (ccm *ConcurrentContainerManager) Stop()
- func (ccm *ConcurrentContainerManager) StopContainersParallel(ctx context.Context, requests []ContainerStopRequest) <-chan ContainerOperationResult
- func (ccm *ConcurrentContainerManager) WaitContainersParallel(ctx context.Context, requests []ContainerWaitRequest) <-chan ContainerWaitResult
- type ConcurrentImagePuller
- type Container
- func (c *Container) Apply(opts *types.ContainerConfig)
- func (c *Container) BuildImage(dockerfile []byte, imageName string) error
- func (c *Container) BuildImageByPlatform(dockerfile []byte, imageName string, platform string) error
- func (c *Container) BuildImageByPlatforms(dockerfile []byte, dockerCtx *bytes.Buffer, imageName string, ...) ([]string, error)
- func (c *Container) BuildIntermidiateContainer(image string, dockerFile []byte, platforms ...string) error
- func (c *Container) BuildingContainer(opts types.ContainerConfig) error
- func (c *Container) Cleanup()
- func (c *Container) Commit(imageTag string, comment string, changes ...string) (string, error)
- func (c *Container) CopyContentTo(content, dest string) error
- func (c *Container) CopyDirectoryTo(srcPath, dstPath string) error
- func (c *Container) CopyFileFromContainer(srcPath string) (string, error)
- func (c *Container) CopyFileTo(srcPath, destPath string) error
- func (c *Container) Create(opts types.ContainerConfig) error
- func (c *Container) Exec(cmd ...string) error
- func (c *Container) GetBuild() *Build
- func (c *Container) ImageExists(imageName string, platforms ...string) (bool, error)
- func (c *Container) Inspect() (*types.ContainerConfig, error)
- func (c *Container) InspectImage(image string) (*types.ImageInfo, error)
- func (c *Container) Pull(imageTags ...string) error
- func (c *Container) PullByPlatform(platform string, imageTags ...string) error
- func (c *Container) PullDefault(imageTags ...string) error
- func (c *Container) Push(source, target string, opts ...PushOption) error
- func (c *Container) Ready() error
- func (c *Container) Start() error
- func (c *Container) Stop() error
- func (c *Container) Tag(source, target string) error
- func (c *Container) Wait() error
- type ContainerCreateRequest
- type ContainerCreateResult
- type ContainerOperationResult
- type ContainerStopRequest
- type ContainerWaitRequest
- type ContainerWaitResult
- type CopyFilesPayload
- type CreateContainerPayload
- type Custom
- type EnvType
- type ExecCommandPayload
- type ImageExistsResult
- type ImageInspectResult
- type ImagePullRequest
- type ImagePullResult
- type InspectImagePayload
- type Job
- type JobResult
- type JobType
- type Leader
- type Priority
- type PullImagePayload
- type PushOption
- type RemoveContainerPayload
- type Semaphore
- type StartContainerPayload
- type StopContainerPayload
- type WaitContainerPayload
- type Worker
- type WorkerPool
- type WorkerPoolMetrics
Constants ¶
const ( // DefaultWorkerPoolSize is the default number of workers in the pool DefaultWorkerPoolSize = 5 // MaxConcurrentPulls limits concurrent image pulls to prevent overwhelming the registry MaxConcurrentPulls = 3 // DefaultJobBufferSize is the default buffer size for job channels DefaultJobBufferSize = 100 )
Variables ¶
var ( ErrPoolShutdown = errors.New("worker pool is shutdown") ErrUnknownJobType = errors.New("unknown job type") ErrInvalidJobPayload = errors.New("invalid job payload") ErrNoContainerClient = errors.New("no container client provided") ErrJobTimeout = errors.New("job execution timeout") ErrTooManyRetries = errors.New("maximum retries exceeded") )
Error definitions for concurrency operations
Functions ¶
func ComputeChecksum ¶
ComputeChecksum computes SHA256 checksum with memory optimizations Uses streaming approach and buffer pooling for better performance
func ComputeChecksumConcurrent ¶ added in v0.18.0
ComputeChecksumConcurrent computes SHA256 checksum using concurrent processing for very large data sets. Splits the data into chunks and processes them in parallel.
func ParseImageTag ¶
func SumChecksum ¶ added in v0.5.1
SumChecksum combines multiple checksums with memory optimization
func TarDir ¶ added in v0.5.1
TarDir creates a tar archive from a filesystem with memory optimizations and concurrent processing
func TarDirConcurrent ¶ added in v0.18.0
TarDirConcurrent creates a tar archive using concurrent processing for better performance
Types ¶
type BatchImageOperations ¶ added in v0.18.0
type BatchImageOperations struct {
// contains filtered or unexported fields
}
BatchImageOperations provides batch operations for images
func NewBatchImageOperations ¶ added in v0.18.0
func NewBatchImageOperations(client cri.ContainerManager, maxConcurrent int) *BatchImageOperations
NewBatchImageOperations creates a new batch image operations manager
func (*BatchImageOperations) CheckImagesExistParallel ¶ added in v0.18.0
func (bio *BatchImageOperations) CheckImagesExistParallel(ctx context.Context, images []string) <-chan ImageExistsResult
CheckImagesExistParallel checks if multiple images exist in parallel
func (*BatchImageOperations) InspectImagesParallel ¶ added in v0.18.0
func (bio *BatchImageOperations) InspectImagesParallel(ctx context.Context, images []string) <-chan ImageInspectResult
InspectImagesParallel inspects multiple images in parallel
type Build ¶
type Build struct {
Leader Leader
Platform types.Platform
Custom Custom
Registries map[string]*protos2.ContainerRegistry
BuildType BuildType `json:"build_type"`
ContainifyRegistry string
Folder string
App string `json:"app"`
Image string `json:"image"`
ImageTag string `json:"image_tag"`
Registry string
Env EnvType
File string
Repository string
Organization string
Runtime utils.RuntimeType
SourcePackages []string
SourceFiles []string
Verbose bool
// contains filtered or unexported fields
}
TODO: add target container platform Build struct optimized for memory alignment and cache performance
func InitRuntime ¶
func NewGoServiceBuild ¶
func NewMavenServiceBuild ¶
func NewPythonServiceBuild ¶
func NewServiceBuild ¶
func (*Build) AsFlags ¶
AsFlags converts build configuration to command-line flags with memory optimization
func (*Build) CustomString ¶ added in v0.4.0
type BuildGroup ¶ added in v0.11.0
type BuildGroup struct {
Builds []*Build
}
type BuildGroups ¶ added in v0.11.0
type BuildGroups []*BuildGroup
type BuildImagePayload ¶ added in v0.18.0
type BuildImagePayload struct {
Client cri.ContainerManager
ImageName string
Platform string
Dockerfile []byte
}
BuildImagePayload contains data for image building
type BuildType ¶
type BuildType string
type ConcurrentContainerManager ¶ added in v0.18.0
type ConcurrentContainerManager struct {
// contains filtered or unexported fields
}
ConcurrentContainerManager wraps container operations with concurrency support
func NewConcurrentContainerManager ¶ added in v0.18.0
func NewConcurrentContainerManager(client cri.ContainerManager, poolSize int) *ConcurrentContainerManager
NewConcurrentContainerManager creates a new concurrent container manager
func (*ConcurrentContainerManager) CreateContainersParallel ¶ added in v0.18.0
func (ccm *ConcurrentContainerManager) CreateContainersParallel(ctx context.Context, requests []ContainerCreateRequest) <-chan ContainerCreateResult
CreateContainersParallel creates multiple containers in parallel
func (*ConcurrentContainerManager) PullImagesParallel ¶ added in v0.18.0
func (ccm *ConcurrentContainerManager) PullImagesParallel(ctx context.Context, requests []ImagePullRequest) <-chan ImagePullResult
PullImagesParallel pulls multiple images in parallel with rate limiting
func (*ConcurrentContainerManager) Start ¶ added in v0.18.0
func (ccm *ConcurrentContainerManager) Start()
Start starts the concurrent container manager
func (*ConcurrentContainerManager) StartContainersParallel ¶ added in v0.18.0
func (ccm *ConcurrentContainerManager) StartContainersParallel(ctx context.Context, containerIDs []string) <-chan ContainerOperationResult
StartContainersParallel starts multiple containers in parallel
func (*ConcurrentContainerManager) Stop ¶ added in v0.18.0
func (ccm *ConcurrentContainerManager) Stop()
Stop stops the concurrent container manager
func (*ConcurrentContainerManager) StopContainersParallel ¶ added in v0.18.0
func (ccm *ConcurrentContainerManager) StopContainersParallel(ctx context.Context, requests []ContainerStopRequest) <-chan ContainerOperationResult
StopContainersParallel stops multiple containers in parallel
func (*ConcurrentContainerManager) WaitContainersParallel ¶ added in v0.18.0
func (ccm *ConcurrentContainerManager) WaitContainersParallel(ctx context.Context, requests []ContainerWaitRequest) <-chan ContainerWaitResult
WaitContainersParallel waits for multiple containers in parallel
type ConcurrentImagePuller ¶ added in v0.18.0
type ConcurrentImagePuller struct {
// contains filtered or unexported fields
}
ConcurrentImagePuller manages concurrent image pulling with rate limiting
func NewConcurrentImagePuller ¶ added in v0.18.0
func NewConcurrentImagePuller(maxConcurrent int, maxRetries int) *ConcurrentImagePuller
NewConcurrentImagePuller creates a new concurrent image puller
func (*ConcurrentImagePuller) PullImages ¶ added in v0.18.0
func (cip *ConcurrentImagePuller) PullImages(ctx context.Context, client cri.ContainerManager, images []ImagePullRequest) error
PullImages pulls multiple images concurrently with retry logic
func (*ConcurrentImagePuller) Start ¶ added in v0.18.0
func (cip *ConcurrentImagePuller) Start()
Start starts the concurrent image puller
func (*ConcurrentImagePuller) Stop ¶ added in v0.18.0
func (cip *ConcurrentImagePuller) Stop()
Stop stops the concurrent image puller
type Container ¶
type Container struct {
Source fs.ReadDirFS
Build *Build
Env EnvType
Prefix string
Image string
Name string
ID string
Opts types.ContainerConfig
Verbose bool
// contains filtered or unexported fields
}
func (*Container) Apply ¶
func (c *Container) Apply(opts *types.ContainerConfig)
func (*Container) BuildImage ¶
func (*Container) BuildImageByPlatform ¶
func (*Container) BuildImageByPlatforms ¶
func (*Container) BuildIntermidiateContainer ¶
func (*Container) BuildingContainer ¶
func (c *Container) BuildingContainer(opts types.ContainerConfig) error
func (*Container) Cleanup ¶ added in v0.18.0
func (c *Container) Cleanup()
Cleanup properly shuts down concurrency components
func (*Container) CopyContentTo ¶
func (*Container) CopyDirectoryTo ¶
TODO: ignore hidden folder and files maybe support .dockerignore file or more .dockerinclude file to include folder and files that are ignored by default
func (*Container) CopyFileFromContainer ¶
CopyFileFromContainer reads a single file from a container and returns its content as a string.
func (*Container) CopyFileTo ¶
func (*Container) ImageExists ¶
imageExists checks if the image with the specified tag exists.
func (*Container) InspectImage ¶
func (*Container) PullByPlatform ¶
func (*Container) PullDefault ¶
type ContainerCreateRequest ¶ added in v0.18.0
type ContainerCreateRequest struct {
Config *types.ContainerConfig
AuthBase64 string
}
ContainerCreateRequest represents a request to create a container
type ContainerCreateResult ¶ added in v0.18.0
ContainerCreateResult represents the result of a container creation
type ContainerOperationResult ¶ added in v0.18.0
ContainerOperationResult represents the result of a container operation
type ContainerStopRequest ¶ added in v0.18.0
ContainerStopRequest represents a request to stop a container
type ContainerWaitRequest ¶ added in v0.18.0
ContainerWaitRequest represents a request to wait for a container
type ContainerWaitResult ¶ added in v0.18.0
ContainerWaitResult represents the result of waiting for a container
type CopyFilesPayload ¶ added in v0.18.0
type CopyFilesPayload struct {
Client cri.ContainerManager
ContainerID string
SrcPath string
DstPath string
}
CopyFilesPayload contains data for file copy operations
type CreateContainerPayload ¶ added in v0.18.0
type CreateContainerPayload struct {
Client cri.ContainerManager
Config *types.ContainerConfig
AuthBase64 string
}
CreateContainerPayload contains data for container creation
type EnvType ¶
type EnvType string
type ExecCommandPayload ¶ added in v0.18.0
type ExecCommandPayload struct {
Client cri.ContainerManager
ContainerID string
Command []string
AttachStdout bool
}
ExecCommandPayload contains data for command execution
type ImageExistsResult ¶ added in v0.18.0
ImageExistsResult represents the result of checking if an image exists
type ImageInspectResult ¶ added in v0.18.0
ImageInspectResult represents the result of an image inspection
type ImagePullRequest ¶ added in v0.18.0
type ImagePullRequest struct {
Image string
AuthBase64 string
Platform string
Priority Priority
Retries int
}
ImagePullRequest represents a request to pull an image
type ImagePullResult ¶ added in v0.18.0
type ImagePullResult struct {
Reader io.ReadCloser
Error error
Image string
}
ImagePullResult represents the result of an image pull operation
type InspectImagePayload ¶ added in v0.18.0
type InspectImagePayload struct {
Client cri.ContainerManager
Image string
}
InspectImagePayload contains data for image inspection
type Job ¶ added in v0.18.0
type Job struct {
SubmittedAt time.Time
Payload interface{}
Context context.Context
ID string
Type JobType
Priority Priority
}
Job represents a unit of work to be executed by a worker
type JobResult ¶ added in v0.18.0
type JobResult struct {
StartTime time.Time
EndTime time.Time
Result interface{}
Error error
Job Job
Duration time.Duration
WorkerID int
}
JobResult represents the result of a job execution
type JobType ¶ added in v0.18.0
type JobType int
JobType represents different types of container operations
type PullImagePayload ¶ added in v0.18.0
type PullImagePayload struct {
Client cri.ContainerManager
Image string
AuthBase64 string
Platform string
}
PullImagePayload contains data for image pull operations
type PushOption ¶
type PushOption struct {
Remove bool
}
type RemoveContainerPayload ¶ added in v0.18.0
type RemoveContainerPayload struct {
Client cri.ContainerManager
ContainerID string
}
RemoveContainerPayload contains data for container removal
type Semaphore ¶ added in v0.18.0
type Semaphore struct {
// contains filtered or unexported fields
}
Semaphore provides a simple semaphore implementation for rate limiting
func NewSemaphore ¶ added in v0.18.0
NewSemaphore creates a new semaphore with the given capacity
func (*Semaphore) Release ¶ added in v0.18.0
func (s *Semaphore) Release()
Release releases a permit back to the semaphore
func (*Semaphore) TryAcquire ¶ added in v0.18.0
TryAcquire tries to acquire a permit without blocking
type StartContainerPayload ¶ added in v0.18.0
type StartContainerPayload struct {
Client cri.ContainerManager
ContainerID string
}
StartContainerPayload contains data for starting containers
type StopContainerPayload ¶ added in v0.18.0
type StopContainerPayload struct {
Client cri.ContainerManager
ContainerID string
Signal string
}
StopContainerPayload contains data for stopping containers
type WaitContainerPayload ¶ added in v0.18.0
type WaitContainerPayload struct {
Client cri.ContainerManager
ContainerID string
Condition string
}
WaitContainerPayload contains data for waiting on containers
type Worker ¶ added in v0.18.0
type Worker struct {
// contains filtered or unexported fields
}
Worker represents a single worker in the pool
type WorkerPool ¶ added in v0.18.0
type WorkerPool struct {
// contains filtered or unexported fields
}
WorkerPool manages a pool of workers for concurrent container operations
func NewWorkerPool ¶ added in v0.18.0
func NewWorkerPool(size int) *WorkerPool
NewWorkerPool creates a new worker pool with the specified size
func (*WorkerPool) GetMetrics ¶ added in v0.18.0
func (wp *WorkerPool) GetMetrics() WorkerPoolMetrics
GetMetrics returns current pool metrics
func (*WorkerPool) Results ¶ added in v0.18.0
func (wp *WorkerPool) Results() <-chan JobResult
Results returns the result channel for reading job results
func (*WorkerPool) Start ¶ added in v0.18.0
func (wp *WorkerPool) Start()
Start starts all workers in the pool
func (*WorkerPool) Stop ¶ added in v0.18.0
func (wp *WorkerPool) Stop()
Stop gracefully stops all workers
func (*WorkerPool) Submit ¶ added in v0.18.0
func (wp *WorkerPool) Submit(job Job) error
Submit submits a job to the worker pool
type WorkerPoolMetrics ¶ added in v0.18.0
type WorkerPoolMetrics struct {
PoolSize int
JobsSubmitted int64
JobsCompleted int64
JobsFailed int64
CurrentQueueLen int64
PeakQueueDepth int64
AvgQueueTime time.Duration
AvgExecutionTime time.Duration
IsStarted bool
IsShutdown bool
}
WorkerPoolMetrics contains metrics about the worker pool