storj/pkg/bwagreement/config.go

41 lines
974 B
Go
Raw Normal View History

// Copyright (C) 2018 Storj Labs, Inc.
// See LICENSE for copying information.
Satellite bw usage v3 121 (#547) * protobuf for sending bandwidth agreements to satellite from storage nodes * Setup process for sending agreements * Add payer_id to db with bandwidth agreements for better sorting * Linter errors * Read agreements from PSDB * Try writing message to server * Cleanup * Basic functionality * Better error handelling * Fix test * setup config and server structure for receiving bandwidth agreements * Resolve linter issues * Optional commit for if we want to handle deletes all at once * add identity to Server, add logic for receiving bandwidth messsages * Bandwidth agreement DBX creation and integration with bw agreement endpoint Co-authored-by: Kishore <kishore@storj.io> Co-authored-by: Cam <cameron@storj.io> * protobuf for sending bandwidth agreements to satellite from storage nodes * Setup process for sending agreements * Add payer_id to db with bandwidth agreements for better sorting * Linter errors * Read agreements from PSDB * Try writing message to server * Cleanup * Basic functionality * Better error handelling * Fix test * setup config and server structure for receiving bandwidth agreements * Resolve linter issues * Optional commit for if we want to handle deletes all at once * add identity to Server, add logic for receiving bandwidth messsages * Bandwidth agreement DBX creation and integration with bw agreement endpoint Co-authored-by: Kishore <kishore@storj.io> Co-authored-by: Cam <cameron@storj.io> * added postgres create/read/delete test function Co-authored-by: kishore <kishore@storj.io Co-authored-by: cam <cameron@storj.io> * edit comment * removed sqlite3 driver from dbx * remove generated sqlite code, add dbx read limitoffset * remove getServerAndDB function, rename getDBPath to getPSQLInfo * WIP writing server endpoint test * code review changes
2018-11-05 15:23:54 +00:00
package bwagreement
import (
"context"
"github.com/zeebo/errs"
"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 {
}
// Run implements the provider.Responsibility interface
func (c Config) Run(ctx context.Context, server *provider.Provider) (err error) {
defer mon.Task()(&ctx)(&err)
k := server.Identity().Leaf.PublicKey
zap.S().Debug("Starting Bandwidth Agreement Receiver...")
db, ok := ctx.Value("masterdb").(interface{ BandwidthAgreement() DB })
if !ok {
return errs.New("unable to get satellite master db instance")
}
pb.RegisterBandwidthServer(server.GRPC(), NewServer(db.BandwidthAgreement(), zap.L(), k))
return server.Run(ctx)
}