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

Issue 6312048: Drop ServiceRelation; add Relation

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

Description

Drop ServiceRelation; add Relation As discussed on IRC, ServiceRelation is "difficult" and liable to lead to confusion; and the code has been hinting that a Relation really is just a list of endpoints at heart. You'd think this would be obvious to anyone, in hindsight :). The proposed ordering of endpoints within a relation[0] has been dropped, in favour of a pair of Relation methods that expose the same information but more explicitly (Endpoint/RelatedEndpoint). [0] Early discussions suggested that Service.Relations should return a slice of slices of endpoints, with the latter ordered such that the first endpoint corresponded to the service from which the relations were acquired. https://code.launchpad.net/~fwereade/juju-core/relation-type/+merge/110870 (do not edit description out of merge proposal)

Patch Set 1 #

Patch Set 2 : Drop ServiceRelation; add Relation #

Patch Set 3 : Drop ServiceRelation; add Relation #

Total comments: 18

Patch Set 4 : Drop ServiceRelation; add Relation #

Unified diffs Side-by-side diffs Delta from patch set Stats (+142 lines, -60 lines) Patch
A [revision details] View 1 2 3 1 chunk +2 lines, -0 lines 0 comments Download
M state/relation.go View 1 2 3 4 chunks +74 lines, -28 lines 0 comments Download
M state/relation_test.go View 1 2 1 chunk +22 lines, -0 lines 0 comments Download
M state/service.go View 1 2 3 1 chunk +20 lines, -10 lines 0 comments Download
M state/state.go View 1 2 3 2 chunks +2 lines, -12 lines 0 comments Download
M state/state_test.go View 1 2 3 4 chunks +21 lines, -9 lines 0 comments Download
M state/topology.go View 1 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 7
fwereade
Please take a look.
11 years, 10 months ago (2012-06-18 17:31:54 UTC) #1
niemeyer
We've discussed ideas around this online today.
11 years, 10 months ago (2012-06-18 19:13:00 UTC) #2
fwereade
Please take a look.
11 years, 10 months ago (2012-06-18 22:33:46 UTC) #3
fwereade
Please take a look.
11 years, 10 months ago (2012-06-20 11:11:42 UTC) #4
niemeyer
Almost there! https://codereview.appspot.com/6312048/diff/4008/state/relation.go File state/relation.go (right): https://codereview.appspot.com/6312048/diff/4008/state/relation.go#newcode20 state/relation.go:20: // relate to. // This should remain ...
11 years, 10 months ago (2012-06-20 15:15:05 UTC) #5
niemeyer
Actually, LGTM with that in.
11 years, 10 months ago (2012-06-20 15:21:44 UTC) #6
fwereade
11 years, 10 months ago (2012-06-20 16:25:16 UTC) #7
*** Submitted:

Drop ServiceRelation; add Relation

As discussed on IRC, ServiceRelation is "difficult" and liable to lead to
confusion; and the code has been hinting that a Relation really is just a
list of endpoints at heart. You'd think this would be obvious to anyone, in
hindsight :).

The proposed ordering of endpoints within a relation[0] has been dropped, in
favour of a pair of Relation methods that expose the same information but
more explicitly (Endpoint/RelatedEndpoint).

[0] Early discussions suggested that Service.Relations should return a slice
of slices of endpoints, with the latter ordered such that the first endpoint
corresponded to the service from which the relations were acquired.

R=niemeyer
CC=
https://codereview.appspot.com/6312048

https://codereview.appspot.com/6312048/diff/4008/state/relation.go
File state/relation.go (right):

https://codereview.appspot.com/6312048/diff/4008/state/relation.go#newcode20
state/relation.go:20: // relate to.
On 2012/06/20 15:15:05, niemeyer wrote:
> // This should remain an internal method because the relation
> // model does not guarantee that for every role there will
> // necessarily exist a single counterpart role that is sensible
> // for basing algorithms upon. 

Done.

https://codereview.appspot.com/6312048/diff/4008/state/relation.go#newcode89
state/relation.go:89: // running a relation hook on a unit of the supplied
service.
On 2012/06/20 15:15:05, niemeyer wrote:
> This isn't documenting what this function returns. It's documenting that what
it
> returns is the same as something else.
> 
> By the way, ideally new functionality unrelated to the review points made
> shouldn't be introduced mid-review, otherwise we risk running around in
circles
> a bit.

Done.

https://codereview.appspot.com/6312048/diff/4008/state/relation.go#newcode90
state/relation.go:90: func (r *Relation) Id(serviceName string) (string, error)
{
On 2012/06/20 15:15:05, niemeyer wrote:
> Hmmm.. what about dropping the serviceName argument, and returning the numeric
> id only?
> 
> It's a bit strange to have the serviceName parameter in an Id method, and it's
> also a bit strange to have a different relation id to each participant server
> from the perspective of this API.
> 
> We can preserve the properties of JUJU_RELATION_ID within the unit by merely
> joining the numeric id to the local relation name.

Done.

https://codereview.appspot.com/6312048/diff/4008/state/relation.go#newcode103
state/relation.go:103: // Endpoint returns the endpoint of the relation attached
to the named service.
On 2012/06/20 15:15:05, niemeyer wrote:
> s/attached to/for/

Done.

https://codereview.appspot.com/6312048/diff/4008/state/relation.go#newcode115
state/relation.go:115: // named service will relate. If the service is not part
of the relation, an
On 2012/06/20 15:15:05, niemeyer wrote:
> s/relate/establish relations with/, just for slightly more clarity.
> 
> Also, s/of the relation/of the r relation/, to disambiguate.

Done.

https://codereview.appspot.com/6312048/diff/4008/state/relation.go#newcode124
state/relation.go:124: for _, ep := range r.endpoints {
On 2012/06/20 15:15:05, niemeyer wrote:
> Nice logic here.
Cheers :).

https://codereview.appspot.com/6312048/diff/4008/state/service.go
File state/service.go (right):

https://codereview.appspot.com/6312048/diff/4008/state/service.go#newcode221
state/service.go:221: var err error
On 2012/06/20 15:15:05, niemeyer wrote:
> This will conflict with Frank's change. Watch out as this is broken. err must
be
> a named result for errorContextf to work.

Yeah, that makes perfect sense now I think about it :/. Thanks.

https://codereview.appspot.com/6312048/diff/4008/state/service.go#newcode231
state/service.go:231: relations := []*Relation{}
On 2012/06/20 15:15:05, niemeyer wrote:
> s/relations/rs/, to follow along everything else below.

On further thought... I think there are enough error paths to make
errorfContextf worthwhile, which implies named parameters, which then rather
demands readably-named ones.

https://codereview.appspot.com/6312048/diff/4008/state/service.go#newcode235
state/service.go:235: for skey, rs := range tr.Services {
On 2012/06/20 15:15:05, niemeyer wrote:
> rs is not a good name here for something that isn't "relations" here due to
> context.

I think I've just realised what topoRelation.Services is... it's
topoRelation.Endpoints. (Or, at least, the remaining information necessary to
reconstruct the endpoints.)

I'm calling it "tep" for now, and I'm going to propose a tiny followup that
fixes topoRelationService (and related bits') naming.
Sign in to reply to this message.

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