|
|
|
@ -11,16 +11,17 @@ import ( |
|
|
|
|
"github.com/spf13/viper" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
//import "github.com/gin-gonic/gin"
|
|
|
|
|
|
|
|
|
|
// LogReportInterval defines how long between logging internal
|
|
|
|
|
// stats/reporting for user supervision
|
|
|
|
|
var LogReportInterval = time.Second * 10 |
|
|
|
|
// conform for storing toots
|
|
|
|
|
type DatabaseStorage interface { |
|
|
|
|
ListInstances() ([]*instance.Instance, error) |
|
|
|
|
StoreInstances([]*instance.Instance) error |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// InstanceManager is the main data structure for the goroutine that manages
|
|
|
|
|
// the list of all known instances, fed by the locator
|
|
|
|
|
type InstanceManager struct { |
|
|
|
|
mu sync.Mutex |
|
|
|
|
db DatabaseStorage |
|
|
|
|
instances map[instance.Hostname]*instance.Instance |
|
|
|
|
newInstanceNotifications chan instance.Hostname |
|
|
|
|
tootDestination chan *toot.Toot |
|
|
|
@ -89,7 +90,7 @@ func (im *InstanceManager) Manage() { |
|
|
|
|
log.Info().Msg("InstanceManager tick") |
|
|
|
|
im.managerLoop() |
|
|
|
|
time.Sleep(1 * time.Second) |
|
|
|
|
if time.Now().After(x.Add(LogReportInterval)) { |
|
|
|
|
if time.Now().After(x.Add(viper.GetDuration("LogReportInterval"))) { |
|
|
|
|
x = time.Now() |
|
|
|
|
im.logInstanceReport() |
|
|
|
|
} |
|
|
|
|