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
% choria buildinfo -D | |
.... | |
Compile time module dependencies: | |
github.com/AlecAivazis/survey/v2 v2.0.5 | |
github.com/OneOfOne/xxhash v1.2.3 | |
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 | |
github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4 | |
github.com/beorn7/perks v1.0.1 | |
github.com/cespare/xxhash/v2 v2.1.1 |
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
diff --git a/goss/client/client.go b/goss/client/client.go | |
index 04d7d96..c679ae6 100644 | |
--- a/goss/client/client.go | |
+++ b/goss/client/client.go | |
@@ -11,6 +11,7 @@ import ( | |
"context" | |
"github.com/choria-io/go-choria/choria" | |
+ coreclient "github.com/choria-io/go-choria/client/client" | |
"github.com/choria-io/go-choria/config" |
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
package config | |
var docStrings = map[string]string{ | |
"loglevel": "The lowest level log to add to the logfile", | |
"logfile": "The file to write logs to, when set to an empty string logging will be to the console", | |
} |
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
type Config struct { | |
// LogLevel is the logging level | |
// | |
// @doc The lowest level log to add to the logfile | |
LogLevel string `confkey:"loglevel" default:"info" validate:"enum=debug,info,warn,error,fatal" deprecated:"1" url:"http://example.com"` | |
// The file to write logs to, when set to an empty string logging will be to the console | |
LogFile string `confkey:"logfile" type:"path_string" description:"The log file"` | |
} |
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
c := &Config{} | |
doc := confkey.KeyDoc(c, "loglevel", "Config") | |
// Description of the field, also have Type(), URL(), Default(), Validation(), | |
// Deprecate(), Environment(), ConfigKey() and StructKey() | |
fmt.Printf("Description: %s\n", doc.Description()) |
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
c := &Config{} | |
// Initialize the struct with default values | |
err := confkey.SetStructDefaults(c) | |
panicIfErr(err) | |
// Next we have to set complex types - number, bool, slices etc - from strings as the data comes from the configuration file as text | |
// the conversions are all handled by the confkey package | |
// Set the value in the struct for whatever field matches the key loglevel |
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
type Config struct { | |
// LogLevel is the logging level | |
// | |
// @doc The lowest level log to add to the logfile | |
LogLevel string `confkey:"loglevel" default:"info" validate:"enum=debug,info,warn,error,fatal" deprecated:"1" url:"http://example.com"` | |
// The file to write logs to, when set to an empty string logging will be to the console | |
LogFile string `confkey:"logfile" type:"path_string" description:"The log file"` | |
Servers []string `confkey:"servers" type:"comma_split" environment:"SERVERS"` // Servers to connect to |
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
// reads config.go and includes parsing of comments | |
d, err := parser.ParseFile(token.NewFileSet(), "config.go", nil, parser.ParseComments) | |
panicIfErr(err) | |
ast.Inspect(d, func(n ast.Node) bool { | |
// this function filters and parses the ast, return false to stop descending into a | |
// branch of the AST, so we skip over everything till we reach Config struct | |
switch t := n.(type) { | |
case *ast.TypeSpec: |
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
$ go run main.go | |
Config.Registration: doc: "The plugin to use for sending Registration data, when this is unset or empty sending registration data is disabled " |
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
broker { | |
network { | |
listen_address = "0.0.0.0" | |
client_port = 4222 | |
client_tls_required = true | |
peer_port = 5222 | |
peers = [ | |
"nats://p1.example.net:5222" | |
] | |
} |