diff options
Diffstat (limited to 'plugins/jobs/job')
-rw-r--r-- | plugins/jobs/job/job.go | 51 | ||||
-rw-r--r-- | plugins/jobs/job/job_test.go | 18 |
2 files changed, 0 insertions, 69 deletions
diff --git a/plugins/jobs/job/job.go b/plugins/jobs/job/job.go deleted file mode 100644 index adab2a0a..00000000 --- a/plugins/jobs/job/job.go +++ /dev/null @@ -1,51 +0,0 @@ -package job - -import ( - "time" -) - -// constant keys to pack/unpack messages from different drivers -const ( - RRID string = "rr_id" - RRJob string = "rr_job" - RRHeaders string = "rr_headers" - RRPipeline string = "rr_pipeline" - RRDelay string = "rr_delay" - RRPriority string = "rr_priority" -) - -// Job carries information about single job. -type Job struct { - // Job contains name of job broker (usually PHP class). - Job string `json:"job"` - - // Ident is unique identifier of the job, should be provided from outside - Ident string `json:"id"` - - // Payload is string data (usually JSON) passed to Job broker. - Payload string `json:"payload"` - - // Headers with key-value pairs - Headers map[string][]string `json:"headers"` - - // Options contains set of PipelineOptions specific to job execution. Can be empty. - Options *Options `json:"options,omitempty"` -} - -// Options carry information about how to handle given job. -type Options struct { - // Priority is job priority, default - 10 - // pointer to distinguish 0 as a priority and nil as priority not set - Priority int64 `json:"priority"` - - // Pipeline manually specified pipeline. - Pipeline string `json:"pipeline,omitempty"` - - // Delay defines time duration to delay execution for. Defaults to none. - Delay int64 `json:"delay,omitempty"` -} - -// DelayDuration returns delay duration in a form of time.Duration. -func (o *Options) DelayDuration() time.Duration { - return time.Second * time.Duration(o.Delay) -} diff --git a/plugins/jobs/job/job_test.go b/plugins/jobs/job/job_test.go deleted file mode 100644 index 4a95e27d..00000000 --- a/plugins/jobs/job/job_test.go +++ /dev/null @@ -1,18 +0,0 @@ -package job - -import ( - "testing" - "time" - - "github.com/stretchr/testify/assert" -) - -func TestOptions_DelayDuration(t *testing.T) { - opts := &Options{Delay: 0} - assert.Equal(t, time.Duration(0), opts.DelayDuration()) -} - -func TestOptions_DelayDuration2(t *testing.T) { - opts := &Options{Delay: 1} - assert.Equal(t, time.Second, opts.DelayDuration()) -} |