Skip to content

Commit

Permalink
update changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
fwidjaya20 committed Dec 9, 2023
1 parent 4872382 commit 9d613d6
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 17 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.1.5] - 2023-12-09

### Added

- Support `log.Logger` contract on Echo Framework.

### Fixed

- Fix invalid Schedule Timing caused by `cron.WithSecond()` by adding "0" in front of expression.

## [1.1.4] - 2023-12-01

### Fixed
Expand Down Expand Up @@ -53,6 +63,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Support `Schedule` feature.
- Support `Queue` feature

[1.1.5]: https://github.com/fwidjaya20/symphonic/compare/v1.1.4...v1.1.5
[1.1.4]: https://github.com/fwidjaya20/symphonic/compare/v1.1.3...v1.1.4
[1.1.3]: https://github.com/fwidjaya20/symphonic/compare/v1.1.2...v1.1.3
[1.1.2]: https://github.com/fwidjaya20/symphonic/compare/v1.1.1...v1.1.2
Expand Down
3 changes: 3 additions & 0 deletions contracts/schedule/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ type Job interface {
Hourly() Job
HourlyAt(atMinutes ...string) Job
Daily() Job
DailyAt(atHours ...string) Job
Weekly() Job
WeeklyAt(atDaysOfWeek ...string) Job
Monthly() Job
MonthlyAt(atDaysOfMonth ...string) Job
}
50 changes: 34 additions & 16 deletions schedule/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ func NewJob(callback func()) schedule.Job {
}

func (j *Job) SetTiming(expression string) schedule.Job {
if len(strings.Split(expression, " ")) == 5 {
expression = "0 " + expression
}
j.timing = expression
return j
}
Expand Down Expand Up @@ -71,56 +68,77 @@ func (j *Job) EveryThirtySecond() schedule.Job {
}

func (j *Job) EveryMinute() schedule.Job {
return j.SetTiming("* * * * *")
return j.SetTiming("0 * * * * *")
}

func (j *Job) EveryTwoMinute() schedule.Job {
return j.SetTiming("*/2 * * * *")
return j.SetTiming("0 */2 * * * *")
}

func (j *Job) EveryThreeMinute() schedule.Job {
return j.SetTiming("*/3 * * * *")
return j.SetTiming("0 */3 * * * *")
}

func (j *Job) EveryFourMinute() schedule.Job {
return j.SetTiming("*/4 * * * *")
return j.SetTiming("0 */4 * * * *")
}

func (j *Job) EveryFiveMinute() schedule.Job {
return j.SetTiming("*/5 * * * *")
return j.SetTiming("0 */5 * * * *")
}

func (j *Job) EveryTenMinute() schedule.Job {
return j.SetTiming("*/10 * * * *")
return j.SetTiming("0 */10 * * * *")
}

func (j *Job) EveryFifteenMinute() schedule.Job {
return j.SetTiming("*/15 * * * *")
return j.SetTiming("0 */15 * * * *")
}

func (j *Job) EveryThirtyMinute() schedule.Job {
return j.SetTiming("*/30 * * * *")
return j.SetTiming("0 */30 * * * *")
}

func (j *Job) Hourly() schedule.Job {
return j.SetTiming("0 * * * *")
return j.SetTiming("0 0 * * * *")
}

func (j *Job) HourlyAt(atMinutes ...string) schedule.Job {
if len(atMinutes) > 0 {
return j.SetTiming(fmt.Sprintf("%s * * * *", strings.Join(atMinutes, ",")))
return j.SetTiming(fmt.Sprintf("0 %s * * * *", strings.Join(atMinutes, ",")))
}
return j.Hourly()
}

func (j *Job) Daily() schedule.Job {
return j.SetTiming("0 0 * * *")
return j.SetTiming("0 0 0 * * *")
}

func (j *Job) DailyAt(atHours ...string) schedule.Job {
if len(atHours) > 0 {
return j.SetTiming(fmt.Sprintf("0 0 %s * * *", strings.Join(atHours, ",")))
}
return j.Daily()
}

func (j *Job) Weekly() schedule.Job {
return j.SetTiming("0 0 * * 0")
return j.SetTiming("0 0 0 * * 0")
}

func (j *Job) WeeklyAt(atDaysOfWeek ...string) schedule.Job {
if len(atDaysOfWeek) > 0 {
return j.SetTiming(fmt.Sprintf("0 0 0 * * %s", strings.Join(atDaysOfWeek, ",")))
}
return j.Weekly()
}

func (j *Job) Monthly() schedule.Job {
return j.SetTiming("0 0 1 * *")
return j.SetTiming("0 0 0 1 * *")
}

func (j *Job) MonthlyAt(atDaysOfMonth ...string) schedule.Job {
if len(atDaysOfMonth) > 0 {
return j.SetTiming(fmt.Sprintf("0 0 0 %s * *", strings.Join(atDaysOfMonth, ",")))
}
return j.Monthly()
}
2 changes: 1 addition & 1 deletion schedule/service_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ func (sp *ServiceProvider) Boot(app foundation.Application) {}

func (sp *ServiceProvider) Register(app foundation.Application) {
app.Instance(Binding, func(app foundation.Application) (any, error) {
return NewApplication(), nil
return NewApplication(app.GetLogger()), nil
})
}

0 comments on commit 9d613d6

Please sign in to comment.