func (app *localAppConn) EchoAsync(msg string) *tmspcli.ReqRes { app.Callback( tmsp.RequestEcho(msg), tmsp.ResponseEcho(msg), ) return nil // TODO maybe create a ReqRes }
func handleRequest(app types.Application, req *types.Request, responses chan<- *types.Response) { switch req.Type { case types.MessageType_Echo: responses <- types.ResponseEcho(string(req.Data)) case types.MessageType_Flush: responses <- types.ResponseFlush() case types.MessageType_Info: data := app.Info() responses <- types.ResponseInfo(data) case types.MessageType_SetOption: logStr := app.SetOption(req.Key, req.Value) responses <- types.ResponseSetOption(logStr) case types.MessageType_AppendTx: code, result, logStr := app.AppendTx(req.Data) responses <- types.ResponseAppendTx(code, result, logStr) case types.MessageType_CheckTx: code, result, logStr := app.CheckTx(req.Data) responses <- types.ResponseCheckTx(code, result, logStr) case types.MessageType_Commit: hash, logStr := app.Commit() responses <- types.ResponseCommit(hash, logStr) case types.MessageType_Query: code, result, logStr := app.Query(req.Data) responses <- types.ResponseQuery(code, result, logStr) default: responses <- types.ResponseException("Unknown request") } }