https://github.com/schraf/jobsystem
A concurrent job execution system for Go with dependency management
https://github.com/schraf/jobsystem
Last synced: 7 months ago
JSON representation
A concurrent job execution system for Go with dependency management
- Host: GitHub
- URL: https://github.com/schraf/jobsystem
- Owner: schraf
- License: mit
- Archived: true
- Created: 2025-12-05T13:02:58.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-12-06T14:28:26.000Z (8 months ago)
- Last Synced: 2025-12-09T00:00:30.610Z (8 months ago)
- Language: Go
- Size: 15.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# jobsystem
A concurrent job execution system for Go with dependency management.
## Overview
`jobsystem` provides a way to schedule and execute jobs concurrently while ensuring that jobs are executed only after their dependencies have completed successfully.
## Installation
```bash
go get github.com/schraf/jobsystem
```
## Usage
```go
package main
import (
"context"
"fmt"
"github.com/schraf/jobsystem"
)
func main() {
system := jobsystem.NewJobSystem()
ctx := context.Background()
// Create job IDs
job1 := jobsystem.NewJobId()
job2 := jobsystem.NewJobId()
job3 := jobsystem.NewJobId()
// Schedule jobs with dependencies
system.ScheduleJob(job1, nil, func(ctx context.Context) error {
fmt.Println("Job 1 executing")
return nil
})
system.ScheduleJob(job2, []jobsystem.JobId{job1}, func(ctx context.Context) error {
fmt.Println("Job 2 executing (depends on job1)")
return nil
})
system.ScheduleJob(job3, []jobsystem.JobId{job1, job2}, func(ctx context.Context) error {
fmt.Println("Job 3 executing (depends on job1 and job2)")
return nil
})
// Run all jobs with a concurrency limit of 10
if err := system.Run(ctx, 10); err != nil {
fmt.Printf("Error: %v\n", err)
}
}
```
## Features
- Concurrent job execution with configurable concurrency limits
- Dependency management
- Type-safe job identifiers
- Error handling with custom error types
## Concurrency Limits
The `Run` method requires a `concurrencyLimit` parameter that specifies the maximum number of jobs that can run simultaneously. This limit must be greater than 0. The system uses a semaphore to enforce this limit, ensuring that resource usage is controlled even when many jobs are ready to execute.