Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry provides the available RPC receivers
func (*Registry) Register ¶
Register publishes in the server the set of methods of the receiver value that satisfy the following conditions:
- exported method of exported type
- two arguments, both of exported type
- the second argument is a pointer
- one return value, of type error
It returns an error if the receiver is not an exported type or has no suitable methods. It also logs the error using package log. The client accesses each method using a string of the form "Type.Method", where Type is the receiver's concrete type.
func (*Registry) RegisterName ¶
RegisterName is like Register but uses the provided name for the type instead of the receiver's concrete type.
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session is a bi-direction RPC connection.
Example ¶
var conn io.ReadWriteCloser // Create a registry, and register your available services registry := NewRegistry() registry.Register(&Service{}) // TODO: Establish your connection before passing it to the session // Create a new session session, err := NewSession(conn, Yin, registry, 0) if err != nil { log.Fatal(err) } // Clean up session resources defer func() { if err := session.Close(); err != nil { log.Fatal(err) } }() // Start the event loop, this is a blocking call, so place it in a goroutine // if you need to move on. The call will return when the connection is // terminated. if err = session.Serve(); err != nil { log.Fatal(err) }
Output:
func NewSession ¶
func NewSession(conn io.ReadWriteCloser, yinOrYang YinYang, registry *Registry, bufferPoolSize int) (*Session, error)
NewSession creates a new session.
func (*Session) Call ¶
Call invokes the named function, waits for it to complete, and returns its error status.
func (*Session) Go ¶
func (s *Session) Go(serviceMethod string, args interface{}, reply interface{}, done chan *rpc.Call) *rpc.Call
Go invokes the function asynchronously. It returns the Call structure representing the invocation. The done channel will signal when the call is complete by returning the same Call object. If done is nil, Go will allocate a new channel. If non-nil, done must be buffered or Go will deliberately crash.