Created
July 3, 2011 08:09
-
-
Save et4te/1062055 to your computer and use it in GitHub Desktop.
example factor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USING: assocs byte-arrays.hex io io.binary io.encodings.binary | |
io.sockets kernel sequences ; | |
IN: riak | |
! ---------------------------------------------------------------------------- | |
CONSTANT: rpb-ping-req HEX{ 00 00 00 01 01 } | |
: decode-ping-response ( -- n ) | |
0 ; | |
CONSTANT: rpb-get-client-id-req HEX{ 00 00 00 01 03 } | |
CONSTANT: response-map H{ | |
{ HEX{ 2 } [ decode-ping-response ] } | |
} | |
: lookup-response ( id -- val ? ) | |
response-map at* ; | |
: decode-response ( resp -- val ? ) | |
1 head lookup-response ; | |
: read-response ( -- val ? ) | |
4 read be> read decode-response ; | |
: request ( req -- val ? ) | |
"127.0.0.1" 8087 <inet> binary [ | |
write flush read-response | |
] with-client ; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment