manager

package
v0.0.0-...-14be240 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidTimeframe = fmt.Errorf("invalid timeframe specified")
)

Functions

This section is empty.

Types

type Job

type Job struct {
	JobID             string
	ArgType           string
	Arguments         map[string]interface{}
	ChainID           string
	ContractAddress   string
	JobCostPrediction float64
	Stake             float64
	Status            string
	TargetFunction    string
	TimeFrame         int64 // in seconds
	TimeInterval      int64 // in seconds
	UserID            string
	CreatedAt         time.Time
	MaxRetries        int
	CurrentRetries    int
	LastExecuted      time.Time
	NextExecutionTime time.Time
	Error             string
	Payload           map[string]interface{}
	CodeURL           string
}

Job represents a scheduled task with its properties

type JobScheduler

type JobScheduler struct {
	Cron *cron.Cron
	// contains filtered or unexported fields
}

JobScheduler enhanced with load balancing

func NewJobScheduler

func NewJobScheduler(workersCount int) *JobScheduler

NewJobScheduler creates an enhanced scheduler with resource limits

func (*JobScheduler) AddJob

func (js *JobScheduler) AddJob(job *Job) error

AddJob enhanced with resource checking

func (*JobScheduler) GetJobDetails

func (js *JobScheduler) GetJobDetails(jobID string) (map[string]interface{}, error)

GetJobDetails returns detailed information about a specific job

func (*JobScheduler) GetQueueStatus

func (js *JobScheduler) GetQueueStatus() map[string]interface{}

GetQueueStatus returns the current status of job queues

func (*JobScheduler) GetSystemMetrics

func (js *JobScheduler) GetSystemMetrics() SystemResources

GetSystemMetrics returns current system metrics

func (*JobScheduler) SetResourceLimits

func (js *JobScheduler) SetResourceLimits(cpuThreshold, memoryThreshold float64)

func (*JobScheduler) Stop

func (js *JobScheduler) Stop()

Stop gracefully shuts down the scheduler

type Quorum

type Quorum struct {
	QuorumID    string
	NodeCount   int
	ActiveNodes []string
	Status      string
	ChainID     string
	CreatedAt   time.Time
	UpdatedAt   time.Time
}

Quorum represents a group of nodes that can execute jobs

type SystemResources

type SystemResources struct {
	CPUUsage    float64
	MemoryUsage float64
	MaxCPU      float64
	MaxMemory   float64
}

SystemResources tracks system resource usage

type WaitingJob

type WaitingJob struct {
	Job           *Job
	EstimatedTime time.Time
}

WaitingJob represents a job waiting in queue

Jump to

Keyboard shortcuts

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