Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(291)

Issue 9410043: rpc: refactor

Can't Edit
Can't Publish+Mail
Start Review
Created:
10 years, 11 months ago by rog
Modified:
10 years, 11 months ago
Reviewers:
dimitern, mp+163705, fwereade
Visibility:
Public.

Description

rpc: refactor This is a significant refactoring. I'm afraid I couldn't see how to do it in small steps. Changes include: - factoring out of the websocket-specific RPC logic from state/apiserver into rpc/jsoncodec. - as a result, the rpc tests are now testing the same codec as used in state/apiserver. - the shutdown logic is hopefully cleaner and clearer. - and most importantly, rpc connections are now fully symmetric - the server can now make requests to the client. https://code.launchpad.net/~rogpeppe/juju-core/300-rpc-refactor/+merge/163705 (do not edit description out of merge proposal)

Patch Set 1 #

Patch Set 2 : rpc: refactor #

Patch Set 3 : rpc: refactor #

Patch Set 4 : rpc: refactor #

Total comments: 20

Patch Set 5 : rpc: refactor #

Total comments: 7

Patch Set 6 : rpc: refactor #

Unified diffs Side-by-side diffs Delta from patch set Stats (+1032 lines, -681 lines) Patch
A [revision details] View 1 2 3 4 5 1 chunk +2 lines, -0 lines 0 comments Download
M rpc/client.go View 1 2 7 chunks +62 lines, -156 lines 0 comments Download
A rpc/jsoncodec/codec.go View 1 2 3 4 1 chunk +157 lines, -0 lines 0 comments Download
A rpc/jsoncodec/codec_test.go View 1 2 1 chunk +183 lines, -0 lines 0 comments Download
A rpc/jsoncodec/conn.go View 1 2 3 4 5 1 chunk +58 lines, -0 lines 0 comments Download
M rpc/methods.go View 1 2 3 4 5 5 chunks +58 lines, -94 lines 0 comments Download
M rpc/rpc_test.go View 1 2 23 chunks +127 lines, -93 lines 0 comments Download
M rpc/server.go View 1 2 3 4 5 4 chunks +348 lines, -152 lines 0 comments Download
M state/api/client.go View 1 2 3 4 5 3 chunks +5 lines, -56 lines 0 comments Download
M state/api/error.go View 1 chunk +1 line, -1 line 0 comments Download
M state/apiserver/api_test.go View 1 2 3 4 5 3 chunks +6 lines, -5 lines 0 comments Download
M state/apiserver/apiserver.go View 1 2 3 4 5 3 chunks +1 line, -4 lines 0 comments Download
M state/apiserver/server.go View 1 2 3 4 5 5 chunks +24 lines, -120 lines 0 comments Download

Messages

Total messages: 5
rog
Please take a look.
10 years, 11 months ago (2013-05-15 12:39:34 UTC) #1
dimitern
Nice, LGTM and a few thoughts. https://codereview.appspot.com/9410043/diff/7001/rpc/jsoncodec/codec.go File rpc/jsoncodec/codec.go (right): https://codereview.appspot.com/9410043/diff/7001/rpc/jsoncodec/codec.go#newcode72 rpc/jsoncodec/codec.go:72: c.mu.Unlock() why not ...
10 years, 11 months ago (2013-05-15 16:27:26 UTC) #2
rog
Please take a look. https://codereview.appspot.com/9410043/diff/7001/rpc/jsoncodec/codec.go File rpc/jsoncodec/codec.go (right): https://codereview.appspot.com/9410043/diff/7001/rpc/jsoncodec/codec.go#newcode72 rpc/jsoncodec/codec.go:72: c.mu.Unlock() On 2013/05/15 16:27:26, dimitern ...
10 years, 11 months ago (2013-05-15 17:15:25 UTC) #3
fwereade
Essentially LGTM, but I would appreciate a bit more verbosity in the variable names -- ...
10 years, 11 months ago (2013-05-16 13:50:02 UTC) #4
rog
10 years, 11 months ago (2013-05-16 17:33:50 UTC) #5
*** Submitted:

rpc: refactor

This is a significant refactoring. I'm afraid I couldn't
see how to do it in small steps.

Changes include:
- factoring out of the websocket-specific RPC logic
from state/apiserver into rpc/jsoncodec.

- as a result, the rpc tests are now testing the same
codec as used in state/apiserver.

- the shutdown logic is hopefully cleaner and clearer.

- and most importantly, rpc connections are now
fully symmetric - the server can now make requests
to the client.

R=dimitern, fwereade
CC=
https://codereview.appspot.com/9410043

https://codereview.appspot.com/9410043/diff/7001/rpc/server.go
File rpc/server.go (right):

https://codereview.appspot.com/9410043/diff/7001/rpc/server.go#newcode232
rpc/server.go:232: _ = conn.codec.Close()
On 2013/05/16 13:50:03, fwereade wrote:
> On 2013/05/15 17:15:26, rog wrote:
> > On 2013/05/15 16:27:26, dimitern wrote:
> > > probably send it on the dead channel or some other ?
> > 
> > we can't do that - we're *receiving* from the dead channel here.
> > 
> > the problem is that we've got two errors here - the error from the input
loop
> > and the error from closing the codec. tbh i don't mind discarding the close
> > error - i can't think of a situation in which it would be very useful.
> 
> At least log it with a warning, please.

Done.

https://codereview.appspot.com/9410043/diff/9002/rpc/server.go
File rpc/server.go (left):

https://codereview.appspot.com/9410043/diff/9002/rpc/server.go#oldcode185
rpc/server.go:185: return o, a, nil
On 2013/05/16 13:50:03, fwereade wrote:
> I'm not really loving these m, o, a vars...

Done.
(i think)

https://codereview.appspot.com/9410043/diff/9002/rpc/server.go
File rpc/server.go (right):

https://codereview.appspot.com/9410043/diff/9002/rpc/server.go#newcode335
rpc/server.go:335: closing := conn.closing
On 2013/05/16 13:50:03, fwereade wrote:
> can't we just unlock here?

no - it's important that we cannot start a new request once closing has been set
(otherwise we can start servicing a new incoming request after we've called
Kill, which might mean that we can't shut down the server).

i'll add a comment.

https://codereview.appspot.com/9410043/diff/9002/rpc/server.go#newcode341
rpc/server.go:341: if closing {
On 2013/05/16 13:50:03, fwereade wrote:
> ...and use an else here for clarity? I misread it first time round.

i'm afraid not.
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b