當前位置: 首頁>>代碼示例>>Golang>>正文


Golang event.Event類代碼示例

本文整理匯總了Golang中github.com/eliothedeman/bangarang/event.Event的典型用法代碼示例。如果您正苦於以下問題:Golang Event類的具體用法?Golang Event怎麽用?Golang Event使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Event類的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: CheckNotMatch

func (p *Policy) CheckNotMatch(e *event.Event) bool {
	for k, m := range p.r_not_match {
		if m.MatchString(e.Get(k)) {
			return false
		}
	}
	return true
}
開發者ID:postfix,項目名稱:bangarang,代碼行數:8,代碼來源:policy.go

示例2: CheckMatch

// check if any of p's matches are satisfied by the event
func (p *Policy) CheckMatch(e *event.Event) bool {
	for k, m := range p.r_match {
		// if the element does not match the regex pattern, the event does not fully match
		if !m.MatchString(e.Get(k)) {
			return false
		}
	}
	return true
}
開發者ID:postfix,項目名稱:bangarang,代碼行數:10,代碼來源:policy.go

示例3: DoOnTracker

func (c *Condition) DoOnTracker(e *event.Event, dot func(*eventTracker)) {
	// c.Lock()
	et, ok := c.eventTrackers[e.IndexName()]
	if !ok {
		et = c.newTracker()
		c.eventTrackers[e.IndexName()] = et
	}
	dot(et)
	// c.Unlock()
}
開發者ID:nolenroyalty,項目名稱:bangarang,代碼行數:10,代碼來源:condition.go

示例4: trackEvent

func (t *Tracker) trackEvent(e *event.Event) {

	// don't track internal events
	if len(e.Get(INTERNAL_TAG_NAME)) != 0 {
		return
	}
	t.total.inc()
	t.updateCounts(e)
	t.updateTimes(e)

}
開發者ID:nolenroyalty,項目名稱:bangarang,代碼行數:11,代碼來源:tracker.go

示例5: getTracker

func (c *Condition) getTracker(e *event.Event) *eventTracker {
	if c.eventTrackers == nil {
		c.eventTrackers = make(map[string]*eventTracker)
	}
	et, ok := c.eventTrackers[e.IndexName()]
	if !ok {
		et = c.newTracker()
		c.eventTrackers[e.IndexName()] = et
	}

	return et
}
開發者ID:nolenroyalty,項目名稱:bangarang,代碼行數:12,代碼來源:condition.go

示例6: processEvent

// Run the given event though the pipeline
func (p *Pipeline) processEvent(e *event.Event) {

	// update to current state
	e.SetState(event.StatePipeline)

	// track stas for this event
	p.tracker.TrackEvent(e)

	// process this event on every policy
	var pol *escalation.Policy
	for _, pol = range p.policies {
		pol.PassEvent(e)
	}
}
開發者ID:nolenroyalty,項目名稱:bangarang,代碼行數:15,代碼來源:pipeline.go

示例7: Process

// Run the given event though the pipeline
func (p *Pipeline) Process(e *event.Event) {
	if p.globalPolicy != nil {
		if !p.globalPolicy.CheckMatch(e) || !p.globalPolicy.CheckNotMatch(e) {
			return
		}
	}

	// track stas for this event
	p.tracker.TrackEvent(e)

	// process this event on every policy
	var pol *alarm.Policy
	for _, pol = range p.policies {
		e.WaitInc()
		pol.Process(e, func(in *event.Incident) {
			p.ProcessIncident(in)
		})
	}

}
開發者ID:postfix,項目名稱:bangarang,代碼行數:21,代碼來源:pipeline.go

示例8: start

// start the policy listening for events
func (p *Policy) start() {
	go func() {
		var e *event.Event
		for {
			select {
			case toResolve := <-p.resolve:
				var c *Condition

				// fetch the condition that created this incident
				if toResolve.Status == event.CRITICAL {
					c = p.Crit
				} else if toResolve.Status == event.WARNING {
					c = p.Warn
				}

				if c != nil {
					t := c.getTracker(&toResolve.Event)
					t.refresh()
				}
			case <-p.stop:
				logrus.Info("Stopping policy", p.Name)

				// cleanup the policy. Sometimes they hangaround.
				p.clean()

				// stop this policy from being stopped again
				p.stop = nil

				// catch resolve's that could be sent to this policy
				res := p.resolve
				p.resolve = nil

				go func() {
					for {
						select {
						case <-res:
							logrus.Info("Attempted to resolve an incident on a policy that no longer exists")

						case <-time.After(1 * time.Minute):
							return
						}
					}

				}()
				return
			case e = <-p.in:
				e.SetState(event.StatePolicy)

				// process the event if it matches the policy

				if p.Matches(e) {

					// check critical
					if shouldAlert, status := p.ActionCrit(e); shouldAlert {
						incident := event.NewIncident(p.Name, status, e)
						incident.SetResolve(p.resolve)

						// send send it off to the next hop
						p.next.PassIncident(incident)

						// check warning
					} else if shouldAlert, status := p.ActionWarn(e); shouldAlert {
						incident := event.NewIncident(p.Name, status, e)
						incident.SetResolve(p.resolve)

						// send it off to the next hop
						p.next.PassIncident(incident)
					} else {
						e.SetState(event.StateComplete)
					}
				}

			}
		}
	}()
}
開發者ID:nolenroyalty,項目名稱:bangarang,代碼行數:77,代碼來源:policy.go

示例9: genIndexName

// generate an index name by using group-by statements
func (g grouper) genIndexName(e *event.Event) string {
	return e.IndexName()

}
開發者ID:postfix,項目名稱:bangarang,代碼行數:5,代碼來源:condition.go


注:本文中的github.com/eliothedeman/bangarang/event.Event類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。