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

Issue 6307099: Rename ServiceRelation to RelatedService

Can't Edit
Can't Publish+Mail
Start Review
Created:
13 years, 8 months ago by fwereade
Modified:
13 years, 8 months ago
Reviewers:
mp+110578, niemeyer
Visibility:
Public.

Description

Rename ServiceRelation to RelatedService Hopefully the name betrays intent a little more clearly; the type represents a specific service in a relation from the perspective of another service in the relation (or at least from a unit eligible to join that relation, which may be a better description in a peer relation...). role/Role field/method were also changed to refer to the "remote" service rather than the "local" service. Also added RelationRole.RelatedRole() to replace most of RelationEndpoint.CanRelateTo and a small part of the relation sanity-checking in topology. https://code.launchpad.net/~fwereade/juju-core/related-service/+merge/110578 Requires: https://code.launchpad.net/~fwereade/juju-core/redundant-relation-prefixes/+merge/110504 (do not edit description out of merge proposal)

Patch Set 1 #

Total comments: 2
Unified diffs Side-by-side diffs Delta from patch set Stats (+57 lines, -46 lines) Patch
A [revision details] View 1 chunk +2 lines, -0 lines 0 comments Download
M state/relation.go View 4 chunks +38 lines, -21 lines 2 comments Download
M state/service.go View 1 chunk +8 lines, -8 lines 0 comments Download
M state/state_test.go View 4 chunks +6 lines, -6 lines 0 comments Download
M state/topology.go View 2 chunks +3 lines, -11 lines 0 comments Download

Messages

Total messages: 4
fwereade
Please take a look.
13 years, 8 months ago (2012-06-15 17:28:03 UTC) #1
niemeyer
https://codereview.appspot.com/6307099/diff/1/state/relation.go File state/relation.go (right): https://codereview.appspot.com/6307099/diff/1/state/relation.go#newcode17 state/relation.go:17: func (r RelationRole) RelatedRole() RelationRole { s/Related/Counterpart/ I'm not ...
13 years, 8 months ago (2012-06-15 20:49:33 UTC) #2
niemeyer
Sorry, after thinking further about this, and realizing that you have already changed AddRelation so ...
13 years, 8 months ago (2012-06-15 21:19:13 UTC) #3
fwereade
13 years, 8 months ago (2012-06-18 10:38:45 UTC) #4
On 2012/06/15 21:19:13, niemeyer wrote:
> Sorry, after thinking further about this, and realizing that you have already
> changed AddRelation so that it doesn't return ServiceRelation anymore. Perhaps
> the direction you're taking this may actually fine, 
> but please help me understanding where you're trying to take this.

I hope the following makes sense to you :).

> You've dropped Relation, which identified a relation. You've also dropped
> ServiceRelation, which identified a relation from the perspective of the
system,
> without assuming a local endpoint.

I dropped Relation, because it was essentially unused. We don't have any way to
list all relations, even in python, because there's no point in doing so; and,
while we do use the Relation type, the only thing we do is effectively
rsm.remove_relation(rsm.get_relation_state(*endpoints)), which is IMO far better
expressed as rsm.remove_relation(*endpoints); less code, fewer types, more
expressive. I don't see a downside here.

More on ServiceRelation to follow...

> How do we talk about a relation now?  If I want to remove a relation, or see
> which services are participating in a given relation, how do I do that?

We identify a relation to remove by looking at the endpoints, as we always did;
we've just dropped an obfuscatory extra step. AFAICT, we don't ever need to know
what services are participating in a particular relation; but, given a service,
we do need to know what it relates to, and this seems to me to apply both when
running a unit agent and when displaying status. What use cases have I missed
here?

Assuming I haven't, I think that RelatedService collects all the information
it's useful for us to know. In each of the above contexts, we want to do
something in response to the fact that a "local" service is related to a bunch
of other services; in every case, this involves knowing what the "local" service
thinks the relation is called (ie we always want to somehow pull in information
about the "local" endpoint).

I'm not saying we couldn't take a perspective-free ServiceRelation and figure
this out; I'm saying that, because we always end up wanting to use information
about each end of the relation, a perspective-free ServiceRelation is of limited
utility.

> Also, if I have a service, that has a peer relation, this is the *only*
service
> in that relation. It doesn't make sense to return the service itself when
> calling RelatedServices,

In both the unit agent and the status command, a service needs to deal with
itself-within-a-peer-relation in the same way it needs to deal with
another-service-in-pro-req-relation. We *could* do as we do, and get a bunch of
ServiceRelations from which we get all involved services and then strip out the
"local" service except in the case of a peer relation... or we could just grab
the related "remote" services and work with them directly.

> nor does it make sense to return the local relation
> endpoint when I call RelatedServices() on a requirer service (the requirer is
> definitely not *relating* to itself).

Quite so. A service-which-is-only-a-requirer's RelatedServices will include
providers only; but they'll be annotated with the "local" relation name, because
that *is* the relation name in every context in which they're used.

> I still have some of the sentiment that we're replacing a good model by
> something that puts us into trouble, but I'm not sure. Would you mind to
> brainstorm with me to see where we can take this?

I'm not sure it actually is a good model for us to use in the code; it seems to
me that recasting the situation in the terms I'm proposing allows us to discard
a lot of (IMO) confusing and superfluous code, both in the status command and in
the unit agent; and I don't *think* I'm making our lives any harder in any other
situations. (Counterexamples here will be the quickest way of convincing me of
crackfulness...) Medium-term, I'm aiming for something a bit like:

// For use by status
(*Service) RelatedServices() ([]RelatedService, error)

// For use by the unit agent (at the top level)
(*Service) WatchRelatedServices() (*RelatedServicesWatcher, error)
(*RelatedServicesWatcher) Changes() <-chan RelatedServicesChange

// For use by the unit agent (per-relation)
(*Unit) AgentJoin(*RelatedService) (*AgentRelation, error)
(*AgentRelation) Changes() <-chan RelatedUnitsChange
(*AgentRelation) Settings() (*ConfigNode, error)
(*AgentRelation) Depart() error
(*AgentRelation) Abscond() error

Note in particular that we end up with a very helpful symetry on AgentRelation
-- an AgentJoin will lead to a -joined on the counterpart, a write to Settings
will lead to a -changed, and a call to Depart will lead to a -departed. (A call
to Abscond will eventually lead to a -departed, but the purpose of that method
is to sneak away without detection in the hope that the agent will replace
itself before anyone else notices it's gone).

None of this includes unit state or unit relation state, which I think are
separate problems, and which I don't think are directly related here.
Sign in to reply to this message.

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