Skip to content

Commit

Permalink
1.schedule:新增方法,2.更新README,3.将根目录的资源文件移动到static目录
Browse files Browse the repository at this point in the history
  • Loading branch information
keepchen committed Apr 19, 2024
1 parent 9fe3263 commit 5dcee74
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 8 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div align="center">
<h1><img src="./sailboat-solid-colorful.svg" alt="sailboat-solid" title="sailboat-solid" width="300" /></h1>
<h1><img src="static/sailboat-solid-colorful.svg" alt="sailboat-solid" title="sailboat-solid" width="300" /></h1>
</div>

[![Go](https://github.com/keepchen/go-sail/actions/workflows/go.yml/badge.svg)](https://github.com/keepchen/go-sail/actions/workflows/go.yml) [![CodeQL](https://github.com/keepchen/go-sail/actions/workflows/codeql.yml/badge.svg)](https://github.com/keepchen/go-sail/actions/workflows/codeql.yml) [![Go Report Card](https://goreportcard.com/badge/github.com/keepchen/go-sail/v3)](https://goreportcard.com/report/github.com/keepchen/go-sail/v3)
Expand Down Expand Up @@ -46,7 +46,7 @@ sail.WakeupHttp("go-sail", conf).
```
当你看到终端如下图所示内容就表示服务启动成功了:

<img src="./launch.png" alt="launch.png" title="launch.png" width="600" />
<img src="static/launch.png" alt="launch.png" title="launch.png" width="600" />

## 文档
[文档传送门](https://blog.keepchen.com/a/go-sail.html?from=github)
Expand Down
4 changes: 2 additions & 2 deletions README_EN.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div align="center">
<h1><img src="./sailboat-solid-colorful.svg" alt="sailboat-solid" title="sailboat-solid" width="300" /></h1>
<h1><img src="static/sailboat-solid-colorful.svg" alt="sailboat-solid" title="sailboat-solid" width="300" /></h1>
</div>

[![Go](https://github.com/keepchen/go-sail/actions/workflows/go.yml/badge.svg)](https://github.com/keepchen/go-sail/actions/workflows/go.yml) [![CodeQL](https://github.com/keepchen/go-sail/actions/workflows/codeql.yml/badge.svg)](https://github.com/keepchen/go-sail/actions/workflows/codeql.yml) [![Go Report Card](https://goreportcard.com/badge/github.com/keepchen/go-sail/v3)](https://goreportcard.com/report/github.com/keepchen/go-sail/v3)
Expand Down Expand Up @@ -46,7 +46,7 @@ sail.WakeupHttp("go-sail", conf).
```
Console screenshot after launched like this:

<img src="./launch.png" alt="launch.png" title="launch.png" width="600" />
<img src="static/launch.png" alt="launch.png" title="launch.png" width="600" />

## Documentation
[Docs](https://blog.keepchen.com/a/go-sail.html?from=github)
Expand Down
6 changes: 6 additions & 0 deletions schedule/crontabexpr.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ package schedule
// 一些常用的crontab表达式
const (
EveryMinute = "* * * * *" //每分钟的开始第0秒
EveryFiveMinute = "*/5 * * * *" //每5分钟的开始第0秒
EveryTenMinute = "*/10 * * * *" //每10分钟的开始第0秒
EveryFifteenMinute = "*/15 * * * *" //每15分钟的开始第0秒
EveryTwentyMinute = "*/20 * * * *" //每20分钟的开始第0秒
EveryThirtyMinute = "*/30 * * * *" //每30分钟的开始第0秒
EveryFortyFiveMinute = "*/45 * * * *" //每45分钟的开始第0秒
FirstDayOfMonth = "0 0 1 * *" //每月的第一天的0点0分
LastDayOfMonth = "0 0 L * *" //每月的最后一天的0点0分
FirstDayOfWeek = "0 0 * * 1" //每周的第一天(周一)的0点0分
Expand Down
File renamed without changes.
20 changes: 19 additions & 1 deletion schedule/interval.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,15 @@ func (j *taskJob) EveryTenSeconds() (cancel CancelFunc) {
return
}

// EveryFifteenSeconds 每15秒执行一次
func (j *taskJob) EveryFifteenSeconds() (cancel CancelFunc) {
j.setInterval(time.Second * 15).run()

cancel = j.cancelFunc

return
}

// EveryTwentySeconds 每20秒执行一次
func (j *taskJob) EveryTwentySeconds() (cancel CancelFunc) {
j.setInterval(time.Second * 20).run()
Expand Down Expand Up @@ -138,6 +147,15 @@ func (j *taskJob) EveryFiveMinutes() (cancel CancelFunc) {
return
}

// EveryFifteenMinutes 每15分钟执行一次
func (j *taskJob) EveryFifteenMinutes() (cancel CancelFunc) {
j.setInterval(time.Minute * 15).run()

cancel = j.cancelFunc

return
}

// EveryTenMinutes 每10分钟执行一次
func (j *taskJob) EveryTenMinutes() (cancel CancelFunc) {
j.setInterval(time.Minute * 10).run()
Expand Down Expand Up @@ -201,7 +219,7 @@ func (j *taskJob) EveryTwentyHours() (cancel CancelFunc) {
return
}

// Daily 每天执行一次
// Daily 每天执行一次(每24小时)
func (j *taskJob) Daily() (cancel CancelFunc) {
j.setInterval(time.Hour * 24).run()

Expand Down
10 changes: 7 additions & 3 deletions schedule/schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ type Scheduler interface {
EveryFiveSeconds() (cancel CancelFunc)
// EveryTenSeconds 每10秒执行一次
EveryTenSeconds() (cancel CancelFunc)
// EveryFifteenSeconds 每15秒执行一次
EveryFifteenSeconds() (cancel CancelFunc)
// EveryTwentySeconds 每20秒执行一次
EveryTwentySeconds() (cancel CancelFunc)
// EveryThirtySeconds 每30秒执行一次
Expand All @@ -43,6 +45,8 @@ type Scheduler interface {
EveryFiveMinutes() (cancel CancelFunc)
// EveryTenMinutes 每10分钟执行一次
EveryTenMinutes() (cancel CancelFunc)
// EveryFifteenMinutes 每15分钟执行一次
EveryFifteenMinutes() (cancel CancelFunc)
// EveryTwentyMinutes 每20分钟执行一次
EveryTwentyMinutes() (cancel CancelFunc)
// EveryThirtyMinutes 每30分钟执行一次
Expand All @@ -55,24 +59,24 @@ type Scheduler interface {
EveryTenHours() (cancel CancelFunc)
// EveryTwentyHours 每20小时执行一次
EveryTwentyHours() (cancel CancelFunc)
// Daily 每天执行一次
// Daily 每天执行一次(每24小时)
Daily() (cancel CancelFunc)
// Weekly 每周执行一次(每7天)
Weekly() (cancel CancelFunc)
// Monthly 每月执行一次(每30天)
Monthly() (cancel CancelFunc)
// Yearly 每年执行一次(每365天)
Yearly() (cancel CancelFunc)

// RunAfter 在一定时间后执行
//
// # Note
//
// 这是一个一次性任务,不会重复执行
RunAfter(delay time.Duration) (cancel CancelFunc)

// RunAt 在某一时刻执行
//
//重复地在某个时间点执行任务
//
// crontabExpr Linux crontab风格的表达式
//
// * * * * *
Expand Down
2 changes: 2 additions & 0 deletions schedule/specs.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (

// RunAt 在某一时刻执行
//
// 重复地在某个时间点执行任务
//
// crontabExpr Linux crontab风格的表达式
//
// * * * * *
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes

0 comments on commit 5dcee74

Please sign in to comment.