Skip to content

Commit 2085462

Browse files
committed
docs: update README for netresearch/go-cron fork
- Update badges and import paths for the fork - Document panic fixes (issues robfig#554, robfig#555, robfig#551) - Document DST handling improvements (PR robfig#541) - Update Go version requirement to 1.25 - Simplify and modernize documentation structure
1 parent 83346ef commit 2085462

File tree

1 file changed

+49
-61
lines changed

1 file changed

+49
-61
lines changed

README.md

Lines changed: 49 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,54 @@
1-
[![GoDoc](http://godoc.org/github.com/robfig/cron?status.png)](http://godoc.org/github.com/robfig/cron)
2-
[![Build Status](https://travis-ci.org/robfig/cron.svg?branch=master)](https://travis-ci.org/robfig/cron)
1+
[![Go Reference](https://pkg.go.dev/badge/github.com/netresearch/go-cron.svg)](https://pkg.go.dev/github.com/netresearch/go-cron)
32

4-
# cron
3+
# go-cron
54

6-
Cron V3 has been released!
5+
A maintained fork of [robfig/cron](https://github.com/robfig/cron) with bug fixes and improvements.
6+
7+
## Installation
78

8-
To download the specific tagged release, run:
99
```bash
10-
go get github.com/robfig/cron/[email protected]
10+
go get github.com/netresearch/go-cron
1111
```
12+
1213
Import it in your program as:
1314
```go
14-
import "github.com/robfig/cron/v3"
15+
import "github.com/netresearch/go-cron"
1516
```
16-
It requires Go 1.11 or later due to usage of Go Modules.
1717

18-
Refer to the documentation here:
19-
http://godoc.org/github.com/robfig/cron
18+
Requires Go 1.25 or later.
2019

21-
The rest of this document describes the the advances in v3 and a list of
22-
breaking changes for users that wish to upgrade from an earlier version.
20+
## Why This Fork?
2321

24-
## Upgrading to v3 (June 2019)
22+
The original robfig/cron has been unmaintained since 2020, with 50+ open PRs and several
23+
critical panic bugs. This fork addresses:
2524

26-
cron v3 is a major upgrade to the library that addresses all outstanding bugs,
27-
feature requests, and rough edges. It is based on a merge of master which
28-
contains various fixes to issues found over the years and the v2 branch which
29-
contains some backwards-incompatible features like the ability to remove cron
30-
jobs. In addition, v3 adds support for Go Modules, cleans up rough edges like
31-
the timezone support, and fixes a number of bugs.
25+
- **Panic fixes**: Fixed TZ= parsing panics (issues #554, #555)
26+
- **Chain behavior**: Added `Entry.Run()` method to properly invoke chain decorators (issue #551)
27+
- **DST handling**: Jobs scheduled during DST "spring forward" now run immediately (ISC cron behavior, PR #541)
28+
- **Go 1.25**: Updated to latest Go version with modern toolchain
3229

33-
New features:
30+
## Migrating from robfig/cron
3431

35-
- Support for Go modules. Callers must now import this library as
36-
`github.com/robfig/cron/v3`, instead of `gopkg.in/...`
32+
Simply update your import path:
33+
```go
34+
// Before
35+
import "github.com/robfig/cron/v3"
36+
37+
// After
38+
import cron "github.com/netresearch/go-cron"
39+
```
3740

38-
- Fixed bugs:
39-
- 0f01e6b parser: fix combining of Dow and Dom (#70)
40-
- dbf3220 adjust times when rolling the clock forward to handle non-existent midnight (#157)
41-
- eeecf15 spec_test.go: ensure an error is returned on 0 increment (#144)
42-
- 70971dc cron.Entries(): update request for snapshot to include a reply channel (#97)
43-
- 1cba5e6 cron: fix: removing a job causes the next scheduled job to run too late (#206)
41+
The API is fully compatible with robfig/cron v3.
42+
43+
## Documentation
44+
45+
Refer to the [package documentation](https://pkg.go.dev/github.com/netresearch/go-cron).
46+
47+
## Features (inherited from robfig/cron v3)
48+
49+
This fork maintains full compatibility with robfig/cron v3 while adding fixes.
50+
51+
Original v3 features:
4452

4553
- Standard cron spec parsing by default (first field is "minute"), with an easy
4654
way to opt into the seconds field (quartz-compatible). Although, note that the
@@ -57,14 +65,8 @@ New features:
5765
- Log each job's invocations
5866
- Notification when jobs are completed
5967

60-
It is backwards incompatible with both v1 and v2. These updates are required:
61-
62-
- The v1 branch accepted an optional seconds field at the beginning of the cron
63-
spec. This is non-standard and has led to a lot of confusion. The new default
64-
parser conforms to the standard as described by [the Cron wikipedia page].
68+
## Usage Examples
6569

66-
UPDATING: To retain the old behavior, construct your Cron with a custom
67-
parser:
6870
```go
6971
// Seconds field, required
7072
cron.New(cron.WithSeconds())
@@ -73,40 +75,26 @@ cron.New(cron.WithSeconds())
7375
cron.New(cron.WithParser(cron.NewParser(
7476
cron.SecondOptional | cron.Minute | cron.Hour | cron.Dom | cron.Month | cron.Dow | cron.Descriptor,
7577
)))
76-
```
77-
- The Cron type now accepts functional options on construction rather than the
78-
previous ad-hoc behavior modification mechanisms (setting a field, calling a setter).
79-
80-
UPDATING: Code that sets Cron.ErrorLogger or calls Cron.SetLocation must be
81-
updated to provide those values on construction.
82-
83-
- CRON_TZ is now the recommended way to specify the timezone of a single
84-
schedule, which is sanctioned by the specification. The legacy "TZ=" prefix
85-
will continue to be supported since it is unambiguous and easy to do so.
86-
87-
UPDATING: No update is required.
8878

89-
- By default, cron will no longer recover panics in jobs that it runs.
90-
Recovering can be surprising (see issue #192) and seems to be at odds with
91-
typical behavior of libraries. Relatedly, the `cron.WithPanicLogger` option
92-
has been removed to accommodate the more general JobWrapper type.
93-
94-
UPDATING: To opt into panic recovery and configure the panic logger:
95-
```go
79+
// With panic recovery
9680
cron.New(cron.WithChain(
97-
cron.Recover(logger), // or use cron.DefaultLogger
81+
cron.Recover(logger),
9882
))
99-
```
100-
- In adding support for https://github.com/go-logr/logr, `cron.WithVerboseLogger` was
101-
removed, since it is duplicative with the leveled logging.
10283

103-
UPDATING: Callers should use `WithLogger` and specify a logger that does not
104-
discard `Info` logs. For convenience, one is provided that wraps `*log.Logger`:
105-
```go
84+
// With verbose logging
10685
cron.New(
10786
cron.WithLogger(cron.VerbosePrintfLogger(logger)))
10887
```
10988

89+
## Timezone Support
90+
91+
CRON_TZ is the recommended way to specify the timezone of a single schedule:
92+
```
93+
CRON_TZ=America/New_York 0 0 * * *
94+
```
95+
96+
The legacy "TZ=" prefix is also supported.
97+
11098
### Background - Cron spec format
11199

112100
There are two cron spec formats in common usage:

0 commit comments

Comments
 (0)