Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions crate.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package crate

import (
"bytes"
"context"
"database/sql"
"database/sql/driver"
"encoding/json"
Expand All @@ -10,6 +11,7 @@ import (
"io"
"net/http"
"net/url"
"strings"
)

// Crate conn structure
Expand All @@ -33,6 +35,14 @@ func (c *CrateDriver) Open(crate_url string) (driver.Conn, error) {
return c, nil
}

func (c *CrateDriver) Ping(ctx context.Context) error {

Choose a reason for hiding this comment

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

exported method CrateDriver.Ping should have comment or be unexported

Copy link
Author

Choose a reason for hiding this comment

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

oooooo fancy

_, err := c.Exec("SELECT name FROM sys.cluster", nil)
if err != nil && strings.Contains(err.Error(), "dial tcp") {
return fmt.Errorf("Could not connect to crate at %s", c.Url)
}
return err
}

// JSON endpoint response struct
// We expect error to be null or ommited
type endpointResponse struct {
Expand Down