-
Notifications
You must be signed in to change notification settings - Fork 290
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
Module rewrite #275
Module rewrite #275
Conversation
@peter-edge, thanks for your PR! By analyzing the history of the files in this pull request, we identified @sectioneight, @shawnburke and @madhuravi to be potential reviewers. |
service/module.go
Outdated
Host | ||
Items() map[string]interface{} | ||
// TODO(pedge) | ||
ConfigValue() config.Value |
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 thought Host already has Config
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.
Ya I'm going to remove this for now
modules/rpc/yarpc_options.go
Outdated
return nil | ||
} | ||
func WithInboundMiddleware(i ...middleware.UnaryInbound) service.ModuleOption { | ||
return service.WithModuleItem(_interceptorKey, func(existing interface{}) interface{} { |
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 like this wrapping on write to module item.
maybe a similar wrapping for read as well?
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.
What do you mean exactly? Wrap Items()
access?
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.
Done
service/module.go
Outdated
func WithModuleItem(key string, f func(interface{})interface{}) ModuleOption { | ||
return func(o *moduleOption) error { | ||
value, ok := o.items[key] | ||
if 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.
nit:
if value, ok := o.items[key]; ok {
o.items[key] = f(value)
return nil
}
o.items[key] = f(nil)
retur nil
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.
ya whoops, sorry
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.
so much better 👏
service/host.go
Outdated
@@ -323,29 +304,34 @@ func (s *host) Stop(reason string, exitCode int) error { | |||
return err | |||
} | |||
|
|||
func (s *host) startModules() map[Module]error { | |||
results := map[Module]error{} | |||
func (s *host) startModules() []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.
so this only happens once, right? how much time are we saving be starting these in parallel?
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.
No idea, but this PR is just addressing the external interface, I think we can iterate on implementation some other time.
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.
sg
return &serviceCore{ | ||
authClient: client, | ||
configProvider: config.NewStaticProvider(nil), | ||
configProvider: configProvider, | ||
standardConfig: serviceConfig{ | ||
Name: "dummy", |
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 we read the name from our config provider? i need this for some integration 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.
We can, but probably out of scope for this PR
service/module.go
Outdated
return m.name | ||
} | ||
|
||
func (m *moduleWrapper) Start() 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.
can we remove locking if we single thread start/stop?
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.
Ya we can, but I really think the locking is "proper".
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.
okay. fine with it.
service/module.go
Outdated
} | ||
|
||
func (mi *moduleInfo) Metrics() tally.Scope { | ||
return mi.Host.Metrics().SubScope("modules").SubScope(mi.name) |
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.
is it more efficient to memoize this scope?
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.
Yes, I think I have a TODO somewhere in this file to do that
modules/rpc/yarpc.go
Outdated
@@ -65,7 +60,8 @@ var ( | |||
// that are stored together to create a shared dispatcher. | |||
// The YARPC team advised it to be a 'singleton' to control | |||
// the lifecycle of all of the in/out bound traffic. | |||
_controller dispatcherController | |||
_controller dispatcherController | |||
_controllerRunning bool |
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 global var is definitely not needed
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.
Removed
modules/rpc/thrift.go
Outdated
type CreateThriftServiceFunc func(svc service.Host) ([]transport.Procedure, error) | ||
|
||
// ThriftModule creates a Thrift Module from a service func | ||
func ThriftModule(hookup CreateThriftServiceFunc, options ...modules.Option) service.ModuleCreateFunc { |
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 you removing 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.
They are now on the service builder only
for msg := range b.bufQueue { | ||
errorCh <- Run(context.Background(), msg) | ||
// TODO(pedge): this was effectively not being handled and was a bug |
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.
It is not a bug, but a feature :) Seriously, this is a way to communicate with a sender about errors in function executions.
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.
If you look into how this channel was read, this error would have never been read with the current service code
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.
We do want to propagate these errors up so nothing to change here. Need to not drop them on the floor in module Start where this gets called.
I've updated for the latest changes. Before continuing, if everyone could give a quick lookover of what has happened so far, that would be great - the next step is going to be a lot of test refactoring and documentation updates, and before doing that, it would be nice to have a general "OK" from what I have so far. @sectioneight @dmcaulay @alsamylkin @madhuravi @yutongp @glibsm |
@@ -22,22 +22,26 @@ package service | |||
|
|||
import "github.com/pkg/errors" | |||
|
|||
// WithModules is a helper to create a service without any options | |||
func WithModules(modules ...ModuleCreateFunc) *Builder { |
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? I would prefer keeping WithModules.
1.
service.WithModule(
rpc,
uhttp,
task
)
service.WithModule(uhttp)
.WithModule(rpc)
.WithModule(task)
1 (the existing way) seems simpler and nicer than 2.
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.
You can't do this anymore, WithModule
takes more than one parameter for every module.
The reason is because now WithModule takes options instead of the
individual derivative functions, there are other ways to handle this but
this seemed the easiest.
…On Mon, Feb 20, 2017 at 7:51 PM Madhu Ravichandran ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In service/builder.go
<#275 (comment)>:
> @@ -22,22 +22,26 @@ package service
import "github.com/pkg/errors"
-// WithModules is a helper to create a service without any options
-func WithModules(modules ...ModuleCreateFunc) *Builder {
Why? I would prefer keeping WithModules.
1.
service.WithModule(
rpc,
uhttp,
task
)
1.
service.WithModule(uhttp)
.WithModule(rpc)
.WithModule(task)
1 (the existing way) seems simpler and nicer than 2.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#275 (review)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AECGvEza3O8QNDcwyW3PkurRd-EyHKRhks5reeCegaJpZM4MDUeB>
.
|
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 looking good to me. a lot of great work here.
Changes Unknown when pulling d2a3a7b on module-rewrite into ** on master**. |
@@ -48,7 +48,8 @@ | |||
// ) |
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 file shouldn't be included?
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.
? It changed from make gendoc
.
Code coverage is back up |
1 similar comment
Changes Unknown when pulling 12b58a2 on module-rewrite into ** on master**. |
Changes Unknown when pulling f0304ee on module-rewrite into ** on master**. |
👏 🎉 |
No description provided.