Skip to content

Commit

Permalink
Move more cfg out of groups
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelavila committed May 6, 2019
1 parent 77259cd commit 28c163b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
4 changes: 2 additions & 2 deletions core/node/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func Online(bcfg *BuildCfg, cfg *config.Config) fx.Option {
fx.Provide(p2p.New),

LibP2P(bcfg, cfg),
OnlineProviders(cfg),
OnlineProviders(cfg.Experimental.StrategicProviding, cfg.Reprovider.Strategy, cfg.Reprovider.Interval),
)
}

Expand All @@ -244,7 +244,7 @@ func Offline(cfg *config.Config) fx.Option {
fx.Provide(offline.Exchange),
fx.Provide(Namesys(0)),
fx.Provide(offroute.NewOfflineRouter),
OfflineProviders(cfg),
OfflineProviders(cfg.Experimental.StrategicProviding, cfg.Reprovider.Strategy, cfg.Reprovider.Interval),
)
}

Expand Down
23 changes: 11 additions & 12 deletions core/node/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (

"go.uber.org/fx"

"github.com/ipfs/go-ipfs-config"
"github.com/ipfs/go-ipfs/core/node/helpers"
"github.com/ipfs/go-ipfs/provider"
q "github.com/ipfs/go-ipfs/provider/queue"
Expand Down Expand Up @@ -72,34 +71,34 @@ func StrategicOfflineProviderSysCtor() provider.System {
// ONLINE/OFFLINE

// OnlineProviders groups units managing provider routing records online
func OnlineProviders(cfg *config.Config) fx.Option {
if cfg.Experimental.StrategicProviding {
func OnlineProviders(useStrategicProviding bool, reprovideStrategy string, reprovideInterval string) fx.Option {
if useStrategicProviding {
return fx.Provide(StrategicProviderSysCtor)
}

return fx.Options(
SimpleProviders(cfg),
SimpleProviders(reprovideStrategy, reprovideInterval),
fx.Provide(SimpleProviderSysCtor),
)
}

// OfflineProviders groups units managing provider routing records offline
func OfflineProviders(cfg *config.Config) fx.Option {
if cfg.Experimental.StrategicProviding {
func OfflineProviders(useStrategicProviding bool, reprovideStrategy string, reprovideInterval string) fx.Option {
if useStrategicProviding {
return fx.Provide(StrategicOfflineProviderSysCtor)
}

return fx.Options(
SimpleProviders(cfg),
SimpleProviders(reprovideStrategy, reprovideInterval),
fx.Provide(SimpleOfflineProviderSysCtor),
)
}

// SimpleProviders creates the simple provider/reprovider dependencies
func SimpleProviders(cfg *config.Config) fx.Option {
func SimpleProviders(reprovideStrategy string, reprovideInterval string) fx.Option {
reproviderInterval := kReprovideFrequency
if cfg.Reprovider.Interval != "" {
dur, err := time.ParseDuration(cfg.Reprovider.Interval)
if reprovideInterval != "" {
dur, err := time.ParseDuration(reprovideInterval)
if err != nil {
return fx.Error(err)
}
Expand All @@ -108,7 +107,7 @@ func SimpleProviders(cfg *config.Config) fx.Option {
}

var keyProvider fx.Option
switch cfg.Reprovider.Strategy {
switch reprovideStrategy {
case "all":
fallthrough
case "":
Expand All @@ -118,7 +117,7 @@ func SimpleProviders(cfg *config.Config) fx.Option {
case "pinned":
keyProvider = fx.Provide(simple.NewPinnedProvider(false))
default:
return fx.Error(fmt.Errorf("unknown reprovider strategy '%s'", cfg.Reprovider.Strategy))
return fx.Error(fmt.Errorf("unknown reprovider strategy '%s'", reprovideStrategy))
}

return fx.Options(
Expand Down

2 comments on commit 28c163b

@GitCop
Copy link

@GitCop GitCop commented on 28c163b May 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were the following issues with your Pull Request

We ask for a few features in the commit message for Open Source licensing hygiene and commit message clarity.
git commit --amend can often help you quickly improve the commit message.
Guidelines and a script are available to help in the long run.
Your feedback on GitCop is welcome on this issue.


This message was auto-generated by https://gitcop.com

@GitCop
Copy link

@GitCop GitCop commented on 28c163b May 6, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were the following issues with your Pull Request

We ask for a few features in the commit message for Open Source licensing hygiene and commit message clarity.
git commit --amend can often help you quickly improve the commit message.
Guidelines and a script are available to help in the long run.
Your feedback on GitCop is welcome on this issue.


This message was auto-generated by https://gitcop.com

Please sign in to comment.