build

package
v0.0.0-...-dc8f43e Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2025 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Overview

Example (MemoryBuild)
package main

import (
	"context"
	"fmt"

	"github.com/Caia-Tech/govc"
	"github.com/Caia-Tech/govc/pkg/build"
	"github.com/Caia-Tech/govc/pkg/build/plugins"
)

func main() {
	// Create a pure in-memory repository
	repo := govc.NewRepository()

	// Write Go source code directly to memory
	repo.WriteFile("main.go", []byte(`
package main

import "fmt"

func main() {
    fmt.Println("Hello from memory-only build!")
}
`))

	repo.WriteFile("go.mod", []byte(`
module example
go 1.21
`))

	// Create build engine with Go plugin
	engine := build.NewMemoryBuildEngine()
	goPlugin := plugins.NewGoPlugin()
	engine.RegisterPlugin(goPlugin)

	// Create VFS from repository
	vfs := build.NewDirectMemoryVFS()
	files, _ := repo.ListFiles()
	for _, file := range files {
		content, _ := repo.ReadFile(file)
		vfs.Write(file, content)
	}

	// Configure build
	config := build.BuildConfig{
		Target:     "binary",
		Mode:       "debug",
		OutputPath: "dist",
		PluginConfig: map[string]interface{}{
			"plugin": "go",
			"vfs":    vfs,
		},
	}

	// Build entirely in memory!
	ctx := context.Background()
	result, err := engine.Build(ctx, config)

	if err != nil {
		fmt.Printf("Build failed: %v\n", err)
	} else if result.Success {
		fmt.Printf("Build successful! Created %d artifacts\n", len(result.Artifacts))
	}

}
Output:

Build successful! Created 1 artifacts

Index

Examples

Constants

View Source
const (
	EventBuildStarted    = "build.started"
	EventBuildCompleted  = "build.completed"
	EventBuildFailed     = "build.failed"
	EventBuildCached     = "build.cached"
	EventBuildCancelled  = "build.cancelled"
	EventPluginLoaded    = "build.plugin.loaded"
	EventArtifactCreated = "build.artifact.created"
)

Build event types

Variables

This section is empty.

Functions

This section is empty.

Types

type Bottleneck

type Bottleneck struct {
	Task       string
	Duration   time.Duration
	Type       string // "cpu", "memory", "io", "lock"
	Severity   string // "low", "medium", "high", "critical"
	Suggestion string
}

Bottleneck represents a performance bottleneck

type BuildArtifact

type BuildArtifact struct {
	// Name of the artifact
	Name string `json:"name"`

	// Type of artifact ("binary", "library", "documentation", "wasm", etc.)
	Type string `json:"type"`

	// Path in virtual filesystem
	Path string `json:"path"`

	// Content of the artifact (for memory storage)
	Content []byte `json:"-"`

	// Size of the artifact
	Size int64 `json:"size"`

	// Hash of the artifact for verification
	Hash string `json:"hash"`

	// Artifact metadata
	Metadata map[string]interface{} `json:"metadata,omitempty"`

	// Executable flag
	Executable bool `json:"executable"`
}

BuildArtifact represents a build output

type BuildCache

type BuildCache interface {
	// Get retrieves cached build result
	Get(key CacheKey) (*BuildResult, bool)

	// Put stores build result in cache
	Put(key CacheKey, result *BuildResult) error

	// Invalidate removes cached result
	Invalidate(key CacheKey) error

	// Clear removes all cached results
	Clear() error

	// Stats returns cache statistics
	Stats() CacheStats
}

BuildCache manages caching of build results

type BuildConfig

type BuildConfig struct {
	// Build target (e.g., "binary", "library", "wasm", "container")
	Target string `json:"target"`

	// Build mode (e.g., "debug", "release", "test", "bench")
	Mode string `json:"mode"`

	// Output path in virtual filesystem
	OutputPath string `json:"output_path"`

	// Environment variables
	Environment map[string]string `json:"environment"`

	// Build arguments
	Args []string `json:"args"`

	// Plugin-specific configuration
	PluginConfig map[string]interface{} `json:"plugin_config"`

	// Cache settings
	Cache *CacheConfig `json:"cache,omitempty"`

	// Parallel build settings
	Parallel bool `json:"parallel"`

	// Memory limit for build process (bytes)
	MemoryLimit int64 `json:"memory_limit,omitempty"`

	// Timeout for build process
	Timeout time.Duration `json:"timeout,omitempty"`
}

BuildConfig specifies how to build a project

type BuildEngine

type BuildEngine interface {
	// Build executes a build using the specified plugin
	Build(ctx context.Context, config BuildConfig) (*BuildResult, error)

	// ListPlugins returns available build plugins
	ListPlugins() []PluginInfo

	// GetPlugin retrieves a specific build plugin
	GetPlugin(name string) (BuildPlugin, error)

	// RegisterPlugin adds a new build plugin
	RegisterPlugin(plugin BuildPlugin) error

	// DetectAndBuild auto-detects project type and builds
	DetectAndBuild(ctx context.Context, vfs VirtualFileSystem, config BuildConfig) (*BuildResult, error)
}

BuildEngine manages the overall build process

type BuildEvent

