feta/archiver.go

40 lines
612 B
Go
Raw Normal View History

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()
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
}