2019-10-24 12:14:36 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2019-10-24 12:41:05 +00:00
|
|
|
"context"
|
2019-10-24 12:14:36 +00:00
|
|
|
"time"
|
|
|
|
//"github.com/bitly/go-simplejson"
|
|
|
|
)
|
|
|
|
|
|
|
|
type InstanceHostName string
|
|
|
|
|
|
|
|
type Archiver struct {
|
|
|
|
locator *InstanceLocator
|
|
|
|
instances map[InstanceHostName]*Instance
|
|
|
|
startup *time.Time
|
2019-10-24 12:41:05 +00:00
|
|
|
ctx context.Context
|
2019-10-24 12:14:36 +00:00
|
|
|
}
|
|
|
|
|
2019-10-24 12:41:05 +00:00
|
|
|
func NewArchiver(ctx context.Context) *Archiver {
|
2019-10-24 12:14:36 +00:00
|
|
|
a := new(Archiver)
|
2019-10-24 12:41:05 +00:00
|
|
|
a.ctx = ctx
|
2019-10-24 12:14:36 +00:00
|
|
|
return a
|
|
|
|
}
|
|
|
|
|
2019-10-24 12:41:05 +00:00
|
|
|
func (a *Archiver) Uptime() time.Duration {
|
|
|
|
return time.Since(*a.startup)
|
|
|
|
}
|
2019-10-24 12:14:36 +00:00
|
|
|
|
2019-10-29 18:48:53 +00:00
|
|
|
func (a *Archiver) RunForever() int {
|
2019-10-24 12:41:05 +00:00
|
|
|
t := time.Now()
|
|
|
|
a.startup = &t
|
|
|
|
a.locator = NewInstanceLocator()
|
2019-10-24 15:11:07 +00:00
|
|
|
go a.locator.Locate()
|
|
|
|
|
|
|
|
for {
|
|
|
|
time.Sleep(1 * time.Second)
|
|
|
|
}
|
|
|
|
|
2019-10-24 12:41:05 +00:00
|
|
|
return 0
|
2019-10-24 12:14:36 +00:00
|
|
|
}
|