Documentation ¶
Index ¶
- Constants
- Variables
- type Context
- func (c *Context) AppendCallTrace(traceinfo *proto.TraceInfo)
- func (c *Context) Fail(msg string)
- func (c *Context) GetArgument(msg pb.Message) error
- func (c *Context) GetClientId() string
- func (c *Context) GetDeadline() time.Time
- func (c *Context) GetDeadlineNotifier() <-chan time.Time
- func (c *Context) GetInput() []byte
- func (c *Context) GetTraceInfo() *proto.TraceInfo
- func (c *Context) Return(msg pb.Message) error
- func (c *Context) Success(data []byte)
- type Handler
- type Server
- func (srv *Server) Close()
- func (srv *Server) RegisterHandler(svc, endpoint string, handler Handler) (err error)
- func (srv *Server) SetLameduck(lameduck bool)
- func (srv *Server) SetLoadshed(loadshed bool)
- func (srv *Server) SetMachineName(name string)
- func (cl *Server) SetRPCLogger(l *golog.Logger)
- func (srv *Server) SetTimeout(d time.Duration)
- func (srv *Server) Start() error
- func (srv *Server) Stop() error
- func (srv *Server) UnregisterHandler(svc, endpoint string) (err error)
Constants ¶
const BACKEND_ROUTER_PATH string = "inproc://rpc_backend_router"
const OUTSTANDING_REQUESTS_PER_THREAD uint = 50
Variables ¶
var MAGIC_READY_STRING []byte = []byte("___ReAdY___")
var MAGIC_STOP_STRING []byte = []byte("___STOPBALANCER___")
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct {
// contains filtered or unexported fields
}
Opaque structure that contains request information and takes the response.
func (*Context) AppendCallTrace ¶
Append traceinfo from child call.
func (*Context) GetArgument ¶
GetArgument serializes the input (from GetInput()) in a protocol buffer message.
func (*Context) GetClientId ¶
GetClientId returns the identification that the client sent.
func (*Context) GetDeadline ¶
Get the absolute deadline requested by the caller.
func (*Context) GetDeadlineNotifier ¶
Returns a channel that is sent a value when the deadline of this RPC has passed.
func (*Context) GetTraceInfo ¶
For half-external use, e.g. by the client package. Returns not nil when the current call tree is traced.
type Handler ¶
type Handler (func(*Context))
A function that is called when the corresponding endpoint is requested. Note that it makes sense to use a bound function: RegisterHandler("Service", "Method", server.method) wherein server is an object with associated function method().
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Handles incoming requests and registering of handler functions.
func NewIPCServer ¶
func NewServer ¶
func NewServer(host string, port uint, threads uint, security_manager *smgr.ServerSecurityManager) (*Server, error)
Create server listening on the specified laddr:port. laddr has to be "*" or an IP address, names do not work. There is usually only one server listening per process (though it is possible to use multiple servers on different ports, of course)
worker_threads is the number of workers; however, there are (additionally) at least one load-balancing thread and one ZeroMQ networking thread.
security_manager adds CURVE and IP "authentication" security to the server. If it's nil, do not add security.
Use the setter functions described below before calling Start(), otherwise they might be ignored.
func (*Server) Close ¶
func (srv *Server) Close()
Close internal sockets. The server may not be used after calling Close().
func (*Server) RegisterHandler ¶
Add a new endpoint (i.e. a handler); svc is the "namespace" in which to register the handler, endpoint the name with which the handler can be identified from the outside. The service is created implicitly
err is not nil if the endpoint is already registered.
func (*Server) SetLameduck ¶
A server that is in lameduck mode will respond negatively to health checks but continue serving requests.
func (*Server) SetLoadshed ¶
A server in loadshed mode will refuse any requests immediately.
func (*Server) SetMachineName ¶
Set the machine name as shown in traces (os.Hostname() can be used to obtain the DNS name)
func (*Server) SetRPCLogger ¶
Log all RPCs made by this client to this logging device; either as hex/raw strings or protobuf strings.
func (*Server) SetTimeout ¶
Set timeout for the routers used by the loadbalancer (the worker sockets don't really need a timeout because they're communicating via inproc://)
func (*Server) Start ¶
Starts worker threads. Returns an error if any thread couldn't set up its socket, otherwise it blocks until the server is stopped. The error is logged at any LOGLEVEL.
func (*Server) Stop ¶
Connect to loadbalancer thread and send special stop message. Does not close sockets etc.
func (*Server) UnregisterHandler ¶
Removes an endpoint from the set of served endpoints.
Returns an error value with a description if the endpoint doesn't exist.