// NewPipeline returns a pipeline that is empty of any configuation but will still pass events though func NewPipeline() *Pipeline { p := &Pipeline{ in: make(chan *event.Event, 10), policies: make(map[string]*escalation.Policy), incidentInput: make(chan *event.Incident), unpauseChan: make(chan struct{}), pauseChan: make(chan struct{}), tracker: NewTracker(), keepAliveCheckTime: DefaultKeepAliveCheckTime, escalations: map[string]*escalation.EscalationPolicy{}, index: event.NewIndex(), } return p }
// NewPipeline func NewPipeline(conf *config.AppConfig) *Pipeline { p := &Pipeline{ encodingPool: event.NewEncodingPool(event.EncoderFactories[conf.Encoding], event.DecoderFactories[conf.Encoding], runtime.NumCPU()), keepAliveAge: conf.KeepAliveAge, keepAliveCheckTime: 10 * time.Second, in: make(chan *event.Event), unpauseChan: make(chan struct{}), pauseChan: make(chan struct{}), tracker: NewTracker(), escalations: &alarm.Collection{}, index: event.NewIndex(), } p.Start() p.Refresh(conf) logrus.Debug("Starting expiration checker") go p.checkExpired() return p }
func testPipeline(p map[string]*alarm.Policy) (*Pipeline, *test.TestAlert) { tests_ran += 1 ta := test.NewTest().(*test.TestAlert) pipe := &Pipeline{ policies: p, index: event.NewIndex(), pauseChan: make(chan struct{}), unpauseChan: make(chan struct{}), encodingPool: event.NewEncodingPool(event.EncoderFactories["json"], event.DecoderFactories["json"], runtime.NumCPU()), escalations: &alarm.Collection{ Coll: map[string][]alarm.Alarm{ "test": []alarm.Alarm{ta}, }, }, tracker: NewTracker(), in: make(chan *event.Event), } go pipe.tracker.Start() pipe.Start() return pipe, ta }