type BuildEvent struct {
	// Event type
	Type string `json:"type"`

	// Event timestamp
	Timestamp time.Time `json:"timestamp"`

	// Build ID
	BuildID string `json:"build_id"`

	// Plugin name
	Plugin string `json:"plugin"`

	// Build configuration
	Config BuildConfig `json:"config"`

	// Build result (for completion events)
	Result *BuildResult `json:"result,omitempty"`

	// Error (for failure events)
	Error error `json:"error,omitempty"`

	// Additional event data
	Data map[string]interface{} `json:"data,omitempty"`
}

BuildEvent represents a build-related event

type BuildManager

type BuildManager interface {
	// Build executes a build for a repository
	Build(ctx context.Context, repoID string, config BuildConfig) (*BuildResult, error)

	// AutoBuild detects and builds project
	AutoBuild(ctx context.Context, repoID string) (*BuildResult, error)

	// BuildInReality builds in a parallel reality
	BuildInReality(ctx context.Context, repoID string, reality string, config BuildConfig) (*BuildResult, error)

	// GetBuildStatus returns current build status
	GetBuildStatus(buildID string) (*BuildStatus, error)

	// ListBuilds returns build history
	ListBuilds(repoID string, limit int) ([]*BuildResult, error)

	// Subscribe to build events
	Subscribe(handler func(BuildEvent)) func()
}

BuildManager coordinates builds with repository

type BuildManagerImpl

type BuildManagerImpl struct {
	// contains filtered or unexported fields
}

BuildManagerImpl integrates build system with govc repository

func NewBuildManager

func NewBuildManager() *BuildManagerImpl

NewBuildManager creates a new build manager

func (*BuildManagerImpl) AutoBuild

func (m *BuildManagerImpl) AutoBuild(ctx context.Context, repoID string) (*BuildResult, error)

AutoBuild detects and builds project

func (*BuildManagerImpl) Build

func (m *BuildManagerImpl) Build(ctx context.Context, repoID string, config BuildConfig) (*BuildResult, error)

Build executes a build for a repository

func (*BuildManagerImpl) BuildInReality

func (m *BuildManagerImpl) BuildInReality(ctx context.Context, repoID string, reality string, config BuildConfig) (*BuildResult, error)

BuildInReality builds in a parallel reality

func (*BuildManagerImpl) GetBuildStatus

func (m *BuildManagerImpl) GetBuildStatus(buildID string) (*BuildStatus, error)

GetBuildStatus returns current build status

func (*BuildManagerImpl) ListBuilds

func (m *BuildManagerImpl) ListBuilds(repoID string, limit int) ([]*BuildResult, error)

ListBuilds returns build history

func (*BuildManagerImpl) RegisterRepository

func (m *BuildManagerImpl) RegisterRepository(repoID string, repo *govc.Repository)

RegisterRepository registers a repository for building

func (*BuildManagerImpl) Subscribe

func (m *BuildManagerImpl) Subscribe(handler func(BuildEvent)) func()

Subscribe to build events

type BuildMetadata

type BuildMetadata struct {
	// Builder plugin used
	Plugin string `json:"plugin"`

	// Project information
	Project *ProjectMetadata `json:"project"`

	// Build timestamp
	Timestamp time.Time `json:"timestamp"`

	// Build host information
	Host string `json:"host"`

	// Build configuration used
	Config BuildConfig `json:"config"`

	// Git commit hash (if applicable)
	CommitHash string `json:"commit_hash,omitempty"`

	// Build number/ID
	BuildID string `json:"build_id"`

	// Dependencies used
	Dependencies []Dependency `json:"dependencies,omitempty"`
}

BuildMetadata contains build information

type BuildOutput

type BuildOutput struct {
	// Standard output
	Stdout string `json:"stdout"`

	// Standard error
	Stderr string `json:"stderr"`

	// Build warnings
	Warnings []string `json:"warnings,omitempty"`

	// Build errors
	Errors []string `json:"errors,omitempty"`

	// Build info messages
	Info []string `json:"info,omitempty"`
}

BuildOutput contains build process output

type BuildPlugin

type BuildPlugin interface {
	// Name returns the plugin name (e.g., "go", "nodejs", "rust")
	Name() string

	// SupportedExtensions returns file extensions this plugin handles
	SupportedExtensions() []string

	// DetectProject analyzes files to determine if this plugin can build
	DetectProject(vfs VirtualFileSystem) (bool, *ProjectMetadata, error)

	// Build executes the build process
	Build(ctx context.Context, config BuildConfig, vfs VirtualFileSystem) (*BuildResult, error)

	// GetDependencies resolves project dependencies
	GetDependencies(config BuildConfig, vfs VirtualFileSystem) ([]Dependency, error)

	// ValidateBuild checks if build configuration is valid
	ValidateBuild(config BuildConfig, vfs VirtualFileSystem) error

	// SupportsMemoryBuild returns true if plugin can build entirely in memory
	SupportsMemoryBuild() bool
}

BuildPlugin defines the interface for language-specific builders

type BuildProfile

type BuildProfile struct {
	BuildID       string
	StartTime     time.Time
	EndTime       time.Time
	Duration      time.Duration
	MemoryUsage   int64
	CPUUsage      float64
	TaskBreakdown map[string]time.Duration
	Bottlenecks   []Bottleneck
}

