-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathPROTOCOL
80 lines (52 loc) · 2.33 KB
/
PROTOCOL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
JESync Protocol Specification
Author: Julio Viera
The protocol is a simple ASCII protocol inspired on projects like memcached or
beanstalkd
--------------------
1. Requesting a lock
--------------------
lock <lock_key>[ <max_concurrent>[ <timeout>[ <expires>]]]
lock_key: Any string (no spaces) representing the lock key
max_concurrent: Max number of concurrent request allowed to run simultaneously
with the one being requested
timeout: Specifies the maximum time to wait in seconds for the
lock to be granted
expires: The time on which the acquired lock (if acquired) will be
automatically release by the server. If not specified it will
be 120 seconds. This parameter is a failsafe in case the socket
does not gets closed when the client disconnects without releasing
the lock.
Response:
GRANTED <lockKey_status> <seconds_left>
seconds_left: Number of seconds left before the lock expires, to renew the
grant, you need to issue another lock command
--------------------
2.Releasing a lock
--------------------
release <lock_key>
lock_key: Any string (no spaces) representing the locked key to be
released
Response:
If the lock was locked by the current connection
RELEASED <lockKey_status> <seconds_left>
seconds_left: Number of seconds left before the lock expired
If the lock was not locked by the current connection
NOT_RELEASED <lockKey_status>
--------------------
3. Lock key status
--------------------
The lock key status is written by the server when responding to any lock key
related request. The format is the following
<concurrent> <waiting> <lockKey>
concurrent: Number of concurrent request currently accesing the lock
Waiting: Number of request waiting to access the lock
lockkey: The lock key
Also it is possible to ask for the status of a key anytime doing:
status <lock_key>
--------------------
4. Status listing
--------------------
A status listing can be requested to the server with the following commands
status-by-key: Returns the list of keys sorted by its name
status-by-requests: Returns the list of keys sorted by the request queue
status-by-grants: Returns the list of keys sorted by the numbers of current grants to that particular key