diff options
author | Valery Piashchynski <[email protected]> | 2021-09-16 21:46:50 +0300 |
---|---|---|
committer | GitHub <[email protected]> | 2021-09-16 21:46:50 +0300 |
commit | 3581b45f237a3f7aa29591ceb2bf6f4a4642a2f5 (patch) | |
tree | e723b19ec1ac16b7ccc7b3c2da69d4a416d63d81 /plugins/jobs/pipeline | |
parent | 337d292dd2d6ff0a555098b1970d8194d8df8bc2 (diff) | |
parent | 823d831b57b75f70c7c3bbbee355f2016633bb3b (diff) |
[#803]: feat(plugins): move plugins to a separate repositoryv2.5.0-alpha.2
[#803]: feat(plugins): move plugins to a separate repository
Diffstat (limited to 'plugins/jobs/pipeline')
-rw-r--r-- | plugins/jobs/pipeline/pipeline.go | 98 | ||||
-rw-r--r-- | plugins/jobs/pipeline/pipeline_test.go | 21 |
2 files changed, 0 insertions, 119 deletions
diff --git a/plugins/jobs/pipeline/pipeline.go b/plugins/jobs/pipeline/pipeline.go deleted file mode 100644 index 8a8c1462..00000000 --- a/plugins/jobs/pipeline/pipeline.go +++ /dev/null @@ -1,98 +0,0 @@ -package pipeline - -import ( - json "github.com/json-iterator/go" - "github.com/spiral/roadrunner/v2/utils" -) - -// Pipeline defines pipeline options. -type Pipeline map[string]interface{} - -const ( - priority string = "priority" - driver string = "driver" - name string = "name" -) - -// With pipeline value -func (p *Pipeline) With(name string, value interface{}) { - (*p)[name] = value -} - -// Name returns pipeline name. -func (p Pipeline) Name() string { - return p.String(name, "") -} - -// Driver associated with the pipeline. -func (p Pipeline) Driver() string { - return p.String(driver, "") -} - -// Has checks if value presented in pipeline. -func (p Pipeline) Has(name string) bool { - if _, ok := p[name]; ok { - return true - } - - return false -} - -// String must return option value as string or return default value. -func (p Pipeline) String(name string, d string) string { - if value, ok := p[name]; ok { - if str, ok := value.(string); ok { - return str - } - } - - return d -} - -// Int must return option value as string or return default value. -func (p Pipeline) Int(name string, d int) int { - if value, ok := p[name]; ok { - if i, ok := value.(int); ok { - return i - } - } - - return d -} - -// Bool must return option value as bool or return default value. -func (p Pipeline) Bool(name string, d bool) bool { - if value, ok := p[name]; ok { - if i, ok := value.(bool); ok { - return i - } - } - - return d -} - -// Map must return nested map value or empty config. -// Here might be sqs attributes or tags for example -func (p Pipeline) Map(name string, out map[string]string) error { - if value, ok := p[name]; ok { - if m, ok := value.(string); ok { - err := json.Unmarshal(utils.AsBytes(m), &out) - if err != nil { - return err - } - } - } - - return nil -} - -// Priority returns default pipeline priority -func (p Pipeline) Priority() int64 { - if value, ok := p[priority]; ok { - if v, ok := value.(int64); ok { - return v - } - } - - return 10 -} diff --git a/plugins/jobs/pipeline/pipeline_test.go b/plugins/jobs/pipeline/pipeline_test.go deleted file mode 100644 index 4482c70d..00000000 --- a/plugins/jobs/pipeline/pipeline_test.go +++ /dev/null @@ -1,21 +0,0 @@ -package pipeline - -import ( - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestPipeline_String(t *testing.T) { - pipe := Pipeline{"value": "value"} - - assert.Equal(t, "value", pipe.String("value", "")) - assert.Equal(t, "value", pipe.String("other", "value")) -} - -func TestPipeline_Has(t *testing.T) { - pipe := Pipeline{"options": map[string]interface{}{"ttl": 10}} - - assert.Equal(t, true, pipe.Has("options")) - assert.Equal(t, false, pipe.Has("other")) -} |