-
Notifications
You must be signed in to change notification settings - Fork 0
Conversation
Changes Unknown when pulling 2265b1c on initial_main into ** on master**. |
.travis.yml
Outdated
@@ -10,5 +10,4 @@ dist: trusty | |||
script: | |||
- make lint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow the convention described here for the makefile.
use make all
in the .travis.yml like other M3DB repos: https://github.com/m3db/m3db/blob/master/.travis.yml
handler/common.go
Outdated
URI: r.RequestURI, | ||
MethodName: r.Method, | ||
SupportedMethods: supported} | ||
body, _ := json.Marshal(response) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: handle the error - propagate up/panic
handler/common_test.go
Outdated
rawResult := make([]byte, rr.Body.Len()) | ||
_, err := rr.Body.Read(rawResult) | ||
if err != nil { | ||
t.Errorf("Encountered error parsing reponse") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shorter:
require.NoError(t, err, "Encountered error parsing response)
handler/health/health.go
Outdated
if status != ok { | ||
w.WriteHeader(http.StatusInternalServerError) | ||
} | ||
body, _ := json.Marshal(h) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: handle error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its very unlikely that this will fail. Also, what do you suggest I do in this case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with Prateek here, all errors should ideally be handled (whether thats performing some action, bubbling them up, panicking, etc.). In this case I think we can log the error and return a 500.
handler/health/health.go
Outdated
func gatherHostInfo() string { | ||
host, err := os.Hostname() | ||
if err != nil { | ||
host = "unknown" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: why not propagate the error up to the m3ctlHealthCheck
?
Use a const instead of a magic string here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took this out of go-common. Its not really an issue, if it is unknown its fine.
handler/health/health.go
Outdated
) | ||
|
||
var ( | ||
healthURL = "/health" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason to make this a var instead of a const?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just following the pattern we have everywhere else
"time" | ||
|
||
"github.com/m3db/m3ctl/handler" | ||
"github.com/m3db/m3x/instrument" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: blank line between repo local and third-party imports
handler/rules/rules.go
Outdated
"github.com/m3db/m3x/instrument" | ||
) | ||
|
||
var ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can these be const
?
"net/http" | ||
|
||
"github.com/m3db/m3ctl/handler" | ||
"github.com/m3db/m3x/instrument" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: empty line between these imports
handler/rules/global.go
Outdated
|
||
package rules | ||
|
||
import "net/http" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: import block
server/options.go
Outdated
} | ||
|
||
// NewOptions creates a new set of server options | ||
func NewOptions() Options { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: reorder so the ctor
is not in the middle of getters/setters
"github.com/m3db/m3x/log" | ||
) | ||
|
||
type serverConfig struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels weird to have the struct be internal but the NewHTTPServerOptions method be public. Either export both, or neither.
If you're going to export the config struct, move to another package so other mains can import it
services/m3ctl/main/main.go
Outdated
|
||
etcdclient "github.com/m3db/m3cluster/client/etcd" | ||
"github.com/m3db/m3ctl/server" | ||
"github.com/m3db/m3ctl/services/m3ctl/serve" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: import ordering and spacing
services/m3ctl/main/main.go
Outdated
} | ||
|
||
type kvClientConfiguration struct { | ||
Etcd *etcdclient.Configuration `yaml:"etcd"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason to define this instead of not using etcdclient.Configuration directly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to not pollute the top level config namespace
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
// THE SOFTWARE. | ||
|
||
package server |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you re-use the newly added m3x/server
package?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will look into this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or perhaps the Server
struct defined in the http
package since this will be an HTTP server: https://golang.org/pkg/net/http/#Server
server/handlers.go
Outdated
"github.com/m3db/m3ctl/handler" | ||
"github.com/m3db/m3ctl/handler/health" | ||
"github.com/m3db/m3ctl/handler/rules" | ||
"github.com/m3db/m3x/instrument" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: space above this line
Changes Unknown when pulling 143f9e8 on initial_main into ** on master**. |
@@ -0,0 +1,11 @@ | |||
package: github.com/m3db/m3ctl | |||
|
|||
import: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe copy the packages (and their corresponding versions) that are in glide.lock
but aren't in glide.yaml
into glide.yaml
so they don't change when someone runs glide update
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only for direct dependencies, not transitive ones, yeah?
glide.yaml
Outdated
version: 18bc01a7057d55b78e528236e0e9db297bcd4fa3 | ||
- package: github.com/m3db/m3x | ||
version: bd6be18ffb184691512eb442561b16a59c15d797 | ||
- package: github.com/stretchr/testify |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: could mark this under TestImports
. For example:
testImport:
- package: github.com/stretchr/testify
version: 6fe211e493929a8aac0469b93f28b1d0688a9a3a
8b40fbc
to
8caad6a
Compare
glide.yaml
Outdated
- package: github.com/uber-go/atomic | ||
version: e682c1008ac17bf26d2e4b5ad6cdd08520ed0b22 | ||
- package: github.com/uber-go/tally | ||
version: 4b9d9de43ffcb0b7efe67dab2a92c2d58dbf16ab |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tally
uses semantic versioning, change this to <4.0.0
handler/health/health.go
Outdated
"github.com/m3db/m3ctl/handler" | ||
"github.com/m3db/m3x/instrument" | ||
|
||
"fmt" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move this to be along side the other stdlib imports
handler/health/health.go
Outdated
unknownName = "unkown" | ||
) | ||
|
||
var () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
delete
handler/rules/rules.go
Outdated
"net/http" | ||
|
||
"github.com/gorilla/mux" | ||
"github.com/m3db/m3ctl/handler" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
separate repo local import
import ( | ||
"github.com/m3db/m3ctl/handler/health" | ||
"github.com/m3db/m3ctl/handler/rules" | ||
"github.com/m3db/m3x/instrument" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
separate repo local v third-party imports
services/m3ctl/main/main.go
Outdated
"github.com/m3db/m3x/instrument" | ||
"github.com/m3db/m3x/log" | ||
|
||
"github.com/m3db/m3ctl/server" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move repo local imports above third party ones
- package: github.com/pmezard/go-difflib | ||
version: d8ed2627bdf02c080bf22230dbb337003b7aba2d | ||
- package: github.com/davecgh/go-spew | ||
version: 5215b55f46b2b919f50a1df0eaa5886afe4e3b3d |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: insert newline at the end
handler/health/health.go
Outdated
) | ||
|
||
const ( | ||
ok = "OK" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe make this a type to make it explicit -
type HealthStatus string
const (
Ok HealthStatus = "OK"
Fail = "FAIL"
)
handler/health/health.go
Outdated
unknownName = "unkown" | ||
) | ||
|
||
type healthCheckResult struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it make sense for this to be exported so other packages can re-use?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potentially but outside of the scope of this commit. It should go into m3x at that point though.
handler/health/health.go
Outdated
return &controller{iOpts: iOpts} | ||
} | ||
|
||
func healthCheck() string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why define this function instead of directly using the variable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the healthCheck in the skeleton implementation. It will be more interesting in the future.
aa3feec
to
58ee895
Compare
Changes Unknown when pulling d08a519 on initial_main into ** on master**. |
No description provided.