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

Delta Between Two Patch Sets: state/api/uniter/relationunit.go

Issue 78890043: state/api: implement APIHostPorts methods
Left Patch Set: Created 11 years ago
Right Patch Set: state/api: implement APIHostPorts methods Created 11 years 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 | « state/api/uniter/charm.go ('k') | state/api/uniter/service.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 // Copyright 2013 Canonical Ltd. 1 // Copyright 2013 Canonical Ltd.
2 // Licensed under the AGPLv3, see LICENCE file for details. 2 // Licensed under the AGPLv3, see LICENCE file for details.
3 3
4 package uniter 4 package uniter
5 5
6 import ( 6 import (
7 "fmt" 7 "fmt"
8 8
9 "launchpad.net/juju-core/names" 9 "launchpad.net/juju-core/names"
10 "launchpad.net/juju-core/state/api/params" 10 "launchpad.net/juju-core/state/api/params"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 // settings, because uniter only uses this to supply the unit's private 68 // settings, because uniter only uses this to supply the unit's private
69 // address, but this is not done at the server-side by the API. 69 // address, but this is not done at the server-side by the API.
70 func (ru *RelationUnit) EnterScope() error { 70 func (ru *RelationUnit) EnterScope() error {
71 var result params.ErrorResults 71 var result params.ErrorResults
72 args := params.RelationUnits{ 72 args := params.RelationUnits{
73 RelationUnits: []params.RelationUnit{{ 73 RelationUnits: []params.RelationUnit{{
74 Relation: ru.relation.tag, 74 Relation: ru.relation.tag,
75 Unit: ru.unit.tag, 75 Unit: ru.unit.tag,
76 }}, 76 }},
77 } 77 }
78 » err := ru.st.caller.Call("Uniter", "", "EnterScope", args, &result) 78 » err := ru.st.call("EnterScope", args, &result)
79 if err != nil { 79 if err != nil {
80 return err 80 return err
81 } 81 }
82 return result.OneError() 82 return result.OneError()
83 } 83 }
84 84
85 // LeaveScope signals that the unit has left its scope in the relation. 85 // LeaveScope signals that the unit has left its scope in the relation.
86 // After the unit has left its relation scope, it is no longer a member 86 // After the unit has left its relation scope, it is no longer a member
87 // of the relation; if the relation is dying when its last member unit 87 // of the relation; if the relation is dying when its last member unit
88 // leaves, it is removed immediately. It is not an error to leave a scope 88 // leaves, it is removed immediately. It is not an error to leave a scope
89 // that the unit is not, or never was, a member of. 89 // that the unit is not, or never was, a member of.
90 func (ru *RelationUnit) LeaveScope() error { 90 func (ru *RelationUnit) LeaveScope() error {
91 var result params.ErrorResults 91 var result params.ErrorResults
92 args := params.RelationUnits{ 92 args := params.RelationUnits{
93 RelationUnits: []params.RelationUnit{{ 93 RelationUnits: []params.RelationUnit{{
94 Relation: ru.relation.tag, 94 Relation: ru.relation.tag,
95 Unit: ru.unit.tag, 95 Unit: ru.unit.tag,
96 }}, 96 }},
97 } 97 }
98 » err := ru.st.caller.Call("Uniter", "", "LeaveScope", args, &result) 98 » err := ru.st.call("LeaveScope", args, &result)
99 if err != nil { 99 if err != nil {
100 return err 100 return err
101 } 101 }
102 return result.OneError() 102 return result.OneError()
103 } 103 }
104 104
105 // Settings returns a Settings which allows access to the unit's settings 105 // Settings returns a Settings which allows access to the unit's settings
106 // within the relation. 106 // within the relation.
107 func (ru *RelationUnit) Settings() (*Settings, error) { 107 func (ru *RelationUnit) Settings() (*Settings, error) {
108 var results params.RelationSettingsResults 108 var results params.RelationSettingsResults
109 args := params.RelationUnits{ 109 args := params.RelationUnits{
110 RelationUnits: []params.RelationUnit{{ 110 RelationUnits: []params.RelationUnit{{
111 Relation: ru.relation.tag, 111 Relation: ru.relation.tag,
112 Unit: ru.unit.tag, 112 Unit: ru.unit.tag,
113 }}, 113 }},
114 } 114 }
115 » err := ru.st.caller.Call("Uniter", "", "ReadSettings", args, &results) 115 » err := ru.st.call("ReadSettings", args, &results)
116 if err != nil { 116 if err != nil {
117 return nil, err 117 return nil, err
118 } 118 }
119 if len(results.Results) != 1 { 119 if len(results.Results) != 1 {
120 return nil, fmt.Errorf("expected one result, got %d", len(result s.Results)) 120 return nil, fmt.Errorf("expected one result, got %d", len(result s.Results))
121 } 121 }
122 result := results.Results[0] 122 result := results.Results[0]
123 if result.Error != nil { 123 if result.Error != nil {
124 return nil, result.Error 124 return nil, result.Error
125 } 125 }
(...skipping 10 matching lines...) Expand all
136 func (ru *RelationUnit) ReadSettings(uname string) (params.RelationSettings, err or) { 136 func (ru *RelationUnit) ReadSettings(uname string) (params.RelationSettings, err or) {
137 tag := names.UnitTag(uname) 137 tag := names.UnitTag(uname)
138 var results params.RelationSettingsResults 138 var results params.RelationSettingsResults
139 args := params.RelationUnitPairs{ 139 args := params.RelationUnitPairs{
140 RelationUnitPairs: []params.RelationUnitPair{{ 140 RelationUnitPairs: []params.RelationUnitPair{{
141 Relation: ru.relation.tag, 141 Relation: ru.relation.tag,
142 LocalUnit: ru.unit.tag, 142 LocalUnit: ru.unit.tag,
143 RemoteUnit: tag, 143 RemoteUnit: tag,
144 }}, 144 }},
145 } 145 }
146 » err := ru.st.caller.Call("Uniter", "", "ReadRemoteSettings", args, &resu lts) 146 » err := ru.st.call("ReadRemoteSettings", args, &results)
147 if err != nil { 147 if err != nil {
148 return nil, err 148 return nil, err
149 } 149 }
150 if len(results.Results) != 1 { 150 if len(results.Results) != 1 {
151 return nil, fmt.Errorf("expected one result, got %d", len(result s.Results)) 151 return nil, fmt.Errorf("expected one result, got %d", len(result s.Results))
152 } 152 }
153 result := results.Results[0] 153 result := results.Results[0]
154 if result.Error != nil { 154 if result.Error != nil {
155 return nil, result.Error 155 return nil, result.Error
156 } 156 }
157 return result.Settings, nil 157 return result.Settings, nil
158 } 158 }
159 159
160 // Watch returns a watcher that notifies of changes to counterpart 160 // Watch returns a watcher that notifies of changes to counterpart
161 // units in the relation. 161 // units in the relation.
162 func (ru *RelationUnit) Watch() (watcher.RelationUnitsWatcher, error) { 162 func (ru *RelationUnit) Watch() (watcher.RelationUnitsWatcher, error) {
163 var results params.RelationUnitsWatchResults 163 var results params.RelationUnitsWatchResults
164 args := params.RelationUnits{ 164 args := params.RelationUnits{
165 RelationUnits: []params.RelationUnit{{ 165 RelationUnits: []params.RelationUnit{{
166 Relation: ru.relation.tag, 166 Relation: ru.relation.tag,
167 Unit: ru.unit.tag, 167 Unit: ru.unit.tag,
168 }}, 168 }},
169 } 169 }
170 » err := ru.st.caller.Call("Uniter", "", "WatchRelationUnits", args, &resu lts) 170 » err := ru.st.call("WatchRelationUnits", args, &results)
171 if err != nil { 171 if err != nil {
172 return nil, err 172 return nil, err
173 } 173 }
174 if len(results.Results) != 1 { 174 if len(results.Results) != 1 {
175 return nil, fmt.Errorf("expected one result, got %d", len(result s.Results)) 175 return nil, fmt.Errorf("expected one result, got %d", len(result s.Results))
176 } 176 }
177 result := results.Results[0] 177 result := results.Results[0]
178 if result.Error != nil { 178 if result.Error != nil {
179 return nil, result.Error 179 return nil, result.Error
180 } 180 }
181 w := watcher.NewRelationUnitsWatcher(ru.st.caller, result) 181 w := watcher.NewRelationUnitsWatcher(ru.st.caller, result)
182 return w, nil 182 return w, nil
183 } 183 }
LEFTRIGHT

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