distributed

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package distributed provides distributed task execution for monox.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeInputHash

func ComputeInputHash(files []string) (string, error)

ComputeInputHash computes the hash of input files.

Types

type Config

type Config struct {
	Enabled       bool     `json:"enabled" yaml:"enabled"`
	Workers       []string `json:"workers" yaml:"workers"`
	MaxParallel   int      `json:"maxParallel" yaml:"maxParallel"`
	Timeout       int      `json:"timeout" yaml:"timeout"`
	CacheEndpoint string   `json:"cacheEndpoint" yaml:"cacheEndpoint"`
}

Config holds distributed execution configuration.

type Coordinator

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

Coordinator manages distributed task execution across workers.

func NewCoordinator

func NewCoordinator(config *Config) *Coordinator

NewCoordinator creates a new distributed coordinator.

func (*Coordinator) Results

func (c *Coordinator) Results() <-chan *TaskResult

Results returns the result channel.

func (*Coordinator) Start

func (c *Coordinator) Start(ctx context.Context) error

Start begins the coordinator.

func (*Coordinator) Stop

func (c *Coordinator) Stop()

Stop stops the coordinator.

func (*Coordinator) Submit

func (c *Coordinator) Submit(task *TaskRequest) error

Submit submits a task for distributed execution.

type FileRef

type FileRef struct {
	Path  string `json:"path"`
	Hash  string `json:"hash"`
	Size  int64  `json:"size"`
	IsDir bool   `json:"isDir"`
}

FileRef references a file for remote execution.

type RemoteCache

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

RemoteCache provides distributed caching.

func NewRemoteCache

func NewRemoteCache(endpoint string) *RemoteCache

NewRemoteCache creates a new remote cache client.

func (*RemoteCache) Get

func (c *RemoteCache) Get(ctx context.Context, key string) (*api.CacheEntry, error)

Get retrieves a cached result.

func (*RemoteCache) Put

func (c *RemoteCache) Put(ctx context.Context, key string, entry *api.CacheEntry) error

Put stores a result in the cache.

type TaskRequest

type TaskRequest struct {
	ID          string            `json:"id"`
	Project     string            `json:"project"`
	Task        string            `json:"task"`
	Command     string            `json:"command"`
	Args        []string          `json:"args"`
	Env         map[string]string `json:"env"`
	WorkDir     string            `json:"workDir"`
	InputHash   string            `json:"inputHash"`
	InputFiles  []FileRef         `json:"inputFiles"`
	OutputPaths []string          `json:"outputPaths"`
}

TaskRequest is a request to execute a task remotely.

type TaskResult

type TaskResult struct {
	ID          string    `json:"id"`
	Success     bool      `json:"success"`
	ExitCode    int       `json:"exitCode"`
	Stdout      string    `json:"stdout"`
	Stderr      string    `json:"stderr"`
	Duration    int64     `json:"durationMs"`
	OutputFiles []FileRef `json:"outputFiles"`
	CacheKey    string    `json:"cacheKey"`
	WorkerID    string    `json:"workerId"`
}

TaskResult is the result of a remote task execution.

type Worker

type Worker struct {
	ID       string
	Endpoint string
	Capacity int
	Active   int
	Health   WorkerHealth
	LastSeen time.Time
}

Worker represents a remote execution worker.

type WorkerHealth

type WorkerHealth string

WorkerHealth represents worker health status.

const (
	WorkerHealthy   WorkerHealth = "healthy"
	WorkerUnhealthy WorkerHealth = "unhealthy"
	WorkerUnknown   WorkerHealth = "unknown"
)

type WorkerServer

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

WorkerServer is an HTTP server for remote execution.

func NewWorkerServer

func NewWorkerServer(port int) *WorkerServer

NewWorkerServer creates a new worker server.

func (*WorkerServer) Start

func (s *WorkerServer) Start() error

Start starts the worker server.

Jump to

Keyboard shortcuts

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