// Create a pipeline from a given script. // tick:ignore func CreatePipeline(script string, sourceEdge EdgeType, scope *tick.Scope, deadman DeadmanService) (*Pipeline, error) { p := &Pipeline{ deadman: deadman, } var src Node switch sourceEdge { case StreamEdge: src = newSourceStreamNode() scope.Set("stream", src) case BatchEdge: src = newSourceBatchNode() scope.Set("batch", src) default: return nil, fmt.Errorf("source edge type must be either Stream or Batch not %s", sourceEdge) } p.addSource(src) err := tick.Evaluate(script, scope) if err != nil { return nil, err } if sourceEdge == StreamEdge && deadman.Global() { src.(*SourceStreamNode).Deadman(deadman.Threshold(), deadman.Interval()) } return p, nil }
// Create a pipeline from a given script. // tick:ignore func CreatePipeline(script string, sourceEdge EdgeType, scope *tick.Scope) (*Pipeline, error) { var src Node switch sourceEdge { case StreamEdge: src = newStreamNode() scope.Set("stream", src) case BatchEdge: src = newSourceBatchNode() scope.Set("batch", src) default: return nil, fmt.Errorf("source edge type must be either Stream or Batch not %s", sourceEdge) } err := tick.Evaluate(script, scope) if err != nil { return nil, err } p := &Pipeline{Source: src} p.Walk(p.setID) return p, nil }