BuildProfile contains performance data for a build

type BuildProfiler

type BuildProfiler struct {
	// contains filtered or unexported fields
}

BuildProfiler profiles build performance

func NewBuildProfiler

func NewBuildProfiler() *BuildProfiler

NewBuildProfiler creates a build profiler

func (*BuildProfiler) EndProfiling

func (bp *BuildProfiler) EndProfiling(buildID string) *BuildProfile

EndProfiling ends profiling and analyzes results

func (*BuildProfiler) StartProfiling

func (bp *BuildProfiler) StartProfiling(buildID string) *BuildProfile

StartProfiling starts profiling a build

type BuildRequest

type BuildRequest struct {
	ID         string
	Files      []string
	Config     BuildConfig
	Context    context.Context
	ResultChan chan BuildResponse
}

BuildRequest represents a build request

type BuildResponse

type BuildResponse struct {
	Result    *BuildResult
	Error     error
	FromCache bool
}

BuildResponse represents a build response

type BuildResult

type BuildResult struct {
	// Success indicates if build completed successfully
	Success bool `json:"success"`

	// Build artifacts (executables, libraries, etc.)
	Artifacts []BuildArtifact `json:"artifacts"`

	// Build metadata
	Metadata *BuildMetadata `json:"metadata"`

	// Build logs and output
	Output *BuildOutput `json:"output"`

	// Error information if build failed
	Error error `json:"error,omitempty"`

	// Build duration
	Duration time.Duration `json:"duration"`

	// Memory usage statistics
	MemoryStats *MemoryStats `json:"memory_stats,omitempty"`

	// Cache hit information
	CacheHit bool `json:"cache_hit"`
}

BuildResult contains the output of a build

type BuildScheduler

type BuildScheduler struct {
	// contains filtered or unexported fields
}

BuildScheduler optimizes build task scheduling

func NewBuildScheduler

func NewBuildScheduler(workers int) *BuildScheduler

NewBuildScheduler creates a build scheduler

func (*BuildScheduler) Schedule

func (bs *BuildScheduler) Schedule(task ScheduledTask) <-chan error

Schedule adds a task to the build schedule

type BuildStatus

type BuildStatus struct {
	// Build ID
	BuildID string `json:"build_id"`

	// Current state (pending, running, completed, failed)
	State string `json:"state"`

	// Progress percentage (0-100)
	Progress int `json:"progress"`

	// Current step
	CurrentStep string `json:"current_step"`

	// Start time
	StartTime time.Time `json:"start_time"`

	// Estimated completion time
	EstimatedCompletion *time.Time `json:"estimated_completion,omitempty"`

	// Build logs (streaming)
	Logs io.ReadCloser `json:"-"`
}

BuildStatus represents current build status

type BuildTask

type BuildTask struct {
	ID            string
	Name          string
	Dependencies  []string
	Execute       func(ctx context.Context) error
	EstimatedTime time.Duration
}

BuildTask represents a single build task

type CPUMonitor

type CPUMonitor struct{}

func NewCPUMonitor

func NewCPUMonitor() *CPUMonitor

type CacheConfig

type CacheConfig struct {
	// Enable caching
	Enabled bool `json:"enabled"`

	// Cache key prefix
	Prefix string `json:"prefix"`

	// Cache TTL
	TTL time.Duration `json:"ttl"`

	// Force rebuild (ignore cache)
	Force bool `json:"force"`
}

CacheConfig defines caching behavior

type CacheEntry

type CacheEntry struct {
	Key        CacheKey
	Result     *BuildResult
	Size       int64
	CreatedAt  time.Time
	AccessedAt time.Time
	HitCount   int
}

CacheEntry represents a cached build result

type CacheKey

type CacheKey struct {
	Plugin       string      `json:"plugin"`
	Config       BuildConfig `json:"config"`
	FilesHash    string      `json:"files_hash"`
	Dependencies []string    `json:"dependencies,omitempty"`
}

CacheKey identifies a unique build configuration

func (CacheKey) String

func (k CacheKey) String() string

String returns string representation of cache key

type CacheKeyBuilder

type CacheKeyBuilder struct {
	// contains filtered or unexported fields
}

CacheKeyBuilder helps build cache keys

func NewCacheKeyBuilder

func NewCacheKeyBuilder(plugin string) *CacheKeyBuilder

NewCacheKeyBuilder creates a new cache key builder

func (*CacheKeyBuilder) Build

func (b *CacheKeyBuilder) Build() CacheKey

Build creates the cache key

func (*CacheKeyBuilder) WithConfig

func (b *CacheKeyBuilder) WithConfig(config BuildConfig) *CacheKeyBuilder

WithConfig sets the build config

func (*CacheKeyBuilder) WithDependency

func (b *CacheKeyBuilder) WithDependency(dep string) *CacheKeyBuilder

WithDependency adds a dependency

func (*CacheKeyBuilder) WithFile

func (b *CacheKeyBuilder) WithFile(path string, content []byte) *CacheKeyBuilder

WithFile adds a file to the key

type CacheStats

