Skip to content

Commit

Permalink
cmd,config: add config
Browse files Browse the repository at this point in the history
  • Loading branch information
n8maninger committed Mar 3, 2024
1 parent 0938b74 commit 20f0eb6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
8 changes: 6 additions & 2 deletions cmd/fsd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ var (
BusAddress: "http://localhost:9980/api/bus",
Bucket: "ipfs",
},
BlockStore: config.BlockStore{
CacheSize: 10000,
MaxConcurrent: 1000,
},
IPFS: config.IPFS{
Gateway: config.HTTPGateway{
ListenAddress: ":8080",
Expand Down Expand Up @@ -150,11 +154,11 @@ func main() {
workerClient := worker.NewClient(cfg.Renterd.WorkerAddress, cfg.Renterd.WorkerPassword)
busClient := bus.NewClient(cfg.Renterd.BusAddress, cfg.Renterd.BusPassword)

bd, err := downloader.NewBlockDownloader(cfg.Renterd.Bucket, 4096, workerClient, log.Named("downloader"))
bd, err := downloader.NewBlockDownloader(cfg.Renterd.Bucket, cfg.BlockStore.CacheSize, workerClient, log.Named("downloader"))
if err != nil {
log.Fatal("failed to create block downloader", zap.Error(err))
}
bd.StartWorkers(ctx, 1000)
bd.StartWorkers(ctx, cfg.BlockStore.MaxConcurrent)

bs, err := renterd.NewBlockStore(
renterd.WithBucket(cfg.Renterd.Bucket),
Expand Down
16 changes: 12 additions & 4 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ type (
Bucket string `yaml:"bucket"`
}

BlockStore struct {

Check warning on line 18 in config/config.go

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 1.20)

exported: exported type BlockStore should have comment or be unexported (revive)
// MaxConcurrent is the maximum number of concurrent block fetches.
MaxConcurrent int `yaml:"maxConcurrent"`
// CacheSize is the maximum number of blocks to cache in memory.
CacheSize int `yaml:"cacheSize"`
}

// RemoteFetch contains settings for enabling/disabling remote IPFS block
// fetching.
RemoteFetch struct {
Expand Down Expand Up @@ -61,9 +68,10 @@ type (

// Config contains the configuration for fsd
Config struct {
Renterd Renterd `yaml:"renterd"`
IPFS IPFS `yaml:"ipfs"`
API API `yaml:"api"`
Log Log `yaml:"log"`
Renterd Renterd `yaml:"renterd"`
BlockStore BlockStore `yaml:"blockstore"`
IPFS IPFS `yaml:"ipfs"`
API API `yaml:"api"`
Log Log `yaml:"log"`
}
)

0 comments on commit 20f0eb6

Please sign in to comment.