Merge pull request #4655 from Loyalsoldier/task-fix-lint
Fix lint and format code in task dir
This commit is contained in:
commit
a25df10e20
@ -48,6 +48,7 @@
|
|||||||
- Feature issue #4402 finish router get example. [4416](https://github.com/beego/beego/pull/4416)
|
- Feature issue #4402 finish router get example. [4416](https://github.com/beego/beego/pull/4416)
|
||||||
- Proposal: Add Bind() method for `web.Controller` [4491](https://github.com/beego/beego/issues/4579)
|
- Proposal: Add Bind() method for `web.Controller` [4491](https://github.com/beego/beego/issues/4579)
|
||||||
- Optimize AddAutoPrefix: only register one router in case-insensitive mode. [4582](https://github.com/beego/beego/pull/4582)
|
- Optimize AddAutoPrefix: only register one router in case-insensitive mode. [4582](https://github.com/beego/beego/pull/4582)
|
||||||
|
- Fix lint and format code in task dir [4655](https://github.com/beego/beego/pull/4655)
|
||||||
- Init exceptMethod by using reflection. [4583](https://github.com/beego/beego/pull/4583)
|
- Init exceptMethod by using reflection. [4583](https://github.com/beego/beego/pull/4583)
|
||||||
- Deprecated BeeMap and replace all usage with `sync.map` [4616](https://github.com/beego/beego/pull/4616)
|
- Deprecated BeeMap and replace all usage with `sync.map` [4616](https://github.com/beego/beego/pull/4616)
|
||||||
- Fix lint and format code in core dir [4654](https://github.com/beego/beego/pull/4654)
|
- Fix lint and format code in core dir [4654](https://github.com/beego/beego/pull/4654)
|
||||||
|
|||||||
@ -24,8 +24,7 @@ import (
|
|||||||
"github.com/beego/beego/v2/core/admin"
|
"github.com/beego/beego/v2/core/admin"
|
||||||
)
|
)
|
||||||
|
|
||||||
type listTaskCommand struct {
|
type listTaskCommand struct{}
|
||||||
}
|
|
||||||
|
|
||||||
func (l *listTaskCommand) Execute(params ...interface{}) *admin.Result {
|
func (l *listTaskCommand) Execute(params ...interface{}) *admin.Result {
|
||||||
resultList := make([][]string, 0, len(globalTaskManager.adminTaskList))
|
resultList := make([][]string, 0, len(globalTaskManager.adminTaskList))
|
||||||
@ -45,8 +44,7 @@ func (l *listTaskCommand) Execute(params ...interface{}) *admin.Result {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type runTaskCommand struct {
|
type runTaskCommand struct{}
|
||||||
}
|
|
||||||
|
|
||||||
func (r *runTaskCommand) Execute(params ...interface{}) *admin.Result {
|
func (r *runTaskCommand) Execute(params ...interface{}) *admin.Result {
|
||||||
if len(params) == 0 {
|
if len(params) == 0 {
|
||||||
@ -83,7 +81,6 @@ func (r *runTaskCommand) Execute(params ...interface{}) *admin.Result {
|
|||||||
Error: errors.New(fmt.Sprintf("task with name %s not found", tn)),
|
Error: errors.New(fmt.Sprintf("task with name %s not found", tn)),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func registerCommands() {
|
func registerCommands() {
|
||||||
|
|||||||
@ -137,7 +137,6 @@ type Task struct {
|
|||||||
|
|
||||||
// NewTask add new task with name, time and func
|
// NewTask add new task with name, time and func
|
||||||
func NewTask(tname string, spec string, f TaskFunc, opts ...Option) *Task {
|
func NewTask(tname string, spec string, f TaskFunc, opts ...Option) *Task {
|
||||||
|
|
||||||
task := &Task{
|
task := &Task{
|
||||||
Taskname: tname,
|
Taskname: tname,
|
||||||
DoFunc: f,
|
DoFunc: f,
|
||||||
@ -351,7 +350,6 @@ func (t *Task) parseSpec(spec string) *Schedule {
|
|||||||
|
|
||||||
// Next set schedule to next time
|
// Next set schedule to next time
|
||||||
func (s *Schedule) Next(t time.Time) time.Time {
|
func (s *Schedule) Next(t time.Time) time.Time {
|
||||||
|
|
||||||
// Start at the earliest possible time (the upcoming second).
|
// Start at the earliest possible time (the upcoming second).
|
||||||
t = t.Add(1*time.Second - time.Duration(t.Nanosecond())*time.Nanosecond)
|
t = t.Add(1*time.Second - time.Duration(t.Nanosecond())*time.Nanosecond)
|
||||||
|
|
||||||
@ -548,7 +546,7 @@ func (m *taskManager) markManagerStop() {
|
|||||||
// runNextTasks it runs next task which next run time is equal to effective
|
// runNextTasks it runs next task which next run time is equal to effective
|
||||||
func (m *taskManager) runNextTasks(sortList *MapSorter, effective time.Time) {
|
func (m *taskManager) runNextTasks(sortList *MapSorter, effective time.Time) {
|
||||||
// Run every entry whose next time was this effective time.
|
// Run every entry whose next time was this effective time.
|
||||||
var i = 0
|
i := 0
|
||||||
for _, e := range sortList.Vals {
|
for _, e := range sortList.Vals {
|
||||||
i++
|
i++
|
||||||
if e.GetNext(context.Background()) != effective {
|
if e.GetNext(context.Background()) != effective {
|
||||||
@ -617,7 +615,6 @@ func (m *taskManager) AddTask(taskname string, t Tasker) {
|
|||||||
m.changed <- true
|
m.changed <- true
|
||||||
}()
|
}()
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteTask delete task with name
|
// DeleteTask delete task with name
|
||||||
@ -690,6 +687,7 @@ func (ms *MapSorter) Less(i, j int) bool {
|
|||||||
}
|
}
|
||||||
return ms.Vals[i].GetNext(context.Background()).Before(ms.Vals[j].GetNext(context.Background()))
|
return ms.Vals[i].GetNext(context.Background()).Before(ms.Vals[j].GetNext(context.Background()))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ms *MapSorter) Swap(i, j int) {
|
func (ms *MapSorter) Swap(i, j int) {
|
||||||
ms.Vals[i], ms.Vals[j] = ms.Vals[j], ms.Vals[i]
|
ms.Vals[i], ms.Vals[j] = ms.Vals[j], ms.Vals[i]
|
||||||
ms.Keys[i], ms.Keys[j] = ms.Keys[j], ms.Keys[i]
|
ms.Keys[i], ms.Keys[j] = ms.Keys[j], ms.Keys[i]
|
||||||
@ -708,7 +706,6 @@ func getField(field string, r bounds) uint64 {
|
|||||||
// getRange returns the bits indicated by the given expression:
|
// getRange returns the bits indicated by the given expression:
|
||||||
// number | number "-" number [ "/" number ]
|
// number | number "-" number [ "/" number ]
|
||||||
func getRange(expr string, r bounds) uint64 {
|
func getRange(expr string, r bounds) uint64 {
|
||||||
|
|
||||||
var (
|
var (
|
||||||
start, end, step uint
|
start, end, step uint
|
||||||
rangeAndStep = strings.Split(expr, "/")
|
rangeAndStep = strings.Split(expr, "/")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user