type CacheStats struct {
	Hits        int64     `json:"hits"`
	Misses      int64     `json:"misses"`
	Entries     int       `json:"entries"`
	Size        int64     `json:"size"`
	HitRate     float64   `json:"hit_rate"`
	LastCleanup time.Time `json:"last_cleanup"`
}

CacheStats contains cache statistics

type CacheStorageManager

type CacheStorageManager struct {
	// contains filtered or unexported fields
}

CacheStorageManager manages cache storage and cleanup

func NewCacheStorageManager

func NewCacheStorageManager(cacheDir string) *CacheStorageManager

NewCacheStorageManager creates a cache storage manager

func (*CacheStorageManager) Cleanup

func (csm *CacheStorageManager) Cleanup() error

Cleanup performs cache cleanup based on size and age

type CacheTuner

type CacheTuner struct{}

func NewCacheTuner

func NewCacheTuner() *CacheTuner

func (*CacheTuner) OptimizeForBuild

func (ct *CacheTuner) OptimizeForBuild(buildType string)

type ContentHasher

type ContentHasher struct {
	// contains filtered or unexported fields
}

ContentHasher computes content-based hashes for caching

func NewContentHasher

func NewContentHasher() *ContentHasher

NewContentHasher creates a content hasher

func (*ContentHasher) HashFile

func (ch *ContentHasher) HashFile(filepath string) string

HashFile computes hash of a single file with caching

func (*ContentHasher) HashFiles

func (ch *ContentHasher) HashFiles(files []string) string

HashFiles computes hash of multiple files

type Dependency

type Dependency struct {
	// Dependency name
	Name string `json:"name"`

	// Version specification
	Version string `json:"version"`

	// Dependency type (runtime, dev, build, etc.)
	Type string `json:"type"`

	// Source (npm, maven, cargo, etc.)
	Source string `json:"source"`

	// Resolved version
	ResolvedVersion string `json:"resolved_version,omitempty"`

	// Dependency hash/checksum
	Hash string `json:"hash,omitempty"`
}

Dependency represents a project dependency

type DependencyAnalyzer

type DependencyAnalyzer struct {
	// contains filtered or unexported fields
}

DependencyAnalyzer analyzes task dependencies

func NewDependencyAnalyzer

func NewDependencyAnalyzer() *DependencyAnalyzer

NewDependencyAnalyzer creates a dependency analyzer

func (*DependencyAnalyzer) AnalyzeDependencies

func (da *DependencyAnalyzer) AnalyzeDependencies(tasks []BuildTask) *DependencyGraph

AnalyzeDependencies creates a dependency graph

type DependencyGraph

type DependencyGraph struct {
	// contains filtered or unexported fields
}

DependencyGraph tracks build dependencies for incremental builds

func NewDependencyGraph

func NewDependencyGraph() *DependencyGraph

NewDependencyGraph creates a dependency graph

func (*DependencyGraph) AddDependency

func (dg *DependencyGraph) AddDependency(file, dependency string)

AddDependency adds a dependency relationship

func (*DependencyGraph) AddEdge

func (dg *DependencyGraph) AddEdge(source, target string)

AddEdge adds an edge from source to target

func (*DependencyGraph) AddNode

func (dg *DependencyGraph) AddNode(node string)

AddNode adds a node to the graph

func (*DependencyGraph) GetAffectedFiles

func (dg *DependencyGraph) GetAffectedFiles(file string) []string

GetAffectedFiles returns files that depend on the given file

func (*DependencyGraph) GetDependencies

func (dg *DependencyGraph) GetDependencies(file string) []string

GetDependencies returns all dependencies for a file

func (*DependencyGraph) TopologicalSort

func (dg *DependencyGraph) TopologicalSort() [][]BuildTask

TopologicalSort performs topological sort for parallel execution

type DirectMemoryBridge

type DirectMemoryBridge struct {
	// contains filtered or unexported fields
}

DirectMemoryBridge bridges DirectMemoryVFS to filesystem

func (*DirectMemoryBridge) Cleanup

func (b *DirectMemoryBridge) Cleanup() error

Cleanup removes temp directory

func (*DirectMemoryBridge) Exec

func (b *DirectMemoryBridge) Exec(cmd string, args []string, env map[string]string) (*ExecResult, error)

Exec executes command with filesystem access

func (*DirectMemoryBridge) SyncFromTemp

func (b *DirectMemoryBridge) SyncFromTemp() error

SyncFromTemp syncs filesystem back to memory

func (*DirectMemoryBridge) SyncToTemp

func (b *DirectMemoryBridge) SyncToTemp() error

SyncToTemp syncs memory to filesystem

func (*DirectMemoryBridge) TempPath

func (b *DirectMemoryBridge) TempPath() string

TempPath returns temp directory path

type DirectMemoryVFS

type DirectMemoryVFS struct {
	// contains filtered or unexported fields
}

DirectMemoryVFS is a pure in-memory VFS without any storage backend

func NewDirectMemoryVFS

func NewDirectMemoryVFS() *DirectMemoryVFS

NewDirectMemoryVFS creates a pure in-memory VFS

func (*DirectMemoryVFS) CreateBridge

