Doc update and a bug fix.
authorPete <pete@debu.gs>
Thu, 25 Apr 2019 03:21:38 +0000 (20:21 -0700)
committerPete <pete@debu.gs>
Thu, 25 Apr 2019 03:21:38 +0000 (20:21 -0700)
README
appl/lib/redis.b
man/1/redis
man/2/redis

diff --git a/README b/README
index ee413086127412c70319b2603dbd79cebcdd8eb9..1d3836657115ae585aa6ac2174f7e5a50146ae97 100644 (file)
--- a/README
+++ b/README
@@ -1,27 +1,28 @@
-Inferno Redis Client:  A Very Alpha Software Release
-__        __         _                                        
-\ \      / /__  _ __| | _____    ___  _ __    _ __ ___  _   _ 
- \ \ /\ / / _ \| '__| |/ / __|  / _ \| '_ \  | '_ ` _ \| | | |
-  \ V  V / (_) | |  |   <\__ \ | (_) | | | | | | | | | | |_| |
-   \_/\_/ \___/|_|  |_|\_\___/  \___/|_| |_| |_| |_| |_|\__, |
-                                                        |___/ 
-                      _     _            _ 
- _ __ ___   __ _  ___| |__ (_)_ __   ___| |
-| '_ ` _ \ / _` |/ __| '_ \| | '_ \ / _ \ |
-| | | | | | (_| | (__| | | | | | | |  __/_|
-|_| |_| |_|\__,_|\___|_| |_|_|_| |_|\___(_)
+- Inferno Redis Client:  An Apparently Working Software Release
 
+This code contains a library and an interactive client for talking to Redis
+(https://redis.io/) from the Inferno OS
+(http://www.vitanuova.com/inferno/index.html).  I am currently using the
+interactive client regularly.
 
-This code contains a library and an interactive client.  I am currently using
-the interactive client daily.  I like Redis.  If you start seeing fewer updates,
-that means I have found fewer bugs (either directly or by reports).
+I use Redis for fun and profit, as well as Inferno.  I wanted to talk to Redis
+from Inferno without using os(10).
 
-I wanted to talk to Redis from Inferno without using os(10).
+- Installing
 
-Installing:  mk install.  Set $ROOT if you are doing it from outside Inferno.
+       % mk install
 
-API Stability:  No.  The current API is bad and wrong.
+Set $ROOT if you are running mk from the host OS, you will need to add
+'ROOT=/path/to/inferno' to the mk command.
 
-Documentation:  See the man pages.
+- Documentation
 
-Plans:  Less buggy, better API, better man pages.  Filesystem interface.
+The command and the library have man pages (which note some bugs).
+
+- Future development
+
+It'd be nice to fix some of the bugs by special-casing the commands.
+
+The man pages could stand some help.
+
+A filesystem interface would be nice.
index ada837e1a2315fa56b58ccabe59f9c15458fc20e..7841723b3fb48d52ad43e2f0c8bf1ab342dc9e13 100644 (file)
@@ -61,9 +61,6 @@ RedisClient.parseresult(cl: self ref RedisClient): list of (int, string) {
                * => -1,
        };
 
-       sys->fprint(sys->fildes(2), "Connection dropped:  %r\n");
-       raise "fail:errors";
-
        c := cl.io.getb();
        if(debug)
                sys->fprint(sys->fildes(2), "« %c", c);
index ac523ac7707d0574eab9eaca4e97571ea0bf2b54..4dbbe7dd78e8702424a3a1a530a6c32876884f92 100644 (file)
@@ -91,9 +91,9 @@ or
 .B SUBSCRIBE
 you will have to issue repeated
 .B PING
-commands to get the results.  This may get fixed, but using the FS interface or
-the library might be more prudent than using the interactive command if you
-are doing things like Pub/Sub.  (
+commands to get the results.  This may get fixed, but using the (planned) FS
+interface or the library might be more prudent than using the interactive
+command if you are doing things like Pub/Sub.  (
 .B BRPOP
 and friends work just fine, though.)
 
index 32d4708ffba2649cf99537ce4e5ca6aa3e55f491..e4e51b713f41dad723220494448179c37bc75fbe 100644 (file)
@@ -7,12 +7,28 @@ include "redis.m";
 redis := load Redis Redis->PATH;
 
 initmod: fn(s: Sys, d: Dial, b: Bufio, st: String);
-call: fn(io: ref Iobuf, cmd: list of string):
-       list of (int, string);
-sendcmd: fn(io: ref Iobuf, cmd: list of string): int;
-parseresult: fn(io: ref Iobuf): list of (int, string);
+connect: fn(addr: string): ref RedisClient;
+client: fn(io: ref Iobuf): ref RedisClient;
+
+parsecmd: fn(s: string, qc: int): (list of string, int);
+packcmd: fn(cmd: list of string): string;
+
 RStr, RInt, RErr: con iota + 1;
 
+setdebug: fn(state: int);
+
+RedisClient: adt {
+       call: fn(c: self ref RedisClient, cmd: list of string): list of (int, string);
+
+       # You probably won't need these:
+       sendcmd: fn(c: self ref RedisClient, cmd: list of string): int;
+       printresult: fn(c: self ref RedisClient);
+       parseresult: fn(c: self ref RedisClient): list of (int, string);
+
+       # Internal:
+       io: ref Bufio->Iobuf;
+};
+
 
 .EE
 
@@ -23,11 +39,25 @@ allows you to speak the Redis protocol to a Redis database.
 You will probably only need the
 .I call()
 function after calling 
-.I initmod().
-.I call()
-and the rest of the code will probably change.  It takes lists of strings and
-returns lists of tuples, each containing a type tag and a string
-representation of the data.
+.I initmod()
+to initialize the module and
+.I connect()
+to dial a server.  If you have your own
+.I ref Iobuf
+and you you would prefer to manage the connection yourself, you can use
+.I client()
+to initialize a client with that Iobuf.
+
+.I RedisClient.call()
+takes lists of strings representing a command and its arguments, and returns
+lists of tuples, each containing a type tag (one of
+.I RStr
+,
+.I RInt
+,
+or
+.I Rerr
+) and a string representation of the data.
 
 .I sendcmd()
 and
@@ -54,16 +84,16 @@ or
 # The library wants some modules passed in:
 redis->initmod(sys, dial, bufio, str);
 
-# Do a connection and wrap the data FD in an Iobuf.
-# See the source for redis(1) for an example.
+# The client:
+client: ref RedisClient = redis->connect('tcp!localhost!6379');
 
-redis->call(c, "SET" :: "X" :: "5" :: nil);
-redis->call(c, "INCRBY" :: "X" :: "3" :: nil);
+client->call(c, "SET" :: "X" :: "5" :: nil);
+client->call(c, "INCRBY" :: "X" :: "3" :: nil);
 # Returns (RInt, "8") :: nil
-redis->call(c, "HSET" :: "HT" :: "X" :: "five" :: nil);
-redis->call(c, "HGETALL" :: "HT" :: nil);
+client->call(c, "HSET" :: "HT" :: "X" :: "five" :: nil);
+client->call(c, "HGETALL" :: "HT" :: nil);
 # Returns (RStr, "X") :: (RStr, "five") :: nil
-redis->call(c, "KEYS" :: "*" :: nil);
+client->call(c, "KEYS" :: "*" :: nil);
 # Returns (Rstr, "X") :: (Rstr, "HT") :: nil
 
 .EE
@@ -78,14 +108,10 @@ redis->call(c, "KEYS" :: "*" :: nil);
 .IR bufio (2)
 
 .SH BUGS
-This is alpha software.  It works on my machine and currently does the
-right thing, usually.
+It works on my machine and currently does the right thing so far.  This being a new release, no one else has used it so the usual caveats apply.
 
 Errors are ignored unless generated by the server.  So a missing argument will display the error that the server sends back, but a failure on our part to parse a response from the server is silently ignored.
 
-The interface will change.  In particular, it is likely that there will be a
-client struct that will carry errors around so that you can see the errors.
-There are some other functions the module exports but none of those will
-remain in their current form.
-
-Most of the interface is undocumented, because it will change.
+The interface will probably change.  In particular, it is likely that
+.I RedisClient
+ will carry errors around so that you can see the errors.