Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultHandler ¶
func DefaultHandler(request jute.RecordReader) (zk.Error, jute.RecordWriter)
DefaultHandler returns a default response based on the request received, with no error code.
Types ¶
type HandlerFunc ¶
type HandlerFunc func(reader jute.RecordReader) (zk.Error, jute.RecordWriter)
HandlerFunc is the function the server uses to return a response to the client based on the request received. If an error is present, an error code should be returned. Note that custom handlers need to send a ReplyHeader before a response as per the Zookeeper protocol.
type TestServer ¶
type TestServer struct { ResponseHandler HandlerFunc // contains filtered or unexported fields }
TestServer is a mock Zookeeper server which enables local testing without the need for a Zookeeper instance.
func NewDefaultServer ¶
func NewDefaultServer() (*TestServer, error)
NewDefaultServer creates and starts a new TestServer instance with a default local listener and handler. Started servers should be closed by calling Close.
func NewServer ¶
func NewServer(handler HandlerFunc) (*TestServer, error)
NewServer creates and starts a new TestServer instance with a custom handler. Started servers should be closed by calling Close.
func (*TestServer) Addr ¶
func (s *TestServer) Addr() net.Addr
Addr returns the address on which this test server is listening on.
func (*TestServer) Close ¶
func (s *TestServer) Close() error
Close closes the test server's listener.