예제 #1
0
파일: logger.go 프로젝트: st3v/fakesandra
func Logger(log func(...interface{})) proto.QueryHandler {
	return proto.QueryHandlerFunc(
		func(qry string, req proto.Frame, rw proto.ResponseWriter) {
			log(fmt.Sprintf("Received query: %s", qry))
		},
	)
}
예제 #2
0
파일: handler.go 프로젝트: st3v/fakesandra
func (qfm *queryFrameHandler) Prepend(handler proto.QueryHandler) {
	next := qfm.queryHandler
	qfm.queryHandler = proto.QueryHandlerFunc(
		func(qry string, req proto.Frame, rw proto.ResponseWriter) {
			handler.ServeQuery(qry, req, rw)
			next.ServeQuery(qry, req, rw)
		},
	)
}
예제 #3
0
파일: handler.go 프로젝트: st3v/fakesandra
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