소스 검색

config items of timeout

zyx 5 년 전
부모
커밋
e8c7ff3d7f
2개의 변경된 파일7개의 추가작업 그리고 0개의 파일을 삭제
  1. 2 0
      worker/config.go
  2. 5 0
      worker/config_test.go

+ 2 - 0
worker/config.go

@@ -53,6 +53,7 @@ type globalConfig struct {
 	Concurrent int    `toml:"concurrent"`
 	Interval   int    `toml:"interval"`
 	Retry      int    `toml:"retry"`
+	Timeout    int    `toml:"timeout"`
 
 	ExecOnSuccess []string `toml:"exec_on_success"`
 	ExecOnFailure []string `toml:"exec_on_failure"`
@@ -118,6 +119,7 @@ type mirrorConfig struct {
 	Upstream     string            `toml:"upstream"`
 	Interval     int               `toml:"interval"`
 	Retry        int               `toml:"retry"`
+	Timeout      int               `toml:"timeout"`
 	MirrorDir    string            `toml:"mirror_dir"`
 	MirrorSubDir string            `toml:"mirror_subdir"`
 	LogDir       string            `toml:"log_dir"`

+ 5 - 0
worker/config_test.go

@@ -19,6 +19,7 @@ mirror_dir = "/data/mirrors"
 concurrent = 10
 interval = 240
 retry = 3
+timeout = 86400
 
 [manager]
 api_base = "https://127.0.0.1:5000"
@@ -37,6 +38,7 @@ provider = "command"
 upstream = "https://aosp.google.com/"
 interval = 720
 retry = 2
+timeout = 3600
 mirror_dir = "/data/git/AOSP"
 exec_on_success = [
 	"bash -c 'echo ${TUNASYNC_JOB_EXIT_STATUS} > ${TUNASYNC_WORKING_DIR}/exit_status'"
@@ -119,6 +121,7 @@ use_ipv6 = true
 		So(cfg.Global.Name, ShouldEqual, "test_worker")
 		So(cfg.Global.Interval, ShouldEqual, 240)
 		So(cfg.Global.Retry, ShouldEqual, 3)
+		So(cfg.Global.Timeout, ShouldEqual, 86400)
 		So(cfg.Global.MirrorDir, ShouldEqual, "/data/mirrors")
 
 		So(cfg.Manager.APIBase, ShouldEqual, "https://127.0.0.1:5000")
@@ -130,12 +133,14 @@ use_ipv6 = true
 		So(m.Provider, ShouldEqual, provCommand)
 		So(m.Interval, ShouldEqual, 720)
 		So(m.Retry, ShouldEqual, 2)
+		So(m.Timeout, ShouldEqual, 3600)
 		So(m.Env["REPO"], ShouldEqual, "/usr/local/bin/aosp-repo")
 
 		m = cfg.Mirrors[1]
 		So(m.Name, ShouldEqual, "debian")
 		So(m.MirrorDir, ShouldEqual, "")
 		So(m.Provider, ShouldEqual, provTwoStageRsync)
+		So(m.Timeout, ShouldEqual, 86400)
 
 		m = cfg.Mirrors[2]
 		So(m.Name, ShouldEqual, "fedora")