Skip to content

Commit 29b4882

Browse files
committed
add timeout on global & task config
1 parent 2cc6815 commit 29b4882

3 files changed

Lines changed: 10 additions & 7 deletions

File tree

config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ type (
1616
Global struct {
1717
LogPath string `xml:"logpath,attr" yaml:"logpath"`
1818
IsRun bool `xml:"isrun,attr" yaml:"isrun"`
19+
Timeout int64 `xml:"timeout,attr" yaml:"timeout"` //全局超时配置,单位为毫秒
1920
} `xml:"global" yaml:"global"`
2021

2122
Tasks []struct {
@@ -28,6 +29,7 @@ type (
2829
QueueSize int64 `xml:"queuesize,attr" yaml:"queuesize"` //queue类型下,queue初始长度
2930
HandlerName string `xml:"handlername,attr" yaml:"handlername"` //Task对应的HandlerName,需使用RegisterHandler进行统一注册
3031
HandlerData string `xml:"handlerdata,attr" yaml:"handlerdata"` //Task对应的自定义数据,可在配置源中设置
32+
Timeout int64 `xml:"timeout,attr" yaml:"timeout"` //全局超时配置,单位为毫秒
3133
} `xml:"tasks>task" yaml:"tasks"`
3234
}
3335

example/loadfromconfig/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ func main() {
3333

3434
//step 3: load config file
3535
service.LoadFileConfig("c:/gotmp/dottask/task.conf")
36+
fmt.Println(*service.Config)
3637

3738
fmt.Println(time.Now().String(), " => Begin Task")
3839
//step 4: start all task

example/loadfromconfig/task.conf

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<config>
3-
<global isrun="true" logpath="d:/"/>
4-
<tasks>
5-
<task taskid="Loop_Config "type="loop" isrun="true" duetime="1000" interval="1000" handlername="Loop_Config"></task>
6-
<task taskid="Job_Config" type="cron" isrun="true" express="0 */5 * * * *" handlername="Job_Config"></task>
7-
</tasks>
8-
</config>
2+
<config>
3+
<global isrun="true" logpath="d:/" timeout="10000"/>
4+
<tasks>
5+
<task taskid="Loop_Config "type="loop" isrun="true" duetime="1000" interval="1000" handlername="Loop_Config"></task>
6+
<task taskid="Job_Config" type="cron" isrun="true" express="0 */5 * * * *" handlername="Job_Config"></task>
7+
</tasks>
8+
</config>

0 commit comments

Comments
 (0)