Message from discussion
emit('data') best practice
Received: by 10.204.154.76 with SMTP id n12mr1997220bkw.1.1346734896481;
Mon, 03 Sep 2012 22:01:36 -0700 (PDT)
X-BeenThere: nodejs@googlegroups.com
Received: by 10.204.145.73 with SMTP id c9ls717858bkv.7.gmail; Mon, 03 Sep
2012 22:01:21 -0700 (PDT)
Received: by 10.204.129.81 with SMTP id n17mr1997245bks.3.1346734881864;
Mon, 03 Sep 2012 22:01:21 -0700 (PDT)
Received: by 10.204.129.81 with SMTP id n17mr1997244bks.3.1346734881839;
Mon, 03 Sep 2012 22:01:21 -0700 (PDT)
Return-Path: <rayn...@gmail.com>
Received: from mail-bk0-f43.google.com (mail-bk0-f43.google.com [209.85.214.43])
by gmr-mx.google.com with ESMTPS id q3si3687784bkv.1.2012.09.03.22.01.21
(version=TLSv1/SSLv3 cipher=OTHER);
Mon, 03 Sep 2012 22:01:21 -0700 (PDT)
Received-SPF: pass (google.com: domain of rayn...@gmail.com designates 209.85.214.43 as permitted sender) client-ip=209.85.214.43;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of rayn...@gmail.com designates 209.85.214.43 as permitted sender) smtp.mail=rayn...@gmail.com; dkim=pass header...@gmail.com
Received: by bkty15 with SMTP id y15so3633126bkt.16
for <nodejs@googlegroups.com>; Mon, 03 Sep 2012 22:01:21 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20120113;
h=mime-version:in-reply-to:references:date:message-id:subject:from:to
:content-type;
bh=cxBIsDNrfjBFJLs4aW0dOrdkdHgIoIP2dKScPEVuFTY=;
b=PDN+9LGgkadM1hnBu+ARFRb4AA1jg7W86kNB6ydIVhaXrFCKCIV/gpK63vVCd3nUcR
LqyMo1ooT+4IMLJ2pT6DUU4L0Rp0WteGBBHLQv2katDDjdLXmW5RimFpE8w0EhkzETvZ
ZfVmgNskOgcJDyROqutLTU/tbaI6kEf8chf/+kXi3WmI+0bOMkEd2+AOtWilOg6LzXnh
FxSdtho85Vcpcp5rGxn/CReIY3eHxDzWb/G4NpqfoNVgBrLHzHPjeRntZlC804vDVKFN
ym6v2gFvEiXoO79fokKLa4xMeTqAm7Lq1cUDOMHq+BnxDMRLqkOx+G0zLQOWq22CRtkY
j7Lg==
MIME-Version: 1.0
Received: by 10.204.147.1 with SMTP id j1mr7602280bkv.110.1346734881521; Mon,
03 Sep 2012 22:01:21 -0700 (PDT)
Received: by 10.204.36.12 with HTTP; Mon, 3 Sep 2012 22:01:21 -0700 (PDT)
In-Reply-To: <163310d0-ebed-472e-8620-60f46f6d16cf@googlegroups.com>
References: <c9a7d898-3544-439b-9636-b91c95b95852@googlegroups.com>
<5de16108-9899-4784-8ad6-110b3db07406@googlegroups.com>
<163310d0-ebed-472e-8620-60f46f6d16cf@googlegroups.com>
Date: Mon, 3 Sep 2012 22:01:21 -0700
Message-ID: <CAMCMjp0HiVjLKjqZHTMchvkL_M5S-YwpeTA43g2LQO5KkRE...@mail.gmail.com>
Subject: Re: [nodejs] Re: emit('data') best practice
From: Jake Verbaten <rayn...@gmail.com>
To: nodejs@googlegroups.com
Content-Type: multipart/alternative; boundary=0015174be97438410f04c8d92665
--0015174be97438410f04c8d92665
Content-Type: text/plain; charset=ISO-8859-1
A way to solve this is open an issue on the repository. You'll get one
concrete answer.
On Mon, Sep 3, 2012 at 9:29 PM, Mike Nichols <nichols.mik...@gmail.com>wrote:
> Thanks for your response.
> I guess my question is whether to emit a 'data' event when there isn't any
> "raw data", but the underlying reply from redis is considered to be an
> 'empty list'. The zen semantic in me asks 'is the absence of data....data'
> . :)
> But seriously, it just feels like a subscriber would always want to know
> that 'empty', not nil, was the reply.
>
>
> On Monday, September 3, 2012 8:26:20 PM UTC-7, tjholowaychuk wrote:
>>
>> IMO if the idea behind streams are to act like pipes then "data" events
>> should only be "raw" data aka Buffers (strings too I guess),
>> if it's a non-stream then whatever I guess
>>
>> On Monday, 3 September 2012 15:44:55 UTC-7, Mike Nichols wrote:
>>>
>>> When issuing a redis command which expects a multi-bulk reply but the
>>> key does not exist, one may receive the following:
>>> +OK
>>> *0
>>>
>>> The redis docs say "If the specified key does not exist, the key is
>>> considered to hold an empty list and the value 0 is sent as multi bulk
>>> count."
>>>
>>> It seems like it is proper to emit a 'data' event in a client library
>>> with the 'empty list' redis implies so that consuming code can use it in a
>>> pipeline and let the consumer handle the `empty list` there.
>>>
>>> This came from looking at 'https://github.com/tblobaum/**redis-stream<https://github.com/tblobaum/redis-stream>'
>>> where this sort of reply drops the data, thus breaking the pipeline.
>>>
>>> This leads me to the greater question on whether or not to emit 'data'
>>> for a empty value. My gut says low level libs like these _should_ emit the
>>> event with empty data but I wonder what other authors are preferring.
>>>
>>> Any opinions would be appreciated on this.
>>>
>>> --
> Job Board: http://jobs.nodejs.org/
> Posting guidelines:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> You received this message because you are subscribed to the Google
> Groups "nodejs" group.
> To post to this group, send email to nodejs@googlegroups.com
> To unsubscribe from this group, send email to
> nodejs+unsubscribe@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/nodejs?hl=en?hl=en
>
--0015174be97438410f04c8d92665
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
A way to solve this is open an issue on the repository. You'll get one =
concrete answer.<br><br><div class=3D"gmail_quote">On Mon, Sep 3, 2012 at 9=
:29 PM, Mike Nichols <span dir=3D"ltr"><<a href=3D"mailto:nichols.mike.s=
@gmail.com" target=3D"_blank">nichols.mik...@gmail.com</a>></span> wrote=
:<br>
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex"><div>Thanks for your response.</div>I guess =
my question is whether to emit a 'data' event when there isn't =
any "raw data", but the underlying reply from redis is considered=
to be an 'empty list'. The zen semantic in me asks 'is the abs=
ence of data....data' . :)=A0<div>
But seriously, it just feels like a subscriber would always want to know th=
at 'empty', not nil, was the reply.=A0</div><div class=3D"HOEnZb"><=
div class=3D"h5"><div><br><br>On Monday, September 3, 2012 8:26:20 PM UTC-7=
, tjholowaychuk wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0;m=
argin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex">
IMO if the idea behind streams are to act like pipes then "data" =
events should only be "raw" data aka Buffers (strings too I guess=
),<div>if it's a non-stream then whatever I guess<br><br>On Monday, 3 S=
eptember 2012 15:44:55 UTC-7, Mike Nichols wrote:<blockquote class=3D"gmai=
l_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #ccc solid;pad=
ding-left:1ex">
<div>When issuing a redis command which expects a multi-bulk reply but the =
key does not exist, one may receive the following:<br></div><div>+OK</div><=
div>*0</div><div><br></div><div>The redis docs say "<span style=3D"col=
or:rgb(51,51,51);font-family:'Helvetica Neue',sans-serif;line-heigh=
t:19px;background-color:rgb(250,250,250)">If the specified key does not exi=
st, the key is considered to hold an empty list and the value=A0</span><cod=
e style=3D"font:inherit;font-family:Menlo,Monaco,monospace;color:rgb(51,51,=
51);background-color:rgb(250,250,250)">0</code><span style=3D"color:rgb(51,=
51,51);font-family:'Helvetica Neue',sans-serif;line-height:19px;bac=
kground-color:rgb(250,250,250)">=A0is sent as multi bulk count."</span=
></div>
<div><span style=3D"color:rgb(51,51,51);font-family:'Helvetica Neue'=
;,sans-serif;line-height:19px;background-color:rgb(250,250,250)"><br></span=
></div><div>It seems like it is proper to emit a 'data' event in a =
client library with the 'empty list' redis implies so that consumin=
g code can use it in a pipeline and let the consumer handle the `empty list=
` there.</div>
<div><br></div><div>This came from looking at '<a href=3D"https://githu=
b.com/tblobaum/redis-stream" target=3D"_blank">https://github.com/tblobaum/=
<u></u>redis-stream</a>' where this sort of reply drops the data, thus =
breaking the pipeline.=A0</div>
<div><br></div><div>This leads me to the greater question on whether or not=
to emit 'data' for a empty value. My gut says low level libs like =
these _should_ emit the event with empty data but I wonder what other autho=
rs are preferring.</div>
<div><br></div><div>Any opinions would be appreciated on this.</div><div><b=
r></div></blockquote></div></blockquote></div>
<p></p>
-- <br>
Job Board: <a href=3D"http://jobs.nodejs.org/" target=3D"_blank">http://job=
s.nodejs.org/</a><br>
Posting guidelines: <a href=3D"https://github.com/joyent/node/wiki/Mailing-=
List-Posting-Guidelines" target=3D"_blank">https://github.com/joyent/node/w=
iki/Mailing-List-Posting-Guidelines</a><br>
You received this message because you are subscribed to the Google<br>
Groups "nodejs" group.<br>
To post to this group, send email to <a href=3D"mailto:nodejs@googlegroups.=
com" target=3D"_blank">nodejs@googlegroups.com</a><br>
To unsubscribe from this group, send email to<br>
<a href=3D"mailto:nodejs%2Bunsubscribe@googlegroups.com" target=3D"_blank">=
nodejs+unsubscribe@googlegroups.com</a><br>
For more options, visit this group at<br>
<a href=3D"http://groups.google.com/group/nodejs?hl=3Den?hl=3Den" target=3D=
"_blank">http://groups.google.com/group/nodejs?hl=3Den?hl=3Den</a><br>
</div></div></blockquote></div><br>
--0015174be97438410f04c8d92665--