7999d24f81
this commit updates our monkit dependency to the v3 version where it outputs in an influx style. this makes discovery much easier as many tools are built to look at it this way. graphite and rothko will suffer some due to no longer being a tree based on dots. hopefully time will exist to update rothko to index based on the new metric format. it adds an influx output for the statreceiver so that we can write to influxdb v1 or v2 directly. Change-Id: Iae9f9494a6d29cfbd1f932a5e71a891b490415ff
67 lines
1.5 KiB
Go
67 lines
1.5 KiB
Go
// Copyright (C) 2019 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package contact
|
|
|
|
import (
|
|
"sync"
|
|
"time"
|
|
|
|
"github.com/spacemonkeygo/monkit/v3"
|
|
"github.com/zeebo/errs"
|
|
"go.uber.org/zap"
|
|
|
|
"storj.io/common/pb"
|
|
"storj.io/common/sync2"
|
|
"storj.io/storj/satellite/overlay"
|
|
)
|
|
|
|
// Error is the default error class for contact package
|
|
var Error = errs.Class("contact")
|
|
|
|
var mon = monkit.Package()
|
|
|
|
// Config contains configurable values for contact service
|
|
type Config struct {
|
|
ExternalAddress string `user:"true" help:"the public address of the node, useful for nodes behind NAT" default:""`
|
|
|
|
// Chore config values
|
|
Interval time.Duration `help:"how frequently the node contact chore should run" releaseDefault:"1h" devDefault:"30s"`
|
|
}
|
|
|
|
// Service is the contact service between storage nodes and satellites
|
|
type Service struct {
|
|
log *zap.Logger
|
|
|
|
mu sync.Mutex
|
|
self *overlay.NodeDossier
|
|
|
|
initialized sync2.Fence
|
|
}
|
|
|
|
// NewService creates a new contact service
|
|
func NewService(log *zap.Logger, self *overlay.NodeDossier) *Service {
|
|
return &Service{
|
|
log: log,
|
|
self: self,
|
|
}
|
|
}
|
|
|
|
// Local returns the storagenode node-dossier
|
|
func (service *Service) Local() overlay.NodeDossier {
|
|
service.mu.Lock()
|
|
defer service.mu.Unlock()
|
|
return *service.self
|
|
}
|
|
|
|
// UpdateSelf updates the local node with the capacity
|
|
func (service *Service) UpdateSelf(capacity *pb.NodeCapacity) {
|
|
service.mu.Lock()
|
|
defer service.mu.Unlock()
|
|
if capacity != nil {
|
|
service.self.Capacity = *capacity
|
|
}
|
|
|
|
service.initialized.Release()
|
|
}
|