Documentation ¶
Index ¶
- Constants
- func NewServerCodec(conn io.ReadWriteCloser) adapter.ServerCodec
- type Server
- func (server *Server) Accept(lis net.Listener)
- func (server *Server) Register(rcvr any) error
- func (server *Server) RegisterName(name string, rcvr any) error
- func (server *Server) ServeCodec(codec adapter.ServerCodec)
- func (server *Server) ServeConn(conn io.ReadWriteCloser)
- func (server *Server) ServeRequest(codec adapter.ServerCodec) error
Constants ¶
const ( // Defaults used by HandleHTTP DefaultRPCPath = "/_goRPC_" DefaultDebugPath = "/debug/rpc" )
Variables ¶
This section is empty.
Functions ¶
func NewServerCodec ¶
func NewServerCodec(conn io.ReadWriteCloser) adapter.ServerCodec
NewServerCodec returns a new rpc.ServerCodec using JSON-RPC on conn.
Types ¶
type Server ¶
type Server struct { Middlewares []adapter.ServerMiddleware Finalizers []adapter.ServerFinalizer // contains filtered or unexported fields }
Server represents an RPC Server.
func (*Server) Accept ¶
Accept accepts connections on the listener and serves requests for each incoming connection. Accept blocks until the listener returns a non-nil error. The caller typically invokes Accept in a go statement.
func (*Server) 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 (*Server) RegisterName ¶
RegisterName is like Register but uses the provided name for the type instead of the receiver's concrete type.
func (*Server) ServeCodec ¶
func (server *Server) ServeCodec(codec adapter.ServerCodec)
ServeCodec is like ServeConn but uses the specified codec to decode requests and encode responses.
func (*Server) ServeConn ¶
func (server *Server) ServeConn(conn io.ReadWriteCloser)
ServeConn runs the server on a single connection. ServeConn blocks, serving the connection until the client hangs up. The caller typically invokes ServeConn in a go statement. ServeConn uses the gob wire format (see package gob) on the connection. To use an alternate codec, use ServeCodec. See NewClient's comment for information about concurrent access.
func (*Server) ServeRequest ¶
func (server *Server) ServeRequest(codec adapter.ServerCodec) error
ServeRequest is like ServeCodec but synchronously serves a single request. It does not close the codec upon completion.