Пример #1
0
func (p *BaseComponent) Resume() {
	p.runtimeLocker.Lock()
	defer p.runtimeLocker.Unlock()

	if p.status == STATUS_RUNNING {
		return
	} else if p.status == STATUS_PAUSED {
		p.startReceivers()
		p.status = STATUS_RUNNING
	} else {
		logs.Warn("[base component] pause or resume at error status")
		return
	}
}
Пример #2
0
func (p *BaseComponent) Stop() {
	p.runtimeLocker.Lock()
	defer p.runtimeLocker.Unlock()

	if p.status != STATUS_RUNNING && p.status != STATUS_PAUSED {
		logs.Warn("[base component] stop at error status, current status: ", p.status)
		return
	}

	p.status = STATUS_STOPPING
	EventCenter.PushEvent(EVENT_BASE_COMPONENT_STOPPING, p.name, p.inboxMessage, p.inboxError)

	p.stopReceivers()

	for p.inboxMessage != 0 || p.inboxError != 0 {
		time.Sleep(time.Second)
		EventCenter.PushEvent(EVENT_BASE_COMPONENT_STOPPING, p.name, p.inboxMessage, p.inboxError)
	}

	p.status = STATUS_STOPPED
	EventCenter.PushEvent(EVENT_BASE_COMPONENT_STOPPED, p.name)
}