- API Create, Read, Update, Delete Job
- Timezone Support, Otomatis Konversi waktu ke timezone yang diinginkan
- Presist Job (Postgre)
- Async Job Eksekusi
- Async Circuit Breaker
- Health Check
- Testing Endpoint (Dev Purposes)
git clone https://github.com/iuran-org/scheduler
cd scheduler
venv activate
pip install -r requirements.txt
uvicorn main:app --reload --port 8008 --host 0.0.0.0 --workers 4
docker compose up --build -d
http://localhost:8008/docs
http://localhost:8008/jobs/interval
{
"days": 1,
"start_date": "2024-01-20T08:00:00",
"callback_url": "http://localhost:8008/callback/test",
"payload": {
"type": "daily_job",
"time": "08:00"
},
"timezone": "GMT+7"
}
{
"weeks": 1,
"start_date": "2024-01-22T09:00:00", // Pastikan ini hari Senin
"callback_url": "http://localhost:8008/callback/test",
"payload": {
"type": "weekly_job",
"day": "Monday"
},
"timezone": "GMT+7"
}
{
"days": 365, // atau 366 untuk tahun kabisat
"start_date": "2024-01-01T00:00:00",
"callback_url": "http://localhost:8008/callback/test",
"payload": {
"type": "yearly_job",
"event": "new_year"
},
"timezone": "GMT+7"
}
Setiap 2 jam:
{
"hours": 2,
"callback_url": "http://localhost:8008/callback/test",
"payload": {
"type": "hourly_job"
},
"timezone": "GMT+7"
}
Setiap 30 menit:
{
"minutes": 30,
"callback_url": "http://localhost:8008/callback/test",
"payload": {
"type": "frequent_job"
},
"timezone": "GMT+7"
}
Setiap 2 minggu pada hari Jumat jam 3 sore:
{
"minutes": 30,
"callback_url": "http://localhost:8008/callback/test",
"payload": {
"type": "frequent_job"
},
"timezone": "GMT+7"
}
PyBreaker mengimplementasikan pola Circuit Breaker untuk menangani kegagalan sistem:
- Closed (Normal): Sistem berjalan normal, request diteruskan
- Open: Setelah beberapa kegagalan, circuit terbuka dan request langsung ditolak
- Half-Open: Setelah waktu timeout, circuit membuka sebagian untuk test koneksi
breaker = CircuitBreaker(
fail_max=5, # Jumlah kegagalan sebelum circuit open
reset_timeout=60, # Waktu tunggu sebelum half-open (detik)
exclude=[ValueError] # Error yang tidak dihitung sebagai kegagalan
)
DB_USER=
DB_PASSWORD=
DB_HOST=localhost
DB_PORT=5432
DB_NAME=scheduler
MISFIRE_GRACE_TIME=900 // 15 minutes
PORT_EXPOSE=8009
API_DOCS_USERNAME=
API_DOCS_PASSWORD=
{
"schedule_time": "2024-01-20T08:00:00",
"callback_url": "http://localhost:8008/callback/test",
"payload": {
"key": "value"
},
"timezone": "GMT+7" // Opsional, default: "UTC"
}
{
"schedule_time": "2024-01-20T08:00:00", // Opsional
"callback_url": "string", // Opsional
"payload": { // Opsional
"key": "value"
},
"timezone": "string" // Opsional
}
{
"weeks": 0, // Opsional
"days": 0, // Opsional
"hours": 0, // Opsional
"minutes": 0, // Opsional
"seconds": 0, // Opsional
"start_date": "2024-01-20T08:00:00", // Opsional
"end_date": "2024-01-20T08:00:00", // Opsional
"timezone": "GMT+7", // Opsional, default: "UTC"
"callback_url": "string",
"payload": {
"key": "value"
},
"jitter": 0 // Opsional
}
{
"weeks": 0, // Opsional
"days": 0, // Opsional
"hours": 0, // Opsional
"minutes": 0, // Opsional
"seconds": 0, // Opsional
"start_date": "2024-01-20T08:00:00", // Opsional
"end_date": "2024-01-20T08:00:00", // Opsional
"timezone": "string", // Opsional
"callback_url": "string", // Opsional
"payload": { // Opsional
"key": "value"
},
"jitter": 0 // Opsional
}