Skip to content
This repository has been archived by the owner on Feb 28, 2019. It is now read-only.

Initial main #1

Merged
merged 8 commits into from
Jun 7, 2017
Merged

Initial main #1

merged 8 commits into from
Jun 7, 2017

Conversation

dgromov
Copy link
Contributor

@dgromov dgromov commented Jun 5, 2017

No description provided.

@dgromov dgromov requested review from cw9 and xichen2020 June 5, 2017 02:03
@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 2265b1c on initial_main into ** on master**.

.travis.yml Outdated
@@ -10,5 +10,4 @@ dist: trusty
script:
- make lint
Copy link

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

URI: r.RequestURI,
MethodName: r.Method,
SupportedMethods: supported}
body, _ := json.Marshal(response)
Copy link

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

rawResult := make([]byte, rr.Body.Len())
_, err := rr.Body.Read(rawResult)
if err != nil {
t.Errorf("Encountered error parsing reponse")
Copy link

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)

if status != ok {
w.WriteHeader(http.StatusInternalServerError)
}
body, _ := json.Marshal(h)
Copy link

Choose a reason for hiding this comment

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

nit: handle error

Copy link
Contributor Author

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?

Copy link
Contributor

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.

func gatherHostInfo() string {
host, err := os.Hostname()
if err != nil {
host = "unknown"
Copy link

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

Copy link
Contributor Author

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.

)

var (
healthURL = "/health"
Copy link

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?

Copy link
Contributor Author

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"
Copy link

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

"github.com/m3db/m3x/instrument"
)

var (
Copy link

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"
Copy link

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


package rules

import "net/http"
Copy link

Choose a reason for hiding this comment

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

nit: import block

}

// NewOptions creates a new set of server options
func NewOptions() Options {
Copy link

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 {
Copy link

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


etcdclient "github.com/m3db/m3cluster/client/etcd"
"github.com/m3db/m3ctl/server"
"github.com/m3db/m3ctl/services/m3ctl/serve"
Copy link

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

}

type kvClientConfiguration struct {
Etcd *etcdclient.Configuration `yaml:"etcd"`
Copy link

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?

Copy link
Contributor Author

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
Copy link

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will look into this.

Copy link
Contributor

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

"github.com/m3db/m3ctl/handler"
"github.com/m3db/m3ctl/handler/health"
"github.com/m3db/m3ctl/handler/rules"
"github.com/m3db/m3x/instrument"
Copy link

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

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 143f9e8 on initial_main into ** on master**.

@@ -0,0 +1,11 @@
package: github.com/m3db/m3ctl

import:
Copy link
Contributor

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?

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

Copy link

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
Copy link
Contributor

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

@dgromov dgromov force-pushed the initial_main branch 2 times, most recently from 8b40fbc to 8caad6a Compare June 7, 2017 17:40
@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 8caad6a7e144df028377e35641f82f377169a396 on initial_main into ** on master**.

glide.yaml Outdated
- package: github.com/uber-go/atomic
version: e682c1008ac17bf26d2e4b5ad6cdd08520ed0b22
- package: github.com/uber-go/tally
version: 4b9d9de43ffcb0b7efe67dab2a92c2d58dbf16ab
Copy link

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

"github.com/m3db/m3ctl/handler"
"github.com/m3db/m3x/instrument"

"fmt"
Copy link

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

unknownName = "unkown"
)

var ()
Copy link

Choose a reason for hiding this comment

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

delete

"net/http"

"github.com/gorilla/mux"
"github.com/m3db/m3ctl/handler"
Copy link

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"
Copy link

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

"github.com/m3db/m3x/instrument"
"github.com/m3db/m3x/log"

"github.com/m3db/m3ctl/server"
Copy link

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

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling b07947f4f3af13c2b4e62e91542671bb5b44f25e on initial_main into ** on master**.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling c5b696d2b0b2b523402b67f9ffca5aea6cbb26ff on initial_main into ** on master**.

- package: github.com/pmezard/go-difflib
version: d8ed2627bdf02c080bf22230dbb337003b7aba2d
- package: github.com/davecgh/go-spew
version: 5215b55f46b2b919f50a1df0eaa5886afe4e3b3d
Copy link

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

)

const (
ok = "OK"
Copy link

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"
)

unknownName = "unkown"
)

type healthCheckResult struct {
Copy link

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?

Copy link
Contributor Author

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.

return &controller{iOpts: iOpts}
}

func healthCheck() string {
Copy link

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?

Copy link
Contributor Author

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.

@dgromov dgromov force-pushed the initial_main branch 2 times, most recently from aa3feec to 58ee895 Compare June 7, 2017 20:05
@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 58ee895822af306cb1b041bc3641251757ea5891 on initial_main into ** on master**.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 58ee895822af306cb1b041bc3641251757ea5891 on initial_main into ** on master**.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling d08a519 on initial_main into ** on master**.

@dgromov dgromov merged commit 3d0f679 into master Jun 7, 2017
@dgromov dgromov deleted the initial_main branch June 7, 2017 20:18
@dgromov dgromov restored the initial_main branch June 7, 2017 20:19
@dgromov dgromov mentioned this pull request Jun 7, 2017
@dgromov dgromov deleted the initial_main branch June 7, 2017 21:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants