2018-11-01 16:51:19 +00:00
|
|
|
// Copyright (C) 2018 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
2018-11-05 15:23:54 +00:00
|
|
|
package bwagreement
|
2018-11-01 16:51:19 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"go.uber.org/zap"
|
|
|
|
|
|
|
|
monkit "gopkg.in/spacemonkeygo/monkit.v2"
|
|
|
|
"storj.io/storj/pkg/pb"
|
|
|
|
"storj.io/storj/pkg/provider"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
mon = monkit.Package()
|
|
|
|
)
|
|
|
|
|
|
|
|
// Config is a configuration struct that is everything you need to start an
|
|
|
|
// agreement receiver responsibility
|
|
|
|
type Config struct {
|
2018-11-05 15:23:54 +00:00
|
|
|
DatabaseURL string `help:"the database connection string to use" default:"$CONFDIR/agreements.db"`
|
|
|
|
DatabaseDriver string `help:"the database driver to use" default:"postgres"`
|
2018-11-01 16:51:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Run implements the provider.Responsibility interface
|
|
|
|
func (c Config) Run(ctx context.Context, server *provider.Provider) (err error) {
|
|
|
|
defer mon.Task()(&ctx)(&err)
|
2018-11-05 15:23:54 +00:00
|
|
|
ns, err := NewServer(c.DatabaseDriver, c.DatabaseURL, zap.L())
|
2018-11-01 16:51:19 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
pb.RegisterBandwidthServer(server.GRPC(), ns)
|
|
|
|
|
|
|
|
return server.Run(ctx)
|
|
|
|
}
|