func readValueToTxn(r *bufio.Reader, txn *ybc.SetTxn, size int) bool { n, err := txn.ReadFrom(r) if err != nil { log.Printf("Error when reading payload with size=[%d]: [%s]", size, err) return false } if n != int64(size) { log.Printf("Unexpected payload size=[%d]. Expected [%d]", n, size) return false } return matchCrLf(r) }
func readValueToTxnAndWriteResponse(c *bufio.ReadWriter, txn *ybc.SetTxn, size int, noreply bool) bool { if txn == nil { return false } if !readValueToTxn(c.Reader, txn, size) { txn.Rollback() return false } if err := txn.Commit(); err != nil { log.Fatalf("Unexpected error returned from SetTxn.Commit(): [%s]", err) } return writeSetResponse(c.Writer, noreply) }
func readValueAndWriteResponse(c *bufio.ReadWriter, txn *ybc.SetTxn, size int, noreply bool) bool { n, err := txn.ReadFrom(c.Reader) if err != nil { log.Printf("Error when reading payload with size=[%d]: [%s]", size, err) return false } if n != int64(size) { log.Printf("Unexpected payload size=[%d]. Expected [%d]", n, size) return false } if !matchCrLf(c.Reader) { return false } if noreply { return true } return writeStr(c.Writer, strStored) && writeCrLf(c.Writer) }