Skip to content

Commit fc8962d

Browse files
committed
updated docs
1 parent 88bf1e0 commit fc8962d

File tree

3 files changed

+75
-10
lines changed

3 files changed

+75
-10
lines changed

AUTHORS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@ Moriyoshi Koizumi (https://github.com/moriyoshi)
1717
takeda-at (https://github.com/takada-at)
1818
- added simple authorization function
1919

20+
WheresWardy (https://github.com/WheresWardy)
21+
- added authentication functions to libhsclient
22+

docs-en/configuration-options.en.txt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,20 @@ handlersocket_accept_balance (default = 0, min = 0, max = 10000)
8080
handlersocket_wrlock_timeout (default = 12, min = 0, max = 3600)
8181

8282
Specify the lock timeout in seconds. When a write request is
83-
performed, handlersocket locks an advisory lock named
83+
performed, handlersocket acquires an advisory lock named
8484
'handlersocket_wr'. This option sets the timeout for the
8585
locking.
8686

87+
-----------------------------------------------------------------
88+
handlersocket_plain_secret (default = '')
89+
90+
When this option is specified, a plain-text authentication is
91+
enabled for the listener for read requests. This option
92+
specifies the secret key for the authentication.
93+
94+
-----------------------------------------------------------------
95+
handlersocket_plain_secret_wr (default = '')
96+
97+
This option specifies the secret key for the listener for write
98+
requests.
8799

docs-en/protocol.en.txt

Lines changed: 59 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,14 @@ Request and Response
3333

3434
The 'open_index' request has the following syntax.
3535

36-
P <indexid> <dbname> <tablename> <indexname> <columns>
36+
P <indexid> <dbname> <tablename> <indexname> <columns> [<fcolumns>]
3737

3838
- <indexid> is a number in decimal.
3939
- <dbname>, <tablename>, and <indexname> are strings. To open the primary
4040
key, use PRIMARY as <indexname>.
4141
- <columns> is a comma-separated list of column names.
42+
- <fcolumns> is a comma-separated list of column names. This parameter is
43+
optional.
4244

4345
Once an 'open_index' request is issued, the HandlerSocket plugin opens the
4446
specified index and keep it open until the client connection is closed. Each
@@ -51,46 +53,94 @@ For efficiency, keep <indexid> small as far as possible.
5153
Getting data
5254

5355
The 'find' request has the following syntax.
56+
57+
<indexid> <op> <vlen> <v1> ... <vn> [LIM] [IN] [FILTER ...]
5458

55-
<indexid> <op> <vlen> <v1> ... <vn> <limit> <offset>
59+
LIM is a sequence of the following parameters.
60+
61+
<limit> <offset>
62+
63+
IN is a sequence of the following parameters.
64+
65+
@ <icol> <ivlen> <iv1> ... <ivn>
66+
67+
FILETER is a sequence of the following parameters.
68+
69+
<ftyp> <fop> <fcol> <fval>
5670

5771
- <indexid> is a number. This number must be an <indexid> specified by a
5872
'open_index' request executed previously on the same connection.
5973
- <op> specifies the comparison operation to use. The current version of
6074
HandlerSocket supports '=', '>', '>=', '<', and '<='.
6175
- <vlen> indicates the length of the trailing parameters <v1> ... <vn>. This
6276
must be smaller than or equal to the number of index columns specified by
63-
specified by the corresponding 'open_index' request.
77+
the <columns> parameter of the corresponding 'open_index' request.
6478
- <v1> ... <vn> specify the index column values to fetch.
65-
- <limit> and <offset> are numbers. These parameters can be omitted. When
66-
omitted, it works as if 1 and 0 are specified.
79+
- LIM is optional. <limit> and <offset> are numbers. When omitted, it works
80+
as if 1 and 0 are specified. These parameter works like LIMIT of SQL.
81+
These values don't include the number of records skipped by a filter.
82+
- IN is optional. It works like WHERE ... IN syntax of SQL. <icol> must be
83+
smaller than or equal to the number of index columns specified by the
84+
<columns> parameter of the corresponding 'open_index' request. If IN is
85+
specified in a find request, the <icol>-th parameter value of <v1> ...
86+
<vn> is ignored.
87+
smaller than or equal to the number of index columns specified by the
88+
- FILTERs are optional. A FILTER specifies a filter. <ftyp> is either 'F'
89+
(filter) or 'W' (while). <fop> specifies the comparison operation to use.
90+
<fcol> must be smaller than or equal to the number of columns specified by
91+
the <fcolumns> parameter of the corresponding 'open_index' request.
92+
Multiple filters can be specified, and work as the logical AND of them.
93+
The difference of 'F' and 'W' is that, when a record does not meet the
94+
specified condition, 'F' simply skips the record, and 'W' stops the loop.
6795

6896
----------------------------------------------------------------------------
6997
Updating/Deleting data
7098

7199
The 'find_modify' request has the following syntax.
72100

73-
<indexid> <op> <vlen> <v1> ... <vn> <limit> <offset> <mop> <m1> ... <mk>
101+
<indexid> <op> <vlen> <v1> ... <vn> [LIM] [IN] [FILTER ...] MOD
102+
103+
MOD is a sequence of the following parameters.
104+
105+
<mop> <m1> ... <mk>
74106

75-
- <mop> is either 'U' (update) or 'D' (delete).
107+
- <mop> is 'U' (update), '+' (increment), '-' (decrement), 'D' (delete),
108+
'U?', '+?', '-?', or 'D?'. If the '?' suffix is specified, it returns
109+
the contents of the records before modification (as if it's a 'find'
110+
request), instead of the number of modified records.
76111
- <m1> ... <mk> specifies the column values to set. The length of <m1> ...
77112
<mk> must be smaller than or equal to the length of <columns> specified by
78113
the corresponding 'open_index' request. If <mop> is 'D', these parameters
79-
are ignored.
114+
are ignored. If <mop> is '+' or '-', values must be numeric. If <mop> is
115+
'-' and it attempts to change column values from negative to positive or
116+
positive to negative, it is not modified.
80117

81118
----------------------------------------------------------------------------
82119
Inserting data
83120

84121
The 'insert' request has the following syntax.
85122

86-
<indexid> '+' <vlen> <v1> ... <vn>
123+
<indexid> + <vlen> <v1> ... <vn>
87124

88125
- <vlen> indicates the length of the trailing parameters <v1> ... <vn>. This
89126
must be smaller than or equal to the length of <columns> specified by the
90127
corresponding 'open_index' request.
91128
- <v1> ... <vn> specify the column values to set. For columns not in
92129
<columns>, the default values for each column are set.
93130

131+
----------------------------------------------------------------------------
132+
Authentication
133+
134+
The 'auth' request has the following syntax.
135+
136+
A <atyp> <akey>
137+
138+
- <atyp> must be '1'
139+
- An 'auth' request succeeds iff <akey> is the correct secret specified by
140+
the 'handlersocket_plain_secret' or 'handlersocket_plain_secret_rw'.
141+
- If an authentication is enabled for a listener, any other requests on a
142+
connection fail before an 'auth' request succeeded on the connection.
143+
94144
----------------------------------------------------------------------------
95145
Response syntax
96146

0 commit comments

Comments
 (0)