Skip to content

Commit

Permalink
admin/back-offie: add defaults to service
Browse files Browse the repository at this point in the history
Add default max buckets and rate limit to admin service so these values can be returned if the DB value is null.

Change-Id: Ic7d2d32b5df9b27995025d3dc81f6167557be382
  • Loading branch information
cam-a authored and Storj Robot committed Jan 3, 2024
1 parent 1c4a6fe commit c7b34b2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
2 changes: 2 additions & 0 deletions satellite/admin.go
Expand Up @@ -265,6 +265,8 @@ func NewAdmin(log *zap.Logger, full *identity.FullIdentity, db DB, metabaseDB *m
peer.DB.ProjectAccounting(),
peer.Accounting.Service,
placement,
config.Metainfo.ProjectLimits.MaxBuckets,
config.Metainfo.RateLimiter.Rate,
)

adminConfig := config.Admin
Expand Down
13 changes: 13 additions & 0 deletions satellite/admin/back-office/service.go
Expand Up @@ -11,13 +11,20 @@ import (
"storj.io/storj/satellite/nodeselection"
)

// Defaults contains default values for limits which are not stored in the DB.
type Defaults struct {
MaxBuckets int
RateLimit int
}

// Service provides functionality for administrating satellites.
type Service struct {
log *zap.Logger
consoleDB console.DB
accountingDB accounting.ProjectAccounting
accounting *accounting.Service
placement nodeselection.PlacementDefinitions
defaults Defaults
}

// NewService creates a new satellite administration service.
Expand All @@ -27,12 +34,18 @@ func NewService(
accountingDB accounting.ProjectAccounting,
accounting *accounting.Service,
placement nodeselection.PlacementDefinitions,
defaultMaxBuckets int,
defaultRateLimit float64,
) *Service {
return &Service{
log: log,
consoleDB: consoleDB,
accountingDB: accountingDB,
accounting: accounting,
placement: placement,
defaults: Defaults{
MaxBuckets: defaultMaxBuckets,
RateLimit: int(defaultRateLimit),
},
}
}

0 comments on commit c7b34b2

Please sign in to comment.