-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4506 from influxdb/enterprise_stats
Enterprise registration as a service
- Loading branch information
Showing
10 changed files
with
326 additions
and
108 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
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package registration | ||
|
||
import ( | ||
"time" | ||
|
||
"github.com/influxdb/influxdb/toml" | ||
) | ||
|
||
const ( | ||
DefaultURL = "https://enterprise.influxdata.com" | ||
DefaultStatsInterval = time.Minute | ||
) | ||
|
||
type Config struct { | ||
Enabled bool `toml:"enabled"` | ||
URL string `toml:"url"` | ||
Token string `toml:"token"` | ||
StatsInterval toml.Duration `toml:"stats-interval"` | ||
} | ||
|
||
func NewConfig() Config { | ||
return Config{ | ||
Enabled: true, | ||
URL: DefaultURL, | ||
StatsInterval: toml.Duration(DefaultStatsInterval), | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package registration_test | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/BurntSushi/toml" | ||
"github.com/influxdb/influxdb/services/registration" | ||
) | ||
|
||
func TestConfig_Parse(t *testing.T) { | ||
// Parse configuration. | ||
var c registration.Config | ||
if _, err := toml.Decode(` | ||
enabled = true | ||
url = "a.b.c" | ||
token = "1234" | ||
stats-interval = "1s" | ||
`, &c); err != nil { | ||
t.Fatal(err) | ||
} | ||
|
||
// Validate configuration. | ||
if c.Enabled != true { | ||
t.Fatalf("unexpected enabled state: %v", c.Enabled) | ||
} else if c.URL != "a.b.c" { | ||
t.Fatalf("unexpected Enterprise URL: %s", c.URL) | ||
} else if c.Token != "1234" { | ||
t.Fatalf("unexpected Enterprise URL: %s", c.URL) | ||
} else if time.Duration(c.StatsInterval) != time.Second { | ||
t.Fatalf("unexpected stats interval: %v", c.StatsInterval) | ||
} | ||
} |
Oops, something went wrong.