summaryrefslogtreecommitdiff
path: root/plugins/jobs/job
diff options
context:
space:
mode:
authorValery Piashchynski <[email protected]>2021-08-12 13:25:36 +0300
committerValery Piashchynski <[email protected]>2021-08-12 13:25:36 +0300
commitecbfc5c5265a9895f4e371ce4388f64df8714e63 (patch)
treedf0749155487eae6bcdbb2456885131a21916f4d /plugins/jobs/job
parent4169e8374f581ba2213f8cd1833cc6b9b84438e8 (diff)
Remove unneeded options, complete tests for the ephemeral, update proto
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'plugins/jobs/job')
-rw-r--r--plugins/jobs/job/general.go1
-rw-r--r--plugins/jobs/job/job_options.go28
-rw-r--r--plugins/jobs/job/job_options_test.go42
3 files changed, 6 insertions, 65 deletions
diff --git a/plugins/jobs/job/general.go b/plugins/jobs/job/general.go
index 0a75f2e6..390f44b5 100644
--- a/plugins/jobs/job/general.go
+++ b/plugins/jobs/job/general.go
@@ -6,7 +6,6 @@ const (
RRJob string = "rr_job"
RRHeaders string = "rr_headers"
RRPipeline string = "rr_pipeline"
- RRTimeout string = "rr_timeout"
RRDelay string = "rr_delay"
RRPriority string = "rr_priority"
)
diff --git a/plugins/jobs/job/job_options.go b/plugins/jobs/job/job_options.go
index 133ae1a8..b7e4ed36 100644
--- a/plugins/jobs/job/job_options.go
+++ b/plugins/jobs/job/job_options.go
@@ -13,12 +13,6 @@ type Options struct {
// Delay defines time duration to delay execution for. Defaults to none.
Delay int64 `json:"delay,omitempty"`
-
- // RetryDelay defines for how long job should be waiting until next retry. Defaults to none.
- RetryDelay int64 `json:"retryDelay,omitempty"`
-
- // Reserve defines for how broker should wait until treating job are failed. Defaults to 30 min.
- Timeout int64 `json:"timeout,omitempty"`
}
// Merge merges job options.
@@ -27,34 +21,12 @@ func (o *Options) Merge(from *Options) {
o.Pipeline = from.Pipeline
}
- if o.Timeout == 0 {
- o.Timeout = from.Timeout
- }
-
- if o.RetryDelay == 0 {
- o.RetryDelay = from.RetryDelay
- }
-
if o.Delay == 0 {
o.Delay = from.Delay
}
}
-// RetryDuration returns retry delay duration in a form of time.Duration.
-func (o *Options) RetryDuration() time.Duration {
- return time.Second * time.Duration(o.RetryDelay)
-}
-
// DelayDuration returns delay duration in a form of time.Duration.
func (o *Options) DelayDuration() time.Duration {
return time.Second * time.Duration(o.Delay)
}
-
-// TimeoutDuration returns timeout duration in a form of time.Duration.
-func (o *Options) TimeoutDuration() time.Duration {
- if o.Timeout == 0 {
- return 30 * time.Minute
- }
-
- return time.Second * time.Duration(o.Timeout)
-}
diff --git a/plugins/jobs/job/job_options_test.go b/plugins/jobs/job/job_options_test.go
index 061e83cc..a47151a3 100644
--- a/plugins/jobs/job/job_options_test.go
+++ b/plugins/jobs/job/job_options_test.go
@@ -7,16 +7,6 @@ import (
"github.com/stretchr/testify/assert"
)
-func TestOptions_RetryDuration(t *testing.T) {
- opts := &Options{RetryDelay: 0}
- assert.Equal(t, time.Duration(0), opts.RetryDuration())
-}
-
-func TestOptions_RetryDuration2(t *testing.T) {
- opts := &Options{RetryDelay: 1}
- assert.Equal(t, time.Second, opts.RetryDuration())
-}
-
func TestOptions_DelayDuration(t *testing.T) {
opts := &Options{Delay: 0}
assert.Equal(t, time.Duration(0), opts.DelayDuration())
@@ -27,49 +17,29 @@ func TestOptions_DelayDuration2(t *testing.T) {
assert.Equal(t, time.Second, opts.DelayDuration())
}
-func TestOptions_TimeoutDuration(t *testing.T) {
- opts := &Options{Timeout: 0}
- assert.Equal(t, time.Minute*30, opts.TimeoutDuration())
-}
-
-func TestOptions_TimeoutDuration2(t *testing.T) {
- opts := &Options{Timeout: 1}
- assert.Equal(t, time.Second, opts.TimeoutDuration())
-}
-
func TestOptions_Merge(t *testing.T) {
opts := &Options{}
opts.Merge(&Options{
- Pipeline: "pipeline",
- Delay: 2,
- Timeout: 1,
- RetryDelay: 1,
+ Pipeline: "pipeline",
+ Delay: 2,
})
assert.Equal(t, "pipeline", opts.Pipeline)
assert.Equal(t, int64(2), opts.Delay)
- assert.Equal(t, int64(1), opts.Timeout)
- assert.Equal(t, int64(1), opts.RetryDelay)
}
func TestOptions_MergeKeepOriginal(t *testing.T) {
opts := &Options{
- Pipeline: "default",
- Delay: 10,
- Timeout: 10,
- RetryDelay: 10,
+ Pipeline: "default",
+ Delay: 10,
}
opts.Merge(&Options{
- Pipeline: "pipeline",
- Delay: 2,
- Timeout: 1,
- RetryDelay: 1,
+ Pipeline: "pipeline",
+ Delay: 2,
})
assert.Equal(t, "default", opts.Pipeline)
assert.Equal(t, int64(10), opts.Delay)
- assert.Equal(t, int64(10), opts.Timeout)
- assert.Equal(t, int64(10), opts.RetryDelay)
}