func (vfs *DirectMemoryVFS) CreateBridge() (FilesystemBridge, error)

CreateBridge creates a filesystem bridge for DirectMemoryVFS

func (*DirectMemoryVFS) Delete

func (vfs *DirectMemoryVFS) Delete(path string) error

Delete removes file from memory map

func (*DirectMemoryVFS) Exists

func (vfs *DirectMemoryVFS) Exists(path string) bool

Exists checks if file exists

func (*DirectMemoryVFS) Glob

func (vfs *DirectMemoryVFS) Glob(pattern string) ([]string, error)

Glob matches files against pattern

func (*DirectMemoryVFS) List

func (vfs *DirectMemoryVFS) List() ([]string, error)

List returns all file paths

func (*DirectMemoryVFS) Read

func (vfs *DirectMemoryVFS) Read(path string) ([]byte, error)

Read reads file from memory map

func (*DirectMemoryVFS) TempDir

func (vfs *DirectMemoryVFS) TempDir(prefix string) (string, error)

TempDir creates a temporary directory path

func (*DirectMemoryVFS) Write

func (vfs *DirectMemoryVFS) Write(path string, data []byte) error

Write writes file to memory map

type DistributedBuildCache

type DistributedBuildCache struct {
	// contains filtered or unexported fields
}

DistributedBuildCache implements a distributed build cache system

func NewDistributedBuildCache

func NewDistributedBuildCache(cacheDir string, remote RemoteCacheBackend) *DistributedBuildCache

NewDistributedBuildCache creates a distributed build cache

func (*DistributedBuildCache) Get

Get retrieves from distributed cache (local first, then remote)

func (*DistributedBuildCache) Put

func (dc *DistributedBuildCache) Put(key CacheKey, result *BuildResult) error

Put stores in both local and remote cache

type DistributedCache

type DistributedCache struct {
	// contains filtered or unexported fields
}

DistributedCache implements distributed caching

func NewDistributedCache

func NewDistributedCache(remote RemoteCacheClient) *DistributedCache

NewDistributedCache creates a distributed cache

func (*DistributedCache) Get

func (d *DistributedCache) Get(key CacheKey) (*BuildResult, bool)

Get retrieves from local cache first, then remote

func (*DistributedCache) Put

func (d *DistributedCache) Put(key CacheKey, result *BuildResult) error

Put stores in both local and remote cache

type DistributedCacheStats

type DistributedCacheStats struct {
	LocalHits        int64     `json:"local_hits"`
	LocalMisses      int64     `json:"local_misses"`
	RemoteHits       int64     `json:"remote_hits"`
	RemoteMisses     int64     `json:"remote_misses"`
	BytesUploaded    int64     `json:"bytes_uploaded"`
	BytesDownloaded  int64     `json:"bytes_downloaded"`
	CompressionRatio float64   `json:"compression_ratio"`
	LastSync         time.Time `json:"last_sync"`
}

DistributedCacheStats tracks distributed cache performance

type ExecResult

type ExecResult struct {
	// Command output
	Output string `json:"output"`

	// Exit code
	ExitCode int `json:"exit_code"`

	// Execution error
	Error error `json:"error,omitempty"`

	// Execution duration
	Duration time.Duration `json:"duration"`
}

ExecResult contains command execution results

type FileEvent

type FileEvent struct {
	Path      string
	Operation string // "create", "modify", "delete"
	Time      time.Time
}

FileEvent represents a file system event

type FileHasher

type FileHasher struct {
	// contains filtered or unexported fields
}

FileHasher calculates hash of multiple files

func NewFileHasher

func NewFileHasher() *FileHasher

NewFileHasher creates a new file hasher

func (*FileHasher) Add

func (h *FileHasher) Add(filename string, content []byte)

Add adds a file to the hash

func (*FileHasher) Files

func (h *FileHasher) Files() []string

Files returns the list of files hashed

func (*FileHasher) Hash

func (h *FileHasher) Hash() string

Hash returns the computed hash

type FileWatcher

type FileWatcher struct {
	// contains filtered or unexported fields
}

FileWatcher watches for file system changes

func NewFileWatcher

func NewFileWatcher() *FileWatcher

NewFileWatcher creates a file watcher

func (*FileWatcher) Watch

func (fw *FileWatcher) Watch(path string) (<-chan FileEvent, error)

Watch starts watching a directory for changes

type FilesystemBridge

type FilesystemBridge interface {
	// TempPath returns the temporary directory path
	TempPath() string

	// Sync writes memory files to temporary directory
	SyncToTemp() error

	// SyncFromTemp reads files from temp back to memory
	SyncFromTemp() error

	// Exec executes command with access to temp directory
	Exec(cmd string, args []string, env map[string]string) (*ExecResult, error)

	// Cleanup removes temporary directory
	Cleanup() error
}

FilesystemBridge provides temporary access to real filesystem

type GCTuner

type GCTuner struct{}

Tuning components (simplified implementations)

func NewGCTuner

func NewGCTuner() *GCTuner

func (*GCTuner) TuneForDuration

func (gt *GCTuner) TuneForDuration(duration time.Duration)

type IOMonitor

type IOMonitor struct{}

func NewIOMonitor

func NewIOMonitor() *IOMonitor

type IncrementalBuilder

type IncrementalBuilder struct {
	// contains filtered or unexported fields
}

IncrementalBuilder performs incremental builds based on file changes

func NewIncrementalBuilder

func NewIncrementalBuilder(cache BuildCache) *IncrementalBuilder

NewIncrementalBuilder creates an incremental builder

func (*IncrementalBuilder) Build

func (ib *IncrementalBuilder) Build(ctx context.Context, files []string, config BuildConfig) (*BuildResult, error)

Build performs an incremental build

type MemoryBuildEngine

type MemoryBuildEngine struct {
	// contains filtered or unexported fields
}

MemoryBuildEngine implements the BuildEngine interface

func NewMemoryBuildEngine

func NewMemoryBuildEngine() *MemoryBuildEngine

NewMemoryBuildEngine creates a new memory-based build engine

func (*MemoryBuildEngine) Build

func (e *MemoryBuildEngine) Build(ctx context.Context, config BuildConfig) (*BuildResult, error)

Build executes a build using the specified plugin

func (*MemoryBuildEngine) DetectAndBuild

func (e *MemoryBuildEngine) DetectAndBuild(ctx context.Context, vfs VirtualFileSystem, config BuildConfig) (*BuildResult, error)

DetectAndBuild auto-detects project type and builds

func (*MemoryBuildEngine) GetPlugin

func (e *MemoryBuildEngine) GetPlugin(name string) (BuildPlugin, error)

GetPlugin retrieves a specific build plugin

func (*MemoryBuildEngine) ListPlugins

func (e *MemoryBuildEngine) ListPlugins() []PluginInfo

ListPlugins returns available build plugins

func (*MemoryBuildEngine) RegisterPlugin

func (e *MemoryBuildEngine) RegisterPlugin(plugin BuildPlugin) error

RegisterPlugin adds a new build plugin

func (*MemoryBuildEngine) Subscribe

func (e *MemoryBuildEngine) Subscribe() <-chan BuildEvent

Subscribe returns a channel for build events

type MemoryCache

type MemoryCache struct {
	// contains filtered or unexported fields
}

MemoryCache implements BuildCache in memory

func NewMemoryCache

func NewMemoryCache() *MemoryCache

NewMemoryCache creates a new in-memory build cache

func NewMemoryCacheWithOptions

func NewMemoryCacheWithOptions(maxEntries int, maxSize int64, ttl time.Duration) *MemoryCache

NewMemoryCacheWithOptions creates cache with custom options

func (*MemoryCache) Clear

func (c *MemoryCache) Clear() error

Clear removes all cached results

func (*MemoryCache) Get

func (c *MemoryCache) Get(key CacheKey) (*BuildResult, bool)

Get retrieves cached build result

func (*MemoryCache) Invalidate

func (c *MemoryCache) Invalidate(key CacheKey) error

Invalidate removes cached result

func (*MemoryCache) Put

func (c *MemoryCache) Put(key CacheKey, result *BuildResult) error

Put stores build result in cache

func (*MemoryCache) Stats

func (c *MemoryCache) Stats() CacheStats

Stats returns cache statistics

type MemoryFSBridge

type MemoryFSBridge struct {
	// contains filtered or unexported fields
}

MemoryFSBridge bridges memory VFS to real filesystem

func (*MemoryFSBridge) Cleanup

func (b *MemoryFSBridge) Cleanup() error

Cleanup removes temporary directory

func (*MemoryFSBridge) Exec

func (b *MemoryFSBridge) Exec(cmd string, args []string, env map[string]string) (*ExecResult, error)

Exec executes command with access to temp directory

func (*MemoryFSBridge) SyncFromTemp

func (b *MemoryFSBridge) SyncFromTemp() error

SyncFromTemp reads files from temp directory back to memory

func (*MemoryFSBridge) SyncToTemp

func (b *MemoryFSBridge) SyncToTemp() error

SyncToTemp writes all memory files to temporary directory

func (*MemoryFSBridge) TempPath

func (b *MemoryFSBridge) TempPath() string

TempPath returns the temporary directory path

type MemoryMonitor

type MemoryMonitor struct{}

Monitoring components (simplified implementations)

func NewMemoryMonitor

func NewMemoryMonitor() *MemoryMonitor

type MemoryStats

type MemoryStats struct {
	// Peak memory usage
	PeakUsage int64 `json:"peak_usage"`

	// Average memory usage
	AverageUsage int64 `json:"average_usage"`

	// Final memory usage
	FinalUsage int64 `json:"final_usage"`

	// Number of allocations
	Allocations int64 `json:"allocations"`

	// Number of frees
	Frees int64 `json:"frees"`
}

MemoryStats tracks memory usage during build

type MemoryStream

type MemoryStream struct {
	// contains filtered or unexported fields
}

MemoryStream provides streaming access to memory files

func (*MemoryStream) Close

func (m *MemoryStream) Close() error

Close implements io.Closer

func (*MemoryStream) Read

func (m *MemoryStream) Read(p []byte) (n int, err error)

Read implements io.Reader

func (*MemoryStream) Write

func (m *MemoryStream) Write(p []byte) (n int, err error)

Write implements io.Writer

type MemoryVFS

type MemoryVFS struct {
	// contains filtered or unexported fields
}

MemoryVFS implements VirtualFileSystem using govc's memory storage

func NewMemoryVFS

func NewMemoryVFS(storage storage.WorkingStorage) *MemoryVFS

NewMemoryVFS creates a VFS backed by govc's memory storage

func (*MemoryVFS) CreateBridge

func (vfs *MemoryVFS) CreateBridge() (FilesystemBridge, error)

CreateBridge creates a temporary bridge to real filesystem

func (*MemoryVFS) Delete

func (vfs *MemoryVFS) Delete(path string) error

Delete removes file from memory

func (*MemoryVFS) Exists

func (vfs *MemoryVFS) Exists(path string) bool

Exists checks if file exists in memory

func (*MemoryVFS) Glob

func (vfs *MemoryVFS) Glob(pattern string) ([]string, error)

Glob returns files matching pattern

func (*MemoryVFS) List

func (vfs *MemoryVFS) List() ([]string, error)

List returns all files in memory

func (*MemoryVFS) Read

func (vfs *MemoryVFS) Read(path string) ([]byte, error)

Read reads file content from memory

func (*MemoryVFS) TempDir

func (vfs *MemoryVFS) TempDir(prefix string) (string, error)

TempDir creates a temporary directory path in memory

func (*MemoryVFS) Write

func (vfs *MemoryVFS) Write(path string, data []byte) error

Write writes file content to memory

type OptimizedBuildContext

type OptimizedBuildContext struct {
	context.Context
	Request   BuildRequest
	MemPool   *optimize.MemoryPool
	Profiler  *BuildProfiler
	StartTime time.Time
}

OptimizedBuildContext contains context for optimized builds

type ParallelExecutor

type ParallelExecutor struct {
	// contains filtered or unexported fields
}

ParallelExecutor executes tasks in parallel

func NewParallelExecutor

func NewParallelExecutor(maxParallel int) *ParallelExecutor

NewParallelExecutor creates a parallel executor

func (*ParallelExecutor) Execute

func (pe *ParallelExecutor) Execute(ctx context.Context, plan *ParallelPlan) error

Execute executes a parallel plan

type ParallelPlan

type ParallelPlan struct {
	Stages []ParallelStage
}

ParallelPlan represents an execution plan

type ParallelStage

type ParallelStage struct {
	Tasks       []BuildTask
	MaxParallel int
}

ParallelStage represents a parallel execution stage

type PersistentCache

type PersistentCache struct {
	// contains filtered or unexported fields
}

PersistentCache implements BuildCache with disk persistence

func NewPersistentCache

func NewPersistentCache(dir string) *PersistentCache

NewPersistentCache creates a persistent cache

func (*PersistentCache) Clear

func (pc *PersistentCache) Clear() error

Clear removes all cached results

func (*PersistentCache) Get

func (pc *PersistentCache) Get(key CacheKey) (*BuildResult, bool)

Get retrieves from persistent cache

func (*PersistentCache) Invalidate

func (pc *PersistentCache) Invalidate(key CacheKey) error

Invalidate removes from cache

func (*PersistentCache) Put

func (pc *PersistentCache) Put(key CacheKey, result *BuildResult) error

Put stores in persistent cache

func (*PersistentCache) Stats

func (pc *PersistentCache) Stats() CacheStats

Stats returns cache statistics

type PipelineOptimizer

type PipelineOptimizer struct {
	// contains filtered or unexported fields
}

PipelineOptimizer optimizes build pipelines for maximum performance

func NewPipelineOptimizer

func NewPipelineOptimizer() *PipelineOptimizer

NewPipelineOptimizer creates an optimized build pipeline

func (*PipelineOptimizer) OptimizedBuild

func (po *PipelineOptimizer) OptimizedBuild(ctx context.Context, request BuildRequest) (*BuildResult, error)

OptimizedBuild performs an optimized build

type PipelineStats

type PipelineStats struct {
	TotalBuilds         atomic.Uint64
	SuccessfulBuilds    atomic.Uint64
	FailedBuilds        atomic.Uint64
	AvgBuildTime        atomic.Int64 // microseconds
	ParallelEfficiency  float64
	ResourceUtilization float64
	CacheHitRate        float64
}

PipelineStats tracks pipeline performance

type PluginInfo

type PluginInfo struct {
	// Plugin name
	Name string `json:"name"`

	// Plugin version
	Version string `json:"version"`

	// Plugin description
	Description string `json:"description"`

	// Supported languages
	Languages []string `json:"languages"`

	// Supported file extensions
	Extensions []string `json:"extensions"`

	// Plugin capabilities
	Capabilities []string `json:"capabilities"`

	// Memory-only build support
	SupportsMemoryBuild bool `json:"supports_memory_build"`
}

PluginInfo describes an available build plugin

type PriorityQueue

type PriorityQueue struct {
	// contains filtered or unexported fields
}

Priority queue implementation for task scheduling

func NewPriorityQueue

func NewPriorityQueue() *PriorityQueue

func (*PriorityQueue) Pop

func (pq *PriorityQueue) Pop() *ScheduledTask

func (*PriorityQueue) Push

func (pq *PriorityQueue) Push(task ScheduledTask)

type ProjectMetadata

type ProjectMetadata struct {
	// Project name
	Name string `json:"name"`

	// Programming language
	Language string `json:"language"`

	// Project version
	Version string `json:"version"`

	// Main entry point
	MainFile string `json:"main_file,omitempty"`

	// Project type (application, library, etc.)
	Type string `json:"type"`

	// Build system detected (make, npm, cargo, etc.)
	BuildSystem string `json:"build_system,omitempty"`

	// Project dependencies count
	DependencyCount int `json:"dependency_count"`
}

ProjectMetadata describes the project being built

type RemoteCacheBackend

type RemoteCacheBackend interface {
	Get(ctx context.Context, key string) ([]byte, error)
	Put(ctx context.Context, key string, data []byte) error
	Exists(ctx context.Context, key string) (bool, error)
	Delete(ctx context.Context, key string) error
	List(ctx context.Context, prefix string) ([]string, error)
}

RemoteCacheBackend defines interface for remote cache storage

type RemoteCacheClient

type RemoteCacheClient interface {
	Get(key string) ([]byte, error)
	Put(key string, value []byte, ttl time.Duration) error
	Delete(key string) error
}

RemoteCacheClient interface for remote cache backends

type RepoVFS

type RepoVFS struct {
	// contains filtered or unexported fields
}

RepoVFS implements VirtualFileSystem backed by govc.Repository

func (*RepoVFS) CreateBridge

func (v *RepoVFS) CreateBridge() (FilesystemBridge, error)

func (*RepoVFS) Delete

func (v *RepoVFS) Delete(path string) error

func (*RepoVFS) Exists

func (v *RepoVFS) Exists(path string) bool

func (*RepoVFS) Glob

func (v *RepoVFS) Glob(pattern string) ([]string, error)

func (*RepoVFS) List

func (v *RepoVFS) List() ([]string, error)

func (*RepoVFS) Read

func (v *RepoVFS) Read(path string) ([]byte, error)

func (*RepoVFS) TempDir

func (v *RepoVFS) TempDir(prefix string) (string, error)

func (*RepoVFS) Write

func (v *RepoVFS) Write(path string, data []byte) error

type ResourceOptimizer

type ResourceOptimizer struct {
	// contains filtered or unexported fields
}

ResourceOptimizer optimizes resource usage during builds

func NewResourceOptimizer

func NewResourceOptimizer() *ResourceOptimizer

NewResourceOptimizer creates a resource optimizer

func (*ResourceOptimizer) OptimizeForBuild

func (ro *ResourceOptimizer) OptimizeForBuild(buildType string, estimatedDuration time.Duration)

OptimizeForBuild optimizes system resources for a build

type ScheduledTask

type ScheduledTask struct {
	ID            string
	Priority      int
	Dependencies  []string
	EstimatedTime time.Duration
	Task          func() error
	ResultChan    chan error
}

ScheduledTask represents a scheduled build task

type SchedulerStats

type SchedulerStats struct {
	TasksScheduled    atomic.Uint64
	TasksCompleted    atomic.Uint64
	AvgWaitTime       atomic.Int64
	WorkerUtilization []float64
}

SchedulerStats tracks scheduler performance

type StreamingVFS

type StreamingVFS struct {
	// contains filtered or unexported fields
}

StreamingVFS wraps a VFS to provide streaming capabilities

func NewStreamingVFS

func NewStreamingVFS(base VirtualFileSystem) *StreamingVFS

NewStreamingVFS creates a streaming-capable VFS

func (*StreamingVFS) OpenStream

func (s *StreamingVFS) OpenStream(path string) (io.ReadWriteCloser, error)

OpenStream opens a file for streaming

type TaskParallelizer

type TaskParallelizer struct {
	// contains filtered or unexported fields
}

TaskParallelizer identifies and parallelizes independent tasks

func NewTaskParallelizer

func NewTaskParallelizer(maxParallel int) *TaskParallelizer

NewTaskParallelizer creates a task parallelizer

func (*TaskParallelizer) ParallelizeBuild

func (tp *TaskParallelizer) ParallelizeBuild(tasks []BuildTask) *ParallelPlan

ParallelizeBuild identifies parallel execution opportunities

type ThreadTuner

type ThreadTuner struct{}

func NewThreadTuner

func NewThreadTuner() *ThreadTuner

func (*ThreadTuner) AdjustForBuildType

func (tt *ThreadTuner) AdjustForBuildType(buildType string)

type VirtualFileSystem

type VirtualFileSystem interface {
	// Read file content from memory
	Read(path string) ([]byte, error)

	// Write file content to memory
	Write(path string, data []byte) error

	// Delete file from memory
	Delete(path string) error

	// List files matching pattern
	Glob(pattern string) ([]string, error)

	// List all files
	List() ([]string, error)

	// Check if file exists
	Exists(path string) bool

	// Create temporary directory in memory
	TempDir(prefix string) (string, error)

	// CreateBridge creates a temporary bridge to real filesystem
	// This is used when external tools require real files
	CreateBridge() (FilesystemBridge, error)
}

VirtualFileSystem abstracts file operations for memory-only builds

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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