storj/pkg/statdb/config.go
JT Olio 87925789de pkg/inspector: split functionality to be per-service (#1029)
now kad inspector features exist on every server that has
kademlia running. likewise, overlay and statdb.

this means kad inspection features are now available on
storage nodes

Change-Id: I343c873552341de13302bfb7a5d79cccc84fc6b8
2019-01-14 11:47:22 -07:00

36 lines
823 B
Go

// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
package statdb
import (
"context"
"go.uber.org/zap"
"storj.io/storj/pkg/pb"
"storj.io/storj/pkg/server"
)
// Config represents a StatDB service
type Config struct{}
// Run implements server.Service
func (Config) Run(ctx context.Context, server *server.Server) (err error) {
defer mon.Task()(&ctx)(&err)
sdb, ok := ctx.Value("masterdb").(interface {
StatDB() DB
})
if !ok {
return Error.New("unable to get master db instance")
}
zap.S().Warn("Once the Peer refactor is done, the statdb inspector needs to be registered on a " +
"gRPC server that only listens on localhost")
// TODO: register on a private rpc server
pb.RegisterStatDBInspectorServer(server.GRPC(), NewInspector(sdb.StatDB()))
return server.Run(ctx)
}