rpcreflect

package
v0.0.0-...-4bd6544 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2016 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMethodNotFound = errors.New("no such method")

Functions

This section is empty.

Types

type CallNotImplementedError

type CallNotImplementedError struct {
	RootMethod string
	Version    int
	Method     string
}

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

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(objId string, arg reflect.Value) (reflect.Value, error)
}

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. If the method does
	// not return a value, the returned value will not be valid.
	Call func(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

func ObjTypeOf(objType reflect.Type) *ObjType

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

func (t *ObjType) DiscardedMethods() []string

DiscardedMethods returns the names of all methods that cannot implement RPC calls because their type signature is inappropriate.

func (*ObjType) GoType

func (t *ObjType) GoType() reflect.Type

func (*ObjType) Method

func (t *ObjType) Method(name string) (ObjMethod, 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 (*ObjType) MethodNames

func (t *ObjType) MethodNames() []string

MethodNames returns the names of all the RPC methods defined on the type.

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

func TypeOf(goType reflect.Type) *Type

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 (r *Type) DiscardedMethods() []string

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

func (r *Type) MethodNames() []string

MethodNames returns the names of all the root object methods on the receiving object.

type Value

type Value struct {
	// contains filtered or unexported fields
}

methodCaller holds the value of the root of an RPC server that can call methods directly on a Go value.

func ValueOf

func ValueOf(rootValue reflect.Value) Value

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.

func (Value) GoValue

func (v Value) GoValue() reflect.Value

GoValue returns the value that was passed to ValueOf to create v.

func (Value) IsValid

func (v Value) IsValid() bool

IsValid returns whether the Value has been initialized with ValueOf.

func (Value) Kill

func (v Value) Kill()

Kill implements rpc.Killer.Kill by calling Kill on the root value if it implements Killer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL