-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
657 additions
and
572 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,48 @@ | ||
package main | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/bahner/go-ma-actor/config" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
func configTemplate(identity string, node string) map[string]interface{} { | ||
type NodeStruct struct { | ||
Cookie string `yaml:"cookie"` | ||
Name string `yaml:"name"` | ||
Space string `yaml:"space"` | ||
DebugInterval time.Duration `yaml:"debug-interval"` | ||
} | ||
|
||
// Get the default settings as a map | ||
// Note: Viper does not have a built-in way to directly extract only the config | ||
// so we manually recreate the structure based on the config we have set. | ||
return map[string]interface{}{ | ||
"actor": map[string]interface{}{ | ||
"identity": identity, | ||
"location": config.ActorLocation(), | ||
"nick": config.ActorNick(), | ||
}, | ||
"db": map[string]interface{}{ | ||
"dir": config.DefaultDbPath, | ||
}, | ||
// Use default log settings, so as not to pick up debug log settings | ||
"log": map[string]interface{}{ | ||
"level": viper.GetString("log.level"), | ||
"file": viper.GetString("log.file"), | ||
}, | ||
// NB! This is a cross over from go-ma | ||
"api": map[string]interface{}{ | ||
// This must be set corretly for generation to work | ||
"maddr": viper.GetString("api.maddr"), | ||
}, | ||
"http": map[string]interface{}{ | ||
"socket": config.HttpSocket(), | ||
}, | ||
"p2p": map[string]interface{}{ | ||
"identity": node, | ||
"port": config.P2PPort(), | ||
"connmgr": map[string]interface{}{ | ||
"low-watermark": config.P2PConnmgrLowWatermark(), | ||
"high-watermark": config.P2PConnmgrHighWatermark(), | ||
"grace-period": config.P2PConnMgrGracePeriod(), | ||
}, | ||
"discovery": map[string]interface{}{ | ||
"advertise-ttl": config.P2PDiscoveryAdvertiseTTL(), | ||
"advertise-limit": config.P2PDiscoveryAdvertiseLimit(), | ||
"advertise-interval": config.P2PDiscoveryAdvertiseInterval(), | ||
"dht": config.P2PDiscoveryDHT(), | ||
"mdns": config.P2PDiscoveryMDNS(), | ||
type NodeConfigStruct struct { | ||
Node NodeStruct `yaml:"node"` | ||
} | ||
|
||
type NodeConfig struct { | ||
Actor config.ActorConfigStruct `yaml:"actor"` | ||
API config.APIConfigStruct `yaml:"api"` | ||
DB config.DBConfigStruct `yaml:"db"` | ||
HTTP config.HTTPConfigStruct `yaml:"http"` | ||
Node NodeConfigStruct `yaml:"node"` | ||
Log config.LogConfigStruct `yaml:"log"` | ||
P2P config.P2PConfigStruct `yaml:"p2p"` | ||
} | ||
|
||
func Config() NodeConfig { | ||
|
||
return NodeConfig{ | ||
Actor: config.ActorConfig(), | ||
API: config.APIConfig(), | ||
DB: config.DBConfig(), | ||
HTTP: config.HTTPConfig(), | ||
Node: NodeConfigStruct{ | ||
Node: NodeStruct{ | ||
Cookie: NodeCookie(), | ||
Name: NodeName(), | ||
Space: NodeSpace(), | ||
DebugInterval: NodeDebugInterval(), | ||
}, | ||
}, | ||
"node": map[string]interface{}{ | ||
"cookie": defaultNodeCookie, | ||
"name": defaultNodeName, | ||
"debug_interval": defaultNodeDebugInterval, | ||
"space": defautSpaceNodeName, | ||
}, | ||
Log: config.LogConfig(), | ||
P2P: config.P2PConfig(), | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.