Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrMethodNotFound = errors.New("no such method")
Functions ¶
This section is empty.
Types ¶
type CallNotImplementedError ¶
CallNotImplementedError is the error returned when an attempt to call to an unknown API method is made.
func (*CallNotImplementedError) Error ¶
func (e *CallNotImplementedError) Error() string
Error implements the error interface.
type MethodCaller ¶
type MethodCaller interface { // ParamsType holds the required type of the parameter to the object method. ParamsType() reflect.Type // ResultType holds the result type of the result of calling the object method. ResultType() reflect.Type // Call is actually placing a call to instantiate an given instance and // call the method on that instance. Call(ctx context.Context, objId string, arg reflect.Value) (reflect.Value, error) }
MethodCaller represents a method that can be called on a facade object.
type ObjMethod ¶
type ObjMethod struct { // Params holds the argument type of the method, or nil // if there is no argument. Params reflect.Type // Result holds the return type of the method, or nil // if the method returns no value. Result reflect.Type // Call calls the method with the given argument // on the given receiver value, and given context // if the method has a context parameter. If the // method does not return a value, the returned // value will not be valid. Call func(ctx context.Context, rcvr, arg reflect.Value) (reflect.Value, error) }
ObjMethod holds information about an RPC method on an object returned by a root-level method.
type ObjType ¶
type ObjType struct {
// contains filtered or unexported fields
}
ObjType holds information on RPC methods implemented on an RPC object.
func ObjTypeOf ¶
ObjTypeOf returns information on all RPC methods implemented by an object of the given Go type, as returned from a root-level method. If objType is nil, it returns nil.
func (*ObjType) DiscardedMethods ¶
DiscardedMethods returns the names of all methods that cannot implement RPC calls because their type signature is inappropriate.
func (*ObjType) Method ¶
Method returns information on the method with the given name, or the zero Method and ErrMethodNotFound if there is no such method (the only possible error).
func (*ObjType) MethodNames ¶
MethodNames returns the names of all the RPC methods defined on the type.
func (*ObjType) RemoveMethod ¶
RemoveMethod removes the method with the given name from the type. This is useful for removing methods that are not supported by the server. It returns whether the method was found.
type RootMethod ¶
type RootMethod struct { // Call invokes the method. The rcvr parameter must be // the same type as the root object. The given id is passed // as an argument to the method. Call func(rcvr reflect.Value, id string) (reflect.Value, error) // Methods holds RPC object-method information about // objects returned from the above call. ObjType *ObjType }
RootMethod holds information on a root-level method.
type Type ¶
type Type struct {
// contains filtered or unexported fields
}
Type holds information about a type that implements RPC server methods, a root-level RPC type.
func TypeOf ¶
TypeOf returns information on all root-level RPC methods implemented by an object of the given Go type. If goType is nil, it returns nil.
func (*Type) DiscardedMethods ¶
func (*Type) Method ¶
func (r *Type) Method(name string) (RootMethod, error)
Method returns information on the method with the given name, or the zero Method and ErrMethodNotFound if there is no such method (the only possible error).
func (*Type) MethodNames ¶
MethodNames returns the names of all the root object methods on the receiving object.
func (*Type) RemoveMethod ¶
RemoveMethod removes the method with the given name from the type. This is useful for removing methods that are not supported by the server. It returns whether the method was found.
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
Value holds the value of the root of an RPC server that can call methods directly on a Go value.
func ValueOf ¶
ValueOf returns a value that can be used to call RPC-style methods on the given root value. It returns the zero Value if rootValue.IsValid is false.
func (Value) FindMethod ¶
func (v Value) FindMethod(rootMethodName string, version int, objMethodName string) (MethodCaller, error)
FindMethod returns an object that can be used to make calls on the given root value to the given root method and object method. It returns an error if either the root method or the object method were not found. It panics if called on the zero Value. The version argument is ignored - all versions will find the same method.