encodable a good
Former-commit-id: a0afebd82dfd256ec70c02c607af2a9b3b4b046f
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
||||
|
||||
type Item struct {
|
||||
Key string
|
||||
*config.Encodable
|
||||
}
|
||||
|
||||
const nsLast = "nsLast"
|
||||
@@ -22,7 +23,8 @@ var forever = time.Duration(time.Hour * 99999)
|
||||
|
||||
func NewItem(key string, interval time.Duration) (*Item, error) {
|
||||
i := &Item{
|
||||
Key: key,
|
||||
Key: key,
|
||||
Encodable: &config.Encodable{},
|
||||
}
|
||||
|
||||
if err := i.setInterval(interval); err != nil {
|
||||
|
||||
@@ -9,6 +9,7 @@ type Monitor struct {
|
||||
queue *Queue
|
||||
Incoming chan *Item
|
||||
Outgoing chan *Item
|
||||
config.Stoppable
|
||||
}
|
||||
|
||||
func New() *Monitor {
|
||||
@@ -22,7 +23,7 @@ func New() *Monitor {
|
||||
func (m *Monitor) Run() error {
|
||||
for {
|
||||
select {
|
||||
case <-m.stopped():
|
||||
case <-m.Stopped():
|
||||
return nil
|
||||
case i := <-m.enqueued():
|
||||
m.enqueue(i)
|
||||
@@ -33,10 +34,6 @@ func (m *Monitor) Run() error {
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Monitor) stopped() <-chan struct{} {
|
||||
return config.Values().Ctx.Done()
|
||||
}
|
||||
|
||||
func (m *Monitor) enqueued() chan *Item {
|
||||
return m.Incoming
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user