Execute a command on current thread#13
Conversation
|
TODO: remove unneeded clone in with_fallback method |
6f54ab2 to
eabd4cb
Compare
45ffee2 to
8db6cc2
Compare
FeatureAdd
|
|
[IMO] The name of I prefer more descriptive names, like |
|
|
Oh, probably I'm confused about synchronous/asynchronous. Never mind. |
yes, I think so, too.
I think command = Expeditor::Command.new{xxx}
command.start(current_thread: true) # execute on current threadWhat do you think? |
|
Typing |
|
How about |
|
Nice suggestion. I think |
|
I'll implement this as a keyword argument. |
|
|
||
| def started? | ||
| @normal_future.executed? | ||
| !!@normal_future && @normal_future.executed? |
There was a problem hiding this comment.
I prefer to be more simply @normal_future && @normal_future.executed?
There was a problem hiding this comment.
I think it's not good. Because @normal_future should be hidden from library users.
I follow the style guide if it exists.
Note: cookpad/styleguide doesn't have the rule.
There was a problem hiding this comment.
should be hidden from library users.
I agree it, but @normal_future && @normal_future.executed? doesn't returns @normal_future, does it?
Although it might returns nil, nil does not show any information about @normal_future.
There was a problem hiding this comment.
I was confused. The implementation doesn't return a future. I'll change it to avoiding !!.
|
@pocke don't you support |
| def start | ||
| # @param current_thread [Boolean] Execute the task on current thread(blocking) | ||
| def start(current_thread: false) | ||
| if not started? |
Thanks, I forgot it. I'll implement it. |
1450e5c to
db50822
Compare
| def start_with_retry(retryable_options = {}) | ||
| if not started? | ||
| unless started? | ||
| current_thread = retryable_options.delete(:current_thread) |
There was a problem hiding this comment.
current_thread is not a member of retryable_options, so this variable name is a little confusing.
I think you should rename it, for example options.
There was a problem hiding this comment.
👍 I think so, too. I'll rename it.
- Avoid double `!` - Use kwrest argument instead of one option argument
|
I've fixed the suggestions. |
|
|
||
| describe '#start' do | ||
| context 'with normal' do | ||
| it 'should execute on current thread' do |
There was a problem hiding this comment.
should is unnecessary description. it 'executes on current thread' is enough.
|
LGTM with a comment |
Thanks, I've |
I've added a feature to execute a command on current thread.
Currently, we can execute a command on current thread by the following code.
However, it's complexity. So, I've added
Command#runmethod to execute on current thread.The following code works same as the above.
Naming of
runis inspired byexec.Commandof Golang. https://golang.org/pkg/os/exec/#Cmd.Run