AI Decision System
Replayable, offline-verifiable records for AI-assisted go/no-go decisions: experiment promotions, typed model answers and human-approved actions.
간편하고 유연한 Go 크론 스케줄링, 기존 gocron 포크
Easy and fluent Go cron scheduling. This is a fork from https://github.com/jasonlvhit/gocron
개발 도구Go · MakefileGitHub @go-co-op직접 설치운영자 미확인
써 보셨어요? 한 번만 눌러 주세요. 로그인은 필요 없어요.
메이커가 쓴 소개는 위의 한 줄이 전부입니다. 더 자세한 내용은 저장소 README에서 읽을 수 있습니다. 저장소 README ↗
README 전체를 불러오는 중입니다.
README 전문 보기 ↗gocron is a job scheduling package which lets you run Go functions at pre-determined intervals.
Looking for a visual interface? Check out gocron-ui — a lightweight web dashboard to monitor, trigger, and manage your
gocronjobs in real time.
If you want to chat, you can find us on Slack at
go get github.com/go-co-op/gocron/v2
package main
import (
"fmt"
"time"
"github.com/go-co-op/gocron/v2"
)
func main() {
// create a scheduler
s, err := gocron.NewScheduler()
if err != nil {
// handle error
}
// add a job to the scheduler
j, err := s.NewJob(
gocron.DurationJob(
10*time.Second,
),
gocron.NewTask(
func(a string, b int) {
// do things
},
"hello",
1,
),
)
if err != nil {
// handle error
}
// each job has a unique id
fmt.Println(j.ID())
// start the scheduler
s.Start()
// block until you are ready to shut down
select {
case <-time.After(time.Minute):
}
// when you're done, shut it down
err = s.Shutdown()
// or for context-aware teardown:
// err = s.ShutdownWithContext(ctx)
if err != nil {
// handle error
}
}
Community articles and tutorials about using gocron:
Jobs can be run at various intervals.
time.Duration.time.Duration between a min and max.Jobs can be scheduled with different interval timing modes.
Jobs can be limited individually or across the entire scheduler.
Multiple instances of gocron can be run.
Job events can trigger actions.
Many job and scheduler options are available.
NewJob.NewScheduler
and the WithGlobalJobOptions option.NewScheduler.Logs can be enabled.
Metrics may be collected from the execution of each job and scheduler lifecycle events.
Monitor: A monitor can be used to collect metrics for each job from a scheduler.
MonitorStatus: Extends Monitor with status and error tracking for each job.
SchedulerMonitor: A scheduler monitor provides comprehensive observability into scheduler and job lifecycle events.
Available Metrics:
SchedulerStarted, SchedulerStopped, SchedulerShutdownJobRegistered, JobUnregistered - track jobs added/removed from schedulerJobStarted, JobRunning, JobCompleted, JobFailed - monitor job execution flowJobExecutionTime, JobSchedulingDelay - measure job duration and scheduling lagThe gocron library is set up to enable testing.
We appreciate the support for free and open source software!
This project is supported by:
ConcurrencyLimitReachedDerived Metrics (calculable from events):
JobFailed / (JobCompleted + JobFailed)JobExecutionTime eventsJobRegistered - JobUnregisteredJobStarted - (JobCompleted + JobFailed)Example - Prometheus Integration:
type PrometheusMonitor struct {
jobsCompleted prometheus.Counter
jobsFailed prometheus.Counter
executionTime prometheus.Histogram
schedulingDelay prometheus.Histogram
}
func (p *PrometheusMonitor) JobExecutionTime(job gocron.Job, duration time.Duration) {
p.executionTime.Observe(duration.Seconds())
}
func (p *PrometheusMonitor) JobSchedulingDelay(job gocron.Job, scheduled, actual time.Time) {
if delay := actual.Sub(scheduled); delay > 0 {
p.schedulingDelay.Observe(delay.Seconds())
}
}
// Initialize scheduler with monitor
s, _ := gocron.NewScheduler(gocron.WithSchedulerMonitor(monitor))
Use Cases: Prometheus metrics, custom dashboards, alerting systems, performance monitoring