File: protocol.md

package info (click to toggle)
sup-mail 0.12.1%2Bgit20120407.aaa852f-1%2Bdeb7u1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 1,784 kB
  • sloc: ruby: 11,902; makefile: 7; sh: 2
file content (168 lines) | stat: -rw-r--r-- 3,747 bytes parent folder | download
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
Redwood Protocol
================

The server begins by sending a line of the form `Redwood <ver> <encodings>
<extensions>`, where `ver` is the major protocol version (1), encodings is a
comma-separated list of supported message encodings (e.g. `json,bert,marshal`),
and `extensions` is a comma-separated list of protocol extensions. The server
must advertise at least one encoding. A zero-length list of extensions is
represented by `none`. The client replies in the same format, with the
restrictions that the protocol version must match, `encodings` and `extensions`
must be subsets of what the server advertised, and there must be exactly 1
encoding specified.

Requests and responses are represented as `[type, params]`, where `type`
is a lowercase string corresponding to one of the message types specified
below and `params` is a dictionary with string keys.

Requests
--------

There may be zero or more replies to a request. Multiple requests may be
issued concurrently. There is an implicit, optional, opaque `tag` parameter to
every request which will be returned in all replies to the request to
aid clients in keeping multiple requests in flight. `tag` may be an
arbitrary datastructure and for the purposes of Cancel defaults to nil.

### Query
Send a Message response for each hit on `query` starting at `offset`
and sending a maximum of `limit` Messages responses. `raw` controls
whether the raw message text is included in the response.

#### Parameters
*   `query`: Query
*   `offset`: int
*   `limit`: int
*   `raw`: boolean

#### Responses
*   multiple Message
*   one Done after all Messages


### Count
Send a count reply with the number of hits for `query`.

#### Parameters
*   `query`: Query

#### Responses
*   one Count


### Label
Modify the labels on all messages matching `query`. First removes the
labels in `remove` then adds those in `add`.

#### Parameters
*   `query`: Query
*   `add`: string list
*   `remove`: string list

#### Responses
*   one Done


### Add
Add a message to the database. `raw` is the normal RFC 2822 message text.

#### Parameters
*   `raw`: string
*   `labels`: string list

#### Responses
*   one Done


### Stream
Sends a Message response whenever a new message that matches `query` is
added with the Add request. This request will not terminate until a
corresponding Cancel request is sent.

#### Parameters
*   `query`: Query

#### Responses
multiple Message


### Cancel
Cancels all active requests with tag `target`. This is only required to
be implemented for the Stream request.

#### Parameters
*   `target`: string

#### Responses
one Done



Responses
---------

### Done
Signifies that a request has completed successfully.


### Message
Represents a query result. If `raw` is present it is the raw message
text that was previously a parameter to the Add request.

#### Parameters
*   `summary`: Summary
*   `raw`: optional string


### Count
`count` is the number of messages matched.

#### Parameters
*   `count`: int


### Error

#### Parameters
*   `type`: string
*   `message`: string



Datatypes
---------

### Query
Recursive prefix-notation datastructure describing a boolean condition.
Where `a` and `b` are Queries and `field` and `value` are strings, a
Query can be any of the following:

*   `[:and, a, b, ...]`
*   `[:or, a, b, ...]`
*   `[:not, a, b]`
*   `[:term, field, value]`


### Summary
*   `message_id`: string
*   `date`: time
*   `from`: Person
*   `to`, `cc`, `bcc`: Person list
*   `subject`: string
*   `refs`: string list
*   `replytos`: string list
*   `labels`: string list


### Person
*   `name`: string
*   `email`: string


TODO
----

*   Protocol negotiation
   -   Version
   -   Compression (none, gzip, ...)
*   Specify string encodings