Skip to content

Commit

Permalink
#### Version 0.9.10
Browse files Browse the repository at this point in the history
* feature: add LICENSE file for issue #10, thanks to @katsusan.
* feature: add PackageVersion use to return packageVersion info
* 2022-04-17 08:00 at ShangHai
  • Loading branch information
devfeel committed Apr 17, 2022
1 parent cbcb4b0 commit 6e00b3d
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 30 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 devfeel [email protected]

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
24 changes: 24 additions & 0 deletions constant.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package task

const (
packageVersion = "0.9.10"
)

const (
TaskState_Init = "0"
TaskState_Run = "1"
TaskState_Stop = "2"

TaskType_Loop = "loop"
TaskType_Cron = "cron"
TaskType_Queue = "queue"

ConfigType_Xml = "xml"
ConfigType_Json = "json"
ConfigType_Yaml = "yaml"
)

const (
defaultCounterTaskName = "TASK_DEFAULT_COUNTERINFO"
fullTimeLayout = "2006-01-02 15:04:05.9999"
)
4 changes: 2 additions & 2 deletions example/queuetask/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ func main() {
if exists {
err = t.RunOnce()
if err != nil {
fmt.Println(t.Context(), "RunOnce error =>", err)
fmt.Println(t.GetConfig(), "RunOnce error =>", err)
} else {
fmt.Println(t.Context(), "RunOnce success")
fmt.Println(t.GetConfig(), "RunOnce success")
}
}

Expand Down
37 changes: 10 additions & 27 deletions tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,6 @@ import (
"sync"
)

const (
TaskState_Init = "0"
TaskState_Run = "1"
TaskState_Stop = "2"
)

const (
TaskType_Loop = "loop"
TaskType_Cron = "cron"
TaskType_Queue = "queue"
)

const (
ConfigType_Xml = "xml"
ConfigType_Json = "json"
ConfigType_Yaml = "yaml"
)

const (
defaultCounterTaskName = "TASK_DEFAULT_COUNTERINFO"
fullTimeLayout = "2006-01-02 15:04:05.9999"
)

var ErrNotSupportTaskType = errors.New("not support task type")

type (
Expand All @@ -51,7 +28,7 @@ type (

ExceptionHandleFunc func(*TaskContext, error)

//task 容器
// TaskService task 容器
TaskService struct {
Config *AppConfig
taskMap map[string]Task
Expand Down Expand Up @@ -86,6 +63,7 @@ func StartNewService() *TaskService {
return &TaskContext{}
},
}
service.Logger().Debug("StartTaskService PackageVersion[" + PackageVersion() + "]")
return service
}

Expand All @@ -105,7 +83,7 @@ func (service *TaskService) SetExceptionHandler(handler ExceptionHandleFunc) {
service.ExceptionHandler = handler
}

// SetOnBeforHandler set handler which exec before task run
// SetOnBeforeHandler set handler which exec before task run
func (service *TaskService) SetOnBeforeHandler(handler TaskHandle) {
service.OnBeforeHandler = handler
}
Expand Down Expand Up @@ -324,7 +302,7 @@ func (service *TaskService) PrintAllTasks() string {
return body
}

// PrintTaskCountData print all task counter data
// PrintAllTaskCounterInfo print all task counter data
func (service *TaskService) PrintAllTaskCounterInfo() string {
body := ""
for _, v := range service.taskMap {
Expand All @@ -334,7 +312,7 @@ func (service *TaskService) PrintAllTaskCounterInfo() string {
return body
}

// GetAllTaskCounterInfo return all show count info
// GetAllTaskCountInfo return all show count info
func (service *TaskService) GetAllTaskCountInfo() []ShowCountInfo {
showInfos := []ShowCountInfo{}
for _, t := range service.GetAllTasks() {
Expand Down Expand Up @@ -405,3 +383,8 @@ func ValidateTaskType(taskType string) bool {
}
return true
}

// PackageVersion return packageVersion info
func PackageVersion() string {
return packageVersion
}
7 changes: 6 additions & 1 deletion version.MD
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
## devfeel/dottask

#### Version 0.9.10
* feature: add LICENSE file for issue #10, thanks to @katsusan.
* feature: add PackageVersion use to return packageVersion info
* 2022-04-17 08:00 at ShangHai

#### Version 0.9.9
* feature: TaskContext增加TimeoutContext与TimeoutCancel属性,用于超时控制,应用可根据需要从TaskContext获取
* feature: TaskInfo增加SetTimeout,用于设置超时时间,单位为秒
Expand Down Expand Up @@ -89,7 +94,7 @@
#### Version 0.8.3
* New feature: add TaskService.GetAllTasks() used to return all task info which type is map[string]Task
* Example:
```golang
``` go
for _, t := range service.GetAllTasks(){
fmt.Println("GetAllTasks", t.TaskID(), t.GetConfig().TaskType, t.GetConfig().IsRun, t.GetConfig().Interval, t.GetConfig().Express)
}
Expand Down

0 comments on commit 6e00b3d

Please sign in to comment.