Skip to content

Instantly share code, notes, and snippets.

@peschkaj
Created July 5, 2013 23:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peschkaj/5937828 to your computer and use it in GitHub Desktop.
Save peschkaj/5937828 to your computer and use it in GitHub Desktop.
public RiakResult<IEnumerable<string>> StreamListBuckets()
{
var lbReq = new RpbListBucketsReq { stream = true };
var result = UseDelayedConnection((conn, onFinish) =>
conn.PbcWriteStreamRead<RpbListBucketsReq, RpbListBucketsResp>(lbReq, lbr => lbr.IsSuccess && !lbr.Value.done, onFinish));
if(result.IsSuccess)
{
var buckets = result.Value.Where(r => r.IsSuccess).SelectMany(r => r.Value.buckets).Select(k => k.FromRiakString());
return RiakResult<IEnumerable<string>>.Success(buckets);
}
return RiakResult<IEnumerable<string>>.Error(result.ResultCode, result.ErrorMessage, result.NodeOffline);
}
@OJ
Copy link

OJ commented Jul 6, 2013

Yes this might suffice. Though I do think we need to think more about it. The reason is because I think we're currently relying on the caller to enumerate the collection fully before we put the connection back in the pool. We should have a chat about how we should handle this because if they bomb out early (ie. don't enumerate the lot) then we could leak connections.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment