Documentation ¶
Index ¶
- Constants
- Variables
- func Accept(lis net.Listener)
- func HandleHTTP()
- func NewDebugHTTP(server *Server) http.Handler
- func Register(rcvr any) error
- func RegisterName(name string, rcvr any) error
- func ServeConn(conn io.ReadWriteCloser)
- func ServeRequest(codec ServerCodec) error
- type ARequest
- type AResponse
- type Call
- type Client
- type ClientCodec
- type Request
- type Response
- type Server
- func (server *Server) Accept(lis net.Listener)
- func (server *Server) HandleHTTP(rpcPath, debugPath string)
- func (server *Server) Register(rcvr any) error
- func (server *Server) RegisterName(name string, rcvr any) error
- func (server *Server) ServeConn(codec ServerCodec)
- func (server *Server) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (server *Server) ServeRequest(codec ServerCodec) error
- type ServerCodec
- type ServerError
Constants ¶
View Source
const ( // Defaults used by HandleHTTP DefaultRPCPath = "/_goRPC_" DefaultDebugPath = "/debug/rpc" )
Variables ¶
View Source
var DefaultServer = NewServer()
View Source
var (
ErrShutdown = errors.New("connection is shut down")
)
Functions ¶
func HandleHTTP ¶
func HandleHTTP()
func NewDebugHTTP ¶
func RegisterName ¶
RegisterName is like Register but uses the provided name for the type instead of the receiver's concrete type.
func ServeConn ¶
func ServeConn(conn io.ReadWriteCloser)
func ServeRequest ¶
func ServeRequest(codec ServerCodec) error
Types ¶
type AResponse ¶
type AResponse struct { ServiceMethod string `json:"method"` Seq uint64 `json:"seq"` Error string `json:"error"` }
func (*AResponse) ErrorString ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func DialHTTPPath ¶
DialHTTPPath connects to an HTTP RPC server at the specified network address and path.
func NewClient ¶
func NewClient(codec ClientCodec) *Client
type ClientCodec ¶
type ClientCodec interface { WriteRequest(req Request, payload any) error ReadResponse() (Response, error) ReadPayload(res Response, payload any) error Close() error }
func NewGobClientCodec ¶
func NewGobClientCodec(conn io.ReadWriteCloser) ClientCodec
func NewJSONClientCodec ¶
func NewJSONClientCodec(conn io.ReadWriteCloser) ClientCodec
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) HandleHTTP ¶
func (*Server) ServeConn ¶
func (server *Server) ServeConn(codec ServerCodec)
func (*Server) ServeHTTP ¶
func (server *Server) ServeHTTP(w http.ResponseWriter, req *http.Request)
ServeHTTP implements an http.Handler that answers RPC requests.
func (*Server) ServeRequest ¶
func (server *Server) ServeRequest(codec ServerCodec) error
ServeRequest is like ServeCodec but synchronously serves a single request. It does not close the codec upon completion.
type ServerCodec ¶
type ServerCodec interface { ReadRequest() (Request, error) ReadPayload(req Request, payload any) error WriteResponse(res Response, payload any) error Close() error }
func NewGobServerCodec ¶
func NewGobServerCodec(conn io.ReadWriteCloser) ServerCodec
func NewJSONServerCodec ¶
func NewJSONServerCodec(conn io.ReadWriteCloser) ServerCodec
type ServerError ¶
type ServerError string
func (ServerError) Error ¶
func (e ServerError) Error() string
Source Files ¶
Click to show internal directories.
Click to hide internal directories.