-
Notifications
You must be signed in to change notification settings - Fork 728
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
tools: add component subcommand #2092
Conversation
765ae13
to
2861a84
Compare
12ffe35
to
ee3adb8
Compare
Codecov Report
@@ Coverage Diff @@
## master #2092 +/- ##
==========================================
- Coverage 76.68% 75.96% -0.72%
==========================================
Files 191 195 +4
Lines 19902 20228 +326
==========================================
+ Hits 15262 15367 +105
- Misses 3475 3686 +211
- Partials 1165 1175 +10
Continue to review full report at Codecov.
|
LGTM |
/run-all-tests |
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.
LGTM
server/api/router.go
Outdated
|
||
type customMarshaler struct{} | ||
|
||
func (c *customMarshaler) Marshal(v interface{}) ([]byte, 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.
Why are they all empty implementations?
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.
Because we need to implement Marshaler interface 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.
how about nopMarshaler
} | ||
|
||
func (m componentMiddleware) Middleware(next http.Handler) http.Handler { | ||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
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 wonder if it is suitable to use middleware here. After all, the logic here is too complicated.
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 better idea?
} | ||
|
||
func (m componentMiddleware) Middleware(next http.Handler) http.Handler { | ||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
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 wonder if it is suitable to use middleware here. After all, the logic here is too complicated.
29dfbd4
to
a0b1421
Compare
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
a0b1421
to
9df4c54
Compare
server/api/router.go
Outdated
|
||
type customMarshaler struct{} | ||
|
||
func (c *customMarshaler) Marshal(v interface{}) ([]byte, 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.
how about nopMarshaler
@@ -34,7 +45,7 @@ func createIndentRender() *render.Render { | |||
}) | |||
} | |||
|
|||
func createRouter(prefix string, svr *server.Server) *mux.Router { | |||
func createRouter(ctx context.Context, prefix string, svr *server.Server) (*mux.Router, func()) { |
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.
could you add some comments to clarify what's the returned func()
used for?
server/api/router.go
Outdated
@@ -188,5 +199,77 @@ func createRouter(prefix string, svr *server.Server) *mux.Router { | |||
// Deprecated | |||
rootRouter.HandleFunc("/ping", func(w http.ResponseWriter, r *http.Request) {}).Methods("GET") | |||
|
|||
return rootRouter | |||
if svr.GetConfig().EnableDynamicConfig { | |||
f := func() { |
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.
seems better define it separetly
Signed-off-by: Ryan Leung <[email protected]>
PTAL. @disksing |
server/api/router.go
Outdated
f := func() { | ||
lazyComponentRouter(ctx, svr, apiRouter) | ||
} | ||
return rootRouter, f |
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.
return rootRouter, func(){lazyComponentRouter(ctx, svr, apiRouter)}
Signed-off-by: Ryan Leung <[email protected]>
/merge |
/run-all-tests |
What problem does this PR solve?
We need a way to support change the config of other components.
What is changed and how it works?
This PR adds a component subcommand to manipulate the config manager's configuration.
Check List
Tests