Skip to content

sleepyvani/gotask

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Cronjob

Multi-threaded HTTP cronjob scheduler written in Go. Designed to handle thousands of concurrent tasks efficiently with minimal memory footprint.

Features

  • Concurrent task execution with configurable worker pool
  • Domain-based rate limiting to prevent server overload
  • Memory optimized for handling 20,000+ tasks
  • Automatic garbage collection and connection cleanup
  • Graceful shutdown on interrupt signals
  • Real-time progress monitoring

Requirements

  • Go 1.21 or higher

Installation

git clone <repository-url>
cd cron
go build -o cronjob app.go

Usage

Basic Usage

go run app.go urls.txt

Or with compiled binary:

./cronjob urls.txt

File Format

Create a text file with one task per line in the following format:

url|interval|method
  • url: Target URL (required, max 2048 characters)
  • interval: Execution interval in seconds (required, must be > 0)
  • method: HTTP method - GET or POST (optional, defaults to GET)

Examples

https://example.com/api/endpoint|5|GET
https://api.example.com/data|10|POST
http://localhost:8080/health|1|GET

Lines starting with # are treated as comments and ignored.

Behavior

  • All tasks start immediately when the program runs
  • Each task runs independently according to its interval
  • Tasks continue running until the program is stopped (Ctrl+C)
  • Rate limiting is applied per domain to prevent overwhelming target servers

Configuration

Default configuration values can be modified in app.go:

  • vanixjnkWorkers: Number of worker goroutines (default: 50)
  • vanixjnkTimeout: HTTP request timeout (default: 10 seconds)
  • vaniMaxRequests: Maximum requests per domain per second (default: 1000)
  • vaniMaxConcurrentRequests: Maximum concurrent requests globally (default: 1000)
  • vanidevGCInterval: Garbage collection interval (default: 10 seconds)

Performance

  • Memory usage: ~500MB-1GB for 20,000 tasks
  • Concurrent goroutines: Limited to prevent unbounded growth
  • HTTP connections: Automatically cleaned up and reused

License

MIT License

Copyright (c) 2025

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages