Documentation ¶
Index ¶
- Constants
- Variables
- func JsonMarshal(v interface{}) []byte
- func JsonUnmarshal(buf []byte, v interface{}) bool
- func MsgpackMarshal(v interface{}) []byte
- func MsgpackMarshalAsArray(v interface{}) []byte
- func MsgpackUnmarshal(buf []byte, v interface{}) bool
- func RegisterError(code uint64, mk func(e *Error) error)
- func RegisterMessage(id uint64, mk func() Message)
- func RegisterStandardMessagesAndErrors(reg *Registry)
- func WriteRequest(w io.Writer, req Request) error
- func WriteResponse(w io.Writer, resp Response) error
- type Client
- func (c *Client) Close()
- func (c *Client) RawSend(oid uint64, paramType uint64, paramData []byte) (Response, error)
- func (c *Client) RawSendCtx(ctx context.Context, oid uint64, paramType uint64, paramData []byte) (Response, error)
- func (c *Client) RawSendParsedReply(reg *Registry, oid uint64, paramType uint64, paramData []byte) (interface{}, error)
- func (c *Client) RawSendParsedReplyCtx(ctx context.Context, reg *Registry, oid uint64, paramType uint64, ...) (interface{}, error)
- func (c *Client) Send(oid uint64, arg Message) (interface{}, error)
- func (c *Client) SendCtx(ctx context.Context, oid uint64, arg Message) (interface{}, error)
- func (c *Client) SendWithReg(reg *Registry, oid uint64, arg Message) (interface{}, error)
- func (c *Client) SendWithRegCtx(ctx context.Context, reg *Registry, oid uint64, arg Message) (interface{}, error)
- type ClientOptions
- type Clunk
- type ConnServer
- func (s *ConnServer) Clunk(oid uint64)
- func (s *ConnServer) Go(f func())
- func (s *ConnServer) HandleRequest(ctx context.Context, r Request, respond RespondFunc)
- func (s *ConnServer) Register(o Object) uint64
- func (s *ConnServer) RegisterBootstrap(o Object)
- func (s *ConnServer) Serve(ctx context.Context, c io.ReadWriteCloser)
- func (s *ConnServer) Wait()
- type ConnServerOptions
- type Error
- type Message
- type Object
- type ObjectRef
- type Ok
- type Registry
- type Request
- type RespondFunc
- type Response
- type Server
- type ServerOptions
Constants ¶
View Source
const ( // From spec TYPE_ERR = 0x81aba3f7522edc6b // From spec TYPE_OK = 0xd4924862b91c639d // From spec TYPE_CLUNK = 0xcf3a50d623ee637d // From spec TYPE_OBJECT_REF = 0xd782cf4b395eca05 // From spec ERRCODE_OBJECT_NOT_EXIST = 0xab0547366de885bc // From spec ERRCODE_UNEXPECTED_MESSAGE = 0xd47d4e94917934b2 ERRCODE_GENERIC = 0 RESERVED_OBJECT_ID = 0 BOOTSTRAP_OBJECT_ID = 1 )
Variables ¶
View Source
var ( ErrBadResponse = errors.New("bad response.") ErrPayloadTooBig = errors.New("payload too big.") ErrRequestCancelled = errors.New("request cancelled.") ErrClientShutdown = errors.New("client has been shutdown.") ErrObjectDoesNotExist = &Error{Code: ERRCODE_OBJECT_NOT_EXIST, Display: "object does not exist."} ErrUnexpectedMessage = &Error{Code: ERRCODE_UNEXPECTED_MESSAGE, Display: "unexpected message."} )
Functions ¶
func JsonMarshal ¶
func JsonMarshal(v interface{}) []byte
func JsonUnmarshal ¶
func MsgpackMarshal ¶
func MsgpackMarshal(v interface{}) []byte
func MsgpackMarshalAsArray ¶
func MsgpackMarshalAsArray(v interface{}) []byte
func MsgpackUnmarshal ¶
func RegisterError ¶
func RegisterMessage ¶
func RegisterStandardMessagesAndErrors ¶
func RegisterStandardMessagesAndErrors(reg *Registry)
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClient ¶
func NewClient(conn io.ReadWriteCloser, options ClientOptions) *Client
func (*Client) RawSendCtx ¶
func (*Client) RawSendParsedReply ¶
func (*Client) RawSendParsedReplyCtx ¶
func (*Client) SendWithReg ¶
type ClientOptions ¶
type Clunk ¶
type Clunk struct{}
func (*Clunk) CoolMsg_Marshal ¶
func (*Clunk) CoolMsg_TypeId ¶
func (*Clunk) CoolMsg_Unmarshal ¶
type ConnServer ¶
type ConnServer struct {
// contains filtered or unexported fields
}
func NewConnServer ¶
func NewConnServer(c io.ReadWriteCloser, options ConnServerOptions) *ConnServer
func (*ConnServer) Clunk ¶
func (s *ConnServer) Clunk(oid uint64)
func (*ConnServer) Go ¶
func (s *ConnServer) Go(f func())
func (*ConnServer) HandleRequest ¶
func (s *ConnServer) HandleRequest(ctx context.Context, r Request, respond RespondFunc)
func (*ConnServer) Register ¶
func (s *ConnServer) Register(o Object) uint64
func (*ConnServer) RegisterBootstrap ¶
func (s *ConnServer) RegisterBootstrap(o Object)
func (*ConnServer) Serve ¶
func (s *ConnServer) Serve(ctx context.Context, c io.ReadWriteCloser)
func (*ConnServer) Wait ¶
func (s *ConnServer) Wait()
type ConnServerOptions ¶
type ConnServerOptions struct { MaxRequestSize uint64 // Each connection will stop reading new // requests if this is exceeded, zero // means unlimited. MaxOutstandingRequests uint64 // This function is used to create the root object // a client can send messages to. // // It takes a connection object as a way for out of band connection // information to be used while creating the root object. // One example is using a unix socket to get the remote user id, // and then using that for authentication. BootstrapFunc func(io.ReadWriteCloser) Object // If nil, defaults to DefaultRegistry Registry *Registry }
type Error ¶
Fields must remain compatible. with spec, Order is significant as Error is marshaled as an array.
func (*Error) CoolMsg_Marshal ¶
func (*Error) CoolMsg_TypeId ¶
func (*Error) CoolMsg_Unmarshal ¶
type Object ¶
type Object interface { Message(context.Context, *ConnServer, Message, RespondFunc) UnknownMessage(context.Context, *ConnServer, uint64, []byte, RespondFunc) Clunk(*ConnServer) }
type ObjectRef ¶
type ObjectRef struct {
Id uint64
}
func (*ObjectRef) CoolMsg_Marshal ¶
func (*ObjectRef) CoolMsg_TypeId ¶
func (*ObjectRef) CoolMsg_Unmarshal ¶
type Ok ¶
type Ok struct{}
func (*Ok) CoolMsg_Marshal ¶
func (*Ok) CoolMsg_TypeId ¶
func (*Ok) CoolMsg_Unmarshal ¶
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
var DefaultRegistry *Registry
func NewRegistry ¶
func NewRegistry() *Registry
func (*Registry) RegisterError ¶
func (*Registry) RegisterMessage ¶
type Request ¶
type RespondFunc ¶
type RespondFunc func(Message)
type Response ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(options ServerOptions) *Server
func (*Server) GoHandle ¶
func (s *Server) GoHandle(c io.ReadWriteCloser)
type ServerOptions ¶
type ServerOptions struct {
ConnOptions ConnServerOptions
}
Click to show internal directories.
Click to hide internal directories.