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

Delta Between Two Patch Sets: state/relation.go

Issue 6120045: Added ResolvedWatcher for Units. (Closed)
Left Patch Set: Added ResolvedWatcher for Units. Created 12 years, 11 months ago
Right Patch Set: Added ResolvedWatcher for Units. Created 12 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « [revision details] ('k') | state/state.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 package state 1 package state
2 2
3 import () 3 import (
4 » "fmt"
5 )
4 6
5 // RelationRole defines the role of a relation endpoint. 7 // RelationRole defines the role of a relation endpoint.
6 type RelationRole string 8 type RelationRole string
7 9
8 const ( 10 const (
9 RoleProvider RelationRole = "provider" 11 RoleProvider RelationRole = "provider"
10 RoleRequirer RelationRole = "requirer" 12 RoleRequirer RelationRole = "requirer"
11 RolePeer RelationRole = "peer" 13 RolePeer RelationRole = "peer"
12 ) 14 )
13 15
(...skipping 26 matching lines...) Expand all
40 return other.RelationRole == RoleProvider 42 return other.RelationRole == RoleProvider
41 } 43 }
42 panic("endpoint role is undefined") 44 panic("endpoint role is undefined")
43 } 45 }
44 46
45 // String returns the unique identifier of the relation endpoint. 47 // String returns the unique identifier of the relation endpoint.
46 func (e RelationEndpoint) String() string { 48 func (e RelationEndpoint) String() string {
47 return e.ServiceName + ":" + e.RelationName 49 return e.ServiceName + ":" + e.RelationName
48 } 50 }
49 51
52 // checkValues performs basic tests on the endpoint data without
53 // checking the validity of identifiers.
54 func (e *RelationEndpoint) checkValues() error {
55 switch {
56 case e.ServiceName == "":
57 return fmt.Errorf("endpoint has empty service name")
58 case e.Interface == "":
59 return fmt.Errorf("endpoint has empty interface")
60 case e.RelationName == "":
61 return fmt.Errorf("endpoint has empty relation name")
62 case e.RelationRole != RoleProvider && e.RelationRole != RoleRequirer && e.RelationRole != RolePeer:
63 return fmt.Errorf("endpoint has invalid role: %q", e.RelationRol e)
64 case e.RelationScope != ScopeGlobal && e.RelationScope != ScopeContainer :
65 return fmt.Errorf("endpoint has invalid scope: %q", e.RelationSc ope)
66 }
67 return nil
68 }
69
50 // Relation represents a link between services, or within a 70 // Relation represents a link between services, or within a
51 // service (in the case of peer relations). 71 // service (in the case of peer relations).
52 type Relation struct { 72 type Relation struct {
53 st *State 73 st *State
54 key string 74 key string
55 } 75 }
56 76
57 // ServiceRelation represents an established relation from 77 // ServiceRelation represents an established relation from
58 // the viewpoint of a participant service. 78 // the viewpoint of a participant service.
59 type ServiceRelation struct { 79 type ServiceRelation struct {
(...skipping 12 matching lines...) Expand all
72 92
73 // RelationRole returns the service role within the relation.· 93 // RelationRole returns the service role within the relation.·
74 func (r *ServiceRelation) RelationRole() RelationRole { 94 func (r *ServiceRelation) RelationRole() RelationRole {
75 return r.relationRole 95 return r.relationRole
76 } 96 }
77 97
78 // RelationName returns the name this relation has within the service. 98 // RelationName returns the name this relation has within the service.
79 func (r *ServiceRelation) RelationName() string { 99 func (r *ServiceRelation) RelationName() string {
80 return r.relationName 100 return r.relationName
81 } 101 }
LEFTRIGHT

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