parent
28427e7fad
commit
c4afec9328
4
go.mod
4
go.mod
@ -40,7 +40,7 @@ require (
|
||||
github.com/fatih/color v1.7.0
|
||||
github.com/fatih/structs v1.0.0 // indirect
|
||||
github.com/go-redis/redis v6.14.1+incompatible
|
||||
github.com/gogo/protobuf v1.1.2-0.20181116123445-07eab6a8298c
|
||||
github.com/gogo/protobuf v1.2.0
|
||||
github.com/golang-migrate/migrate/v3 v3.5.2
|
||||
github.com/golang/mock v1.2.0
|
||||
github.com/golang/protobuf v1.2.0
|
||||
@ -109,7 +109,7 @@ require (
|
||||
go.uber.org/multierr v1.1.0 // indirect
|
||||
go.uber.org/zap v1.9.1
|
||||
golang.org/x/crypto v0.0.0-20190103213133-ff983b9c42bc
|
||||
golang.org/x/net v0.0.0-20181106065722-10aee1819953
|
||||
golang.org/x/net v0.0.0-20190119204137-ed066c81e75e
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4
|
||||
golang.org/x/sys v0.0.0-20190108104531-7fbe1cd0fcc2
|
||||
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2 // indirect
|
||||
|
4
go.sum
4
go.sum
@ -98,6 +98,8 @@ github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG
|
||||
github.com/gocql/gocql v0.0.0-20180913072538-864d5908455a/go.mod h1:4Fw1eo5iaEhDUs8XyuhSVCVy52Jq3L+/3GJgYkwc+/0=
|
||||
github.com/gogo/protobuf v1.1.2-0.20181116123445-07eab6a8298c h1:c8VQNu/587ErbVKJSz6kKVdrf3kS18Sn50UShPyJ7Wc=
|
||||
github.com/gogo/protobuf v1.1.2-0.20181116123445-07eab6a8298c/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/gogo/protobuf v1.2.0 h1:xU6/SpYbvkNYiptHJYEDRseDLvYE7wSqhYYNy0QSUzI=
|
||||
github.com/gogo/protobuf v1.2.0/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
||||
github.com/golang-migrate/migrate/v3 v3.5.2 h1:SUWSv6PD8Lr2TGx1lmVW7W2lRoQiVny3stM4He6jczQ=
|
||||
github.com/golang-migrate/migrate/v3 v3.5.2/go.mod h1:QDa9JH6Bdwbi+1jIEpOIWnTNoYRbtaVgByErXU0844E=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58=
|
||||
@ -349,6 +351,8 @@ golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73r
|
||||
golang.org/x/net v0.0.0-20180911220305-26e67e76b6c3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20181106065722-10aee1819953 h1:LuZIitY8waaxUfNIdtajyE/YzA/zyf0YxXG27VpLrkg=
|
||||
golang.org/x/net v0.0.0-20181106065722-10aee1819953/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190119204137-ed066c81e75e h1:MDa3fSUp6MdYHouVmCCNz/zaH2a6CRcxY3VhT/K3C5Q=
|
||||
golang.org/x/net v0.0.0-20190119204137-ed066c81e75e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be h1:vEDujvNQGv4jgYKudGeI/+DAX4Jffq6hpD55MmoEvKs=
|
||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f h1:wMNYb4v58l5UBM7MYRLPG6ZhfOqbKu7X5eyFl8ZhKvA=
|
||||
|
@ -83,7 +83,7 @@ func (s *Server) Retrieve(stream pb.PieceStoreRoutes_RetrieveServer) (err error)
|
||||
return err
|
||||
}
|
||||
|
||||
s.log.Debug("Successfully retrieved",
|
||||
s.log.Info("Successfully retrieved",
|
||||
zap.String("Piece ID", fmt.Sprint(pd.GetId())),
|
||||
zap.Int64("Allocated", allocated),
|
||||
zap.Int64("Retrieved", retrieved),
|
||||
|
@ -160,7 +160,7 @@ func (s *Server) Stop(ctx context.Context) error {
|
||||
)
|
||||
}
|
||||
|
||||
// Piece -- Send meta data about a stored by by Id
|
||||
// Piece -- Send meta data about a piece stored by Id
|
||||
func (s *Server) Piece(ctx context.Context, in *pb.PieceId) (*pb.PieceSummary, error) {
|
||||
s.log.Debug("Getting Meta", zap.String("Piece ID", in.GetId()))
|
||||
|
||||
@ -199,7 +199,7 @@ func (s *Server) Piece(ctx context.Context, in *pb.PieceId) (*pb.PieceSummary, e
|
||||
return nil, err
|
||||
}
|
||||
|
||||
s.log.Debug("Successfully retrieved meta", zap.String("Piece ID", in.GetId()))
|
||||
s.log.Info("Successfully retrieved meta", zap.String("Piece ID", in.GetId()))
|
||||
return &pb.PieceSummary{Id: in.GetId(), PieceSize: fileInfo.Size(), ExpirationUnixSec: ttl}, nil
|
||||
}
|
||||
|
||||
@ -207,6 +207,17 @@ func (s *Server) Piece(ctx context.Context, in *pb.PieceId) (*pb.PieceSummary, e
|
||||
func (s *Server) Stats(ctx context.Context, in *pb.StatsReq) (*pb.StatSummary, error) {
|
||||
s.log.Debug("Getting Stats...")
|
||||
|
||||
statsSummary, err := s.retrieveStats()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
s.log.Info("Successfully retrieved Stats...")
|
||||
|
||||
return statsSummary, nil
|
||||
}
|
||||
|
||||
func (s *Server) retrieveStats() (*pb.StatSummary, error) {
|
||||
totalUsed, err := s.DB.SumTTLSizes()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -265,6 +276,8 @@ func (s *Server) Delete(ctx context.Context, in *pb.PieceDelete) (*pb.PieceDelet
|
||||
return nil, err
|
||||
}
|
||||
|
||||
s.log.Info("Successfully deleted", zap.String("Piece ID", fmt.Sprint(in.GetId())))
|
||||
|
||||
return &pb.PieceDeleteSummary{Message: OK}, nil
|
||||
}
|
||||
|
||||
@ -277,8 +290,6 @@ func (s *Server) deleteByID(id string) error {
|
||||
return err
|
||||
}
|
||||
|
||||
s.log.Debug("Deleted", zap.String("Piece ID", id))
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -347,7 +358,7 @@ func getNamespace(signedMessage *pb.SignedMessage) []byte {
|
||||
}
|
||||
|
||||
func (s *Server) getDashboardData(ctx context.Context) (*pb.DashboardStats, error) {
|
||||
statsSummary, err := s.Stats(ctx, &pb.StatsReq{})
|
||||
statsSummary, err := s.retrieveStats()
|
||||
if err != nil {
|
||||
return &pb.DashboardStats{}, ServerError.Wrap(err)
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ func (s *Server) Store(reqStream pb.PieceStoreRoutes_StoreServer) (err error) {
|
||||
if err = s.DB.AddBandwidthUsed(total); err != nil {
|
||||
return StoreError.New("failed to write bandwidth info to database: %v", err)
|
||||
}
|
||||
s.log.Debug("Successfully stored", zap.String("Piece ID", fmt.Sprint(pd.GetId())))
|
||||
s.log.Info("Successfully stored", zap.String("Piece ID", fmt.Sprint(pd.GetId())))
|
||||
|
||||
return reqStream.SendAndClose(&pb.PieceStoreSummary{Message: OK, TotalReceived: total})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user