Making all operations synchronous

This commit is contained in:
nikhiljindal
2015-01-21 21:20:57 -08:00
parent 790a78415e
commit de60600608
15 changed files with 117 additions and 527 deletions

View File

@@ -39,7 +39,7 @@ import (
// specialParams lists parameters that are handled specially and which users of Request
// are therefore not allowed to set manually.
var specialParams = util.NewStringSet("sync", "timeout")
var specialParams = util.NewStringSet("timeout")
// PollFunc is called when a server operation returns 202 accepted. The name of the
// operation is extracted from the response and passed to this function. Return a
@@ -107,7 +107,6 @@ type Request struct {
resource string
resourceName string
selector labels.Selector
sync bool
timeout time.Duration
// output
@@ -177,15 +176,6 @@ func (r *Request) Name(resourceName string) *Request {
return r
}
// Sync sets sync/async call status by setting the "sync" parameter to "true"/"false".
func (r *Request) Sync(sync bool) *Request {
if r.err != nil {
return r
}
r.sync = sync
return r
}
// Namespace applies the namespace scope to a request (<resource>/[ns/<namespace>/]<name>)
func (r *Request) Namespace(namespace string) *Request {
if r.err != nil {
@@ -270,7 +260,7 @@ func (r *Request) setParam(paramName, value string) *Request {
}
// Timeout makes the request use the given duration as a timeout. Sets the "timeout"
// parameter. Ignored if sync=false.
// parameter.
func (r *Request) Timeout(d time.Duration) *Request {
if r.err != nil {
return r
@@ -359,13 +349,9 @@ func (r *Request) finalURL() string {
query.Add("namespace", r.namespace)
}
// sync and timeout are handled specially here, to allow setting them
// in any order.
if r.sync {
query.Add("sync", "true")
if r.timeout != 0 {
query.Add("timeout", r.timeout.String())
}
// timeout is handled specially here.
if r.timeout != 0 {
query.Add("timeout", r.timeout.String())
}
finalURL.RawQuery = query.Encode()
return finalURL.String()