feta/archiver.go

38 lines
644 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
"fmt"
"github.com/rs/zerolog/log"
"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-24 12:41:05 +00:00
func (a *Archiver) Run() int {
t := time.Now()
a.startup = &t
a.locator = NewInstanceLocator()
log.Info().Msg(fmt.Sprintf("in %#v.Run()", a))
a.locator.Locate()
return 0
2019-10-24 12:14:36 +00:00
}