Beispiel #1
0
// SetBroker sets the broker on the handler.
func (h *Handler) SetBroker(b *Broker) {
	h.broker = b

	if b != nil {
		h.raftHandler = raft.NewHTTPHandler(b.log)
	} else {
		h.raftHandler = nil
	}
}
Beispiel #2
0
// Open opens the log and HTTP server.
func (n *Node) Open() {
	// Start the HTTP server.
	n.Server = httptest.NewServer(raft.NewHTTPHandler(n.Log))
	n.Log.URL, _ = url.Parse(n.Server.URL)

	// Open the log.
	if err := n.Log.Open(tempfile()); err != nil {
		panic("open: " + err.Error())
	}
}