Skip to content

Commit

Permalink
chore: do not block startup
Browse files Browse the repository at this point in the history
  • Loading branch information
caarlos0 committed Dec 12, 2018
1 parent fd1f3a7 commit 0f534e0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
21 changes: 12 additions & 9 deletions client/couchbase.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ type Client struct {
}

// New creates a new couchbase client
func New(url, user, password string) (Client, error) {
func New(url, user, password string) Client {
var client = Client{
baseURL: url,
client: http.Client{
Expand All @@ -28,14 +28,17 @@ func New(url, user, password string) (Client, error) {
},
},
}
nodes, err := client.Nodes()
if err != nil {
return client, errors.Wrap(err, "failed to get node details")
}
if !strings.HasPrefix(nodes.Nodes[0].Version, "5.") {
log.Warnf("couchbase %s is not fully supported", nodes.Nodes[0].Version)
}
return client, nil
go func() {
nodes, err := client.Nodes()
if err != nil {
log.Warnf("couldn't verify server version compatibility: %s", err.Error())
return
}
if !strings.HasPrefix(nodes.Nodes[0].Version, "5.") {
log.Warnf("couchbase %s is not fully supported", nodes.Nodes[0].Version)
}
}()
return client
}

func (c Client) url(path string) string {
Expand Down
5 changes: 1 addition & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ func main() {

log.Infof("starting couchbase-exporter %s...", version)

client, err := client.New(*couchbaseURL, *couchbaseUsername, *couchbasePassword)
if err != nil {
log.Fatalf("failed to create couchbase client: %v", err)
}
var client = client.New(*couchbaseURL, *couchbaseUsername, *couchbasePassword)

if *tasks {
prometheus.MustRegister(collector.NewTasksCollector(client))
Expand Down

0 comments on commit 0f534e0

Please sign in to comment.