示例#1
0
文件: mux.go 项目: st3v/fakesandra
func (opmux *opcodeMux) ServeCQL(req proto.Frame, rw proto.ResponseWriter) {
	handler, found := opmux.Handler(req.Opcode())
	if !found {
		// TODO: write error to ResponseWriter
	}

	handler.ServeCQL(req, rw)
}
示例#2
0
func (qfm *queryFrameHandler) ServeCQL(req proto.Frame, rw proto.ResponseWriter) {
	var qry Query
	if err := readQuery(bytes.NewReader(req.Body()), &qry); err != nil {
		// TODO: write error to ResponseWriter
		return
	}

	qfm.queryHandler.ServeQuery(qry.TrimmedStatement(), req, rw)
}
示例#3
0
func ReadyResponse(request proto.Frame) proto.Frame {
	hdr := header{
		Opcode:   proto.OpReady,
		StreamID: request.StreamID(),
		Length:   0,
	}

	return &frame{
		versionDir: proto.VersionDir(Version) | response,
		header:     hdr,
		body:       make([]byte, 0),
	}
}
示例#4
0
func ResultVoidResponse(request proto.Frame) proto.Frame {
	buf := new(bytes.Buffer)
	proto.WriteBinary(buf, ResultVoid)

	hdr := header{
		Opcode:   proto.OpResult,
		StreamID: request.StreamID(),
		Length:   uint32(buf.Len()),
	}

	return &frame{
		versionDir: proto.VersionDir(Version) | response,
		header:     hdr,
		body:       buf.Bytes(),
	}
}