Esempio n. 1
0
func Logger(log func(...interface{}), next proto.FrameHandler) proto.FrameHandler {
	return proto.FrameHandlerFunc(func(req proto.Frame, rw proto.ResponseWriter) {
		log(fmt.Sprintf("Read: %s", req))
		next.ServeCQL(req, &responseLogger{rw, log})
	})
}
Esempio n. 2
0
package v3

import (
	"bytes"

	"github.com/st3v/fakesandra/cql/proto"
)

var StartupFrameHandler = proto.FrameHandlerFunc(startupFrameHandler)

var QueryFrameHandler = NewQueryFrameHandler(ResultVoidHandler)

var ResultVoidHandler = proto.QueryHandlerFunc(resultVoidHandler)

func resultVoidHandler(qry string, req proto.Frame, rw proto.ResponseWriter) {
	rw.WriteFrame(ResultVoidResponse(req))
}

func startupFrameHandler(req proto.Frame, rw proto.ResponseWriter) {
	// log.Println("Received STARTUP request")
	rw.WriteFrame(ReadyResponse(req))
}

func NewQueryFrameHandler(handler proto.QueryHandler) *queryFrameHandler {
	return &queryFrameHandler{
		queryHandler: handler,
	}
}

type queryFrameHandler struct {
	queryHandler proto.QueryHandler