|
@@ -1169,13 +1169,9 @@ func (vh *VHostInfo) checkThrottle(cooldown time.Duration) (err error) {
|
1169
|
1169
|
// callback type implementing the actual business logic of vhost operations
|
1170
|
1170
|
type vhostMunger func(input VHostInfo) (output VHostInfo, err error)
|
1171
|
1171
|
|
1172
|
|
-func (am *AccountManager) VHostSet(account string, vhost string, cooldown time.Duration) (result VHostInfo, err error) {
|
|
1172
|
+func (am *AccountManager) VHostSet(account string, vhost string) (result VHostInfo, err error) {
|
1173
|
1173
|
munger := func(input VHostInfo) (output VHostInfo, err error) {
|
1174
|
1174
|
output = input
|
1175
|
|
- err = output.checkThrottle(cooldown)
|
1176
|
|
- if err != nil {
|
1177
|
|
- return
|
1178
|
|
- }
|
1179
|
1175
|
output.Enabled = true
|
1180
|
1176
|
output.ApprovedVHost = vhost
|
1181
|
1177
|
return
|
|
@@ -1205,6 +1201,29 @@ func (am *AccountManager) VHostRequest(account string, vhost string, cooldown ti
|
1205
|
1201
|
return am.performVHostChange(account, munger)
|
1206
|
1202
|
}
|
1207
|
1203
|
|
|
1204
|
+func (am *AccountManager) VHostTake(account string, vhost string, cooldown time.Duration) (result VHostInfo, err error) {
|
|
1205
|
+ munger := func(input VHostInfo) (output VHostInfo, err error) {
|
|
1206
|
+ output = input
|
|
1207
|
+
|
|
1208
|
+ // if you have a request pending, you can cancel it using take;
|
|
1209
|
+ // otherwise, you're subject to the same throttling as if you were making a request
|
|
1210
|
+ if output.RequestedVHost == "" {
|
|
1211
|
+ err = output.checkThrottle(cooldown)
|
|
1212
|
+ }
|
|
1213
|
+ if err != nil {
|
|
1214
|
+ return
|
|
1215
|
+ }
|
|
1216
|
+ output.ApprovedVHost = vhost
|
|
1217
|
+ output.RequestedVHost = ""
|
|
1218
|
+ output.RejectedVHost = ""
|
|
1219
|
+ output.RejectionReason = ""
|
|
1220
|
+ output.LastRequestTime = time.Now().UTC()
|
|
1221
|
+ return
|
|
1222
|
+ }
|
|
1223
|
+
|
|
1224
|
+ return am.performVHostChange(account, munger)
|
|
1225
|
+}
|
|
1226
|
+
|
1208
|
1227
|
func (am *AccountManager) VHostApprove(account string) (result VHostInfo, err error) {
|
1209
|
1228
|
munger := func(input VHostInfo) (output VHostInfo, err error) {
|
1210
|
1229
|
output = input
|