Package google :: Package protobuf :: Module service :: Class RpcController
[hide private]
[frames] | no frames]

Class RpcController

source code

object --+
         |
        RpcController

An RpcController mediates a single method call.

The primary purpose of the controller is to provide a way to manipulate settings specific to the RPC implementation and to find out about RPC-level errors. The methods provided by the RpcController interface are intended to be a "least common denominator" set of features which we expect all implementations to support. Specific implementations may provide more advanced features (e.g. deadline propagation).

Instance Methods [hide private]
 
Reset(self)
Resets the RpcController to its initial state.
source code
 
Failed(self)
Returns true if the call failed.
source code
 
ErrorText(self)
If Failed is true, returns a human-readable description of the error.
source code
 
StartCancel(self)
Initiate cancellation.
source code
 
SetFailed(self, reason)
Sets a failure reason.
source code
 
IsCanceled(self)
Checks if the client cancelled the RPC.
source code
 
NotifyOnCancel(self, callback)
Sets a callback to invoke on cancel.
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

Reset(self)

source code 

Resets the RpcController to its initial state.

After the RpcController has been reset, it may be reused in a new call. Must not be called while an RPC is in progress.

Failed(self)

source code 

Returns true if the call failed.

After a call has finished, returns true if the call failed. The possible reasons for failure depend on the RPC implementation. Failed() must not be called before a call has finished. If Failed() returns true, the contents of the response message are undefined.

StartCancel(self)

source code 

Initiate cancellation.

Advises the RPC system that the caller desires that the RPC call be canceled. The RPC system may cancel it immediately, may wait awhile and then cancel it, or may not even cancel the call at all. If the call is canceled, the "done" callback will still be called and the RpcController will indicate that the call failed at that time.

SetFailed(self, reason)

source code 

Sets a failure reason.

Causes Failed() to return true on the client side. "reason" will be incorporated into the message returned by ErrorText(). If you find you need to return machine-readable information about failures, you should incorporate it into your response protocol buffer and should NOT call SetFailed().

IsCanceled(self)

source code 

Checks if the client cancelled the RPC.

If true, indicates that the client canceled the RPC, so the server may as well give up on replying to it. The server should still call the final "done" callback.

NotifyOnCancel(self, callback)

source code 

Sets a callback to invoke on cancel.

Asks that the given callback be called when the RPC is canceled. The callback will always be called exactly once. If the RPC completes without being canceled, the callback will be called after completion. If the RPC has already been canceled when NotifyOnCancel() is called, the callback will be called immediately.

NotifyOnCancel() must be called no more than once per request.