From 515b618aba19a6aab84e60552ae3a38da4ff8d06 Mon Sep 17 00:00:00 2001 From: geek Date: Wed, 26 Apr 2017 15:46:04 +0900 Subject: [PATCH] shared project --- queue.go | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/queue.go b/queue.go index 3fa7ee6..5a8a656 100644 --- a/queue.go +++ b/queue.go @@ -2,28 +2,27 @@ package queue import ( "container/heap" - "time" - "loafle.com/overflow/agent_api/observer" "github.com/prometheus/common/log" + "loafle.com/overflow/agent_api/observer" + "time" ) type EventType int const ( - - DATA_TYPE EventType = 0 + DATA_TYPE EventType = 0 EVENT_TYPE EventType = 1 - ) + type item struct { - value interface{} + value interface{} priority int } type LoafleQueue struct { - items []*item + items []*item queueType string - interval time.Duration + interval time.Duration eventChanel chan interface{} } @@ -68,7 +67,7 @@ func (lq *LoafleQueue) Pop() interface{} { } func (lq LoafleQueue) newItem(value interface{}) *item { return &item{ - value:value, + value: value, } } @@ -86,22 +85,22 @@ func (lq *LoafleQueue) Close() { } func NewLoafleQueue(eventType EventType, interval time.Duration) *LoafleQueue { items := make([]*item, 0) - event := make(chan interface{},0) + event := make(chan interface{}, 0) var tempType string if eventType == DATA_TYPE { tempType = "DATA_TYPE" - }else if eventType == EVENT_TYPE{ + } else if eventType == EVENT_TYPE { tempType = "EVENT_TYPE" - }else { + } else { log.Fatal("Event Type Error") } lq := &LoafleQueue{ - items:items, - queueType:tempType, - interval:interval, - eventChanel:event, + items: items, + queueType: tempType, + interval: interval, + eventChanel: event, } observer.Add(lq.queueType, lq.eventChanel)