Permalink
Browse files

add peek as get option

  • Loading branch information...
1 parent a70793f commit 7e3550c07bf68922a16b81ffa95aad42a23f9595 @erikfrey erikfrey committed Aug 17, 2012
Showing with 8 additions and 3 deletions.
  1. +1 −1 README.md
  2. +1 −0 include/darner/net/request.h
  3. +5 −2 src/net/handler.cpp
  4. +1 −0 src/net/request.cpp
View
@@ -62,4 +62,4 @@ Voila! By default, Darner listens on port 22133.
Darner follows the same protocol as [Kestrel](/robey/kestrel/blob/master/docs/guide.md#memcache), which is the memcache
protocol.
-Currently missing from the Darner implementation but TODO: `/peek`, `FLUSH`, `FLUSH_ALL`, `DELETE`, and some stats.
+Currently missing from the Darner implementation but TODO: `FLUSH`, `FLUSH_ALL`, `DELETE`, and some stats.
@@ -26,6 +26,7 @@ struct request
std::string queue;
size_t num_bytes;
bool get_open;
+ bool get_peek;
bool get_close;
bool get_abort;
size_t wait_ms;
View
@@ -157,9 +157,12 @@ void handler::set_on_read_chunk(const system::error_code& e, size_t bytes_transf
void handler::get()
{
- if (req_.get_abort && (req_.get_open || req_.get_close))
+ if (req_.get_abort && (req_.get_open || req_.get_close || req_.get_peek))
return error("abort must be by itself", "CLIENT_ERROR");
+ if (req_.get_peek && req_.get_open)
+ return error("cannot open and peek", "CLIENT_ERROR");
+
if (req_.get_abort || req_.get_close)
{
try
@@ -228,7 +231,7 @@ void handler::get_on_write_chunk(const boost::system::error_code& e, size_t byte
{
try
{
- pop_stream_.close(true);
+ pop_stream_.close(!req_.get_peek);
}
catch (const system::system_error& ex)
{
View
@@ -36,6 +36,7 @@ request_grammar::request_grammar()
get_option =
lit("/open") [phoenix::ref(req.get_open) = true]
+ | lit("/peek") [phoenix::ref(req.get_peek) = true]
| lit("/close") [phoenix::ref(req.get_close) = true]
| lit("/abort") [phoenix::ref(req.get_abort) = true]
| (

0 comments on commit 7e3550c

Please sign in to comment.