clacks

package module
v0.0.0-...-4acf114 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2014 License: GPL-3.0 Imports: 16 Imported by: 0

README

clacks

Documentation

Index

Constants

View Source
const (
	R_RPC  = iota //Normal RPC request
	R_PUSH        //Push async data to client
	R_DATA        //Send data to client
)
View Source
const (
	RPCPath = "/RPC"
)

Variables

View Source
var ErrShutdown = errors.New("connection is shut down")

Functions

This section is empty.

Types

type Call

type Call struct {
	Method string        // The name of the service and method to call.
	Args   []interface{} // The argument to the function (*struct).
	Error  error         // After completion, the error status.
	Done   chan *Call    // Strobes when call is complete.
}

type CallbackId

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

type CallbackManager

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

func (*CallbackManager) SendToAll

func (cbmgr *CallbackManager) SendToAll(arg interface{})

Execute all subscribed functions to a push message

func (*CallbackManager) Subscribe

func (cbmgr *CallbackManager) Subscribe(cb interface{}) (CallbackId, error)

Subscribe to pushed messages from the server

func (*CallbackManager) Unsubscribe

func (cbmgr *CallbackManager) Unsubscribe(sid CallbackId)

Unsubscribe to pushed messages from the server

type Client

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

func Dial

func Dial(network string, address string) (*Client, error)

func DialHTTP

func DialHTTP(network, address string) (*Client, error)

DialHTTP connects to an HTTP RPC server at the specified network address listening on the default HTTP RPC path.

func DialHTTPPath

func DialHTTPPath(network, address, path string) (*Client, error)

DialHTTPPath connects to an HTTP RPC server at the specified network address and path.

func NewClient

func NewClient(conn io.ReadWriteCloser) *Client

It adds a buffer to the write side of the connection so the header and payload are sent as a unit.

func NewClientWithCodec

func NewClientWithCodec(codec Codec) *Client

func (*Client) Call

func (client *Client) Call(serviceMethod string, args ...interface{}) error

Call invokes the named function, waits for it to complete, and returns its error status.

func (*Client) Close

func (client *Client) Close() error

func (*Client) Go

func (client *Client) Go(done chan *Call, serviceMethod string, args ...interface{}) *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.

func (*Client) SubscribeToDisconnect

func (client *Client) SubscribeToDisconnect(cb func(*Client)) error

func (*Client) SubscribeToPush

func (client *Client) SubscribeToPush(cb interface{}) error

type Codec

type Codec interface {
	Register(interface{})
	WriteRequest(*Request, interface{}) error
	WriteResponse(*Response, interface{}) error
	ReadRequestHeader(*Request) error
	ReadResponseHeader(*Response) error
	ReadBody(interface{}) error
	Close() error
}

func GenerateCodec

func GenerateCodec(conn io.ReadWriteCloser) Codec

type Context

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

func NewContext

func NewContext() *Context

func (*Context) Done

func (me *Context) Done() <-chan struct{}

func (*Context) GetCancelFunc

func (me *Context) GetCancelFunc() context.CancelFunc

Get a Cancellation function for this context

func (*Context) GetClientAddr

func (me *Context) GetClientAddr() net.Addr

Get client IP from context

func (*Context) GetClientId

func (me *Context) GetClientId() uint64

Get the client id

func (*Context) GetValue

func (me *Context) GetValue(key interface{}) interface{}

Retrieve the value for a key

func (*Context) SetValue

func (me *Context) SetValue(key interface{}, value interface{})

Set a value for a key

type ReCache

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

type Registry

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

func (*Registry) GetServiceMethod

func (registry *Registry) GetServiceMethod(serviceName string, methodName string) (service *serviceData, method *methodData)

func (*Registry) Register

func (registry *Registry) Register(rcvr interface{}) error

func (*Registry) RegisterType

func (registry *Registry) RegisterType(val interface{})

func (*Registry) RegisterWithName

func (registry *Registry) RegisterWithName(rcvr interface{}, sname string) error

type Request

type Request struct {
	Method string
	Seq    uint64
	// contains filtered or unexported fields
}

type Response

type Response struct {
	Type  uint8
	Seq   uint64
	Error string
	// contains filtered or unexported fields
}

type Server

type Server struct {
	ReCache
	// contains filtered or unexported fields
}

func NewServer

func NewServer() *Server

func (*Server) Accept

func (server *Server) Accept(lis net.Listener)

Accept accepts connections on the listener and serves requests for each incoming connection. Accept blocks; the caller typically invokes it in a go statement.

func (*Server) CodecFunc

func (server *Server) CodecFunc(c codecFunc)

func (*Server) ContextFunc

func (server *Server) ContextFunc(c contextFunc)

func (*Server) HandleHTTP

func (server *Server) HandleHTTP()

This method will bind the different HTTP endpoints to their handlers

func (*Server) ListenAndServe

func (server *Server) ListenAndServe(addr string)

func (*Server) ListenAndServeTLS

func (server *Server) ListenAndServeTLS(addr string, certFile string, keyFile string)

func (*Server) ProcessConnection

func (server *Server) ProcessConnection(conn net.Conn)

func (*Server) Register

func (server *Server) Register(endpoint interface{}) error

func (*Server) ServeHTTP

func (server *Server) ServeHTTP(w http.ResponseWriter, req *http.Request)

HTTP bridge

type ServerError

type ServerError string

ServerError represents an error that has been returned from the remote side of the RPC connection.

func (ServerError) Error

func (e ServerError) Error() string

Jump to

Keyboard shortcuts

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