summaryrefslogtreecommitdiffstats
path: root/docs/clientapi.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/clientapi.md')
-rw-r--r--docs/clientapi.md213
1 files changed, 213 insertions, 0 deletions
diff --git a/docs/clientapi.md b/docs/clientapi.md
new file mode 100644
index 0000000..a2ac18e
--- /dev/null
+++ b/docs/clientapi.md
@@ -0,0 +1,213 @@
1The client API consists of:
2
3* a modification API for messages (Create/Modify/Delete)
4* a query API to retrieve messages
5* a resource facade to abstract the resource implementation details
6* a set of standardized domain types
7* a notification mechanism to be notified about changes from individual stores
8
9## Requirements/Design goals
10* zero-copy should be possible (mmap support)
11 * Likely only possible until application domain until we rewrite portions of the applications
12 * Most importantly we should hide how the data is stored (in parts, or one mmapped buffer)
13 * Support for mmapped buffers implies that we keep track of the lifetime of the loaded values.
14* property-level on-demand loading
15* streaming support for certain properties (attachments)
16
17## Domain Types
18A set of standardized domain types is defined. This is necessary to decouple applications from resources (so a calendar can access events from all resources), and to have a "language" for queries.
19
20The definition of the domain model directly affects:
21* granularity for data retrievel (email property, or individual subject, date, ...)
22* queriable properties (sender, id, ...)
23* properties used for sorting (10 latest email)
24
25The purpose of these domain types is strictly to be the interface and the types are not meant to be used by applications directly, or to be restricted by any other specifications (such as ical). By nature these types will be part of the evolving interface, and will need to be adjusted for every new property that an application must understand.
26
27### Akonadi Domain Types
28This is a proposed set of types that we will need to evolve into what we actually require. Hierarchical types are required to be able to query for a result set of mixed types.
29
30Items:
31
32* Item
33 * incidence
34 * Event
35 * Todo
36 * Journal
37 * Freebusy
38 * Note
39 * Mail
40 * Contact
41
42Collections:
43
44* Collection
45 * Mail Folder
46 * Calendar
47 * Tasklist
48 * Journal
49 * Contact Group
50 * Address Book
51
52Relations:
53
54* Relation
55 * Tag
56
57## Store Facade
58The store is always accessed through a store specific facade, which hides:
59* store access (one store could use a database, and another one plain files)
60* message type (flatbuffers, ...)
61* indexes
62* syncronizer communication
63* notifications
64
65This abstraction layer allows each resource to separately define how data is stored and retrieved. Therefore tradeoffs can be defined to suit the expected access patters or structure of source data. Further it allows individual resources to choose different technologies as suitable. Logic can still be shared among resources, while keeping the maintenance effort reasonable, by providing default implementations that are suitable for most workloads.
66
67Because the facade also implements querying of indexes, a resource my use server-side searching to fullfill the query, and fallback to local searches when the server is not available.
68
69## Modifications
70Modifications are stored by the client sending modification commands to the syncronizer. The syncronizer is responsible for ensuring that modification are not lost and eventually persistet. A small window exists therefore where a modification is transferred to the syncronizer where a modifications can get lost.
71
72The API consists of the following calls:
73
74* create(domainObject, resource)
75* modify(domainObject, resource)
76* remove(domainObject, resource)
77
78The changeset can be recorded by the domain object adapter while the properties are set, and are then sent to the syncronizer once modify is called.
79
80Each modification is associated with a specific revision, which allows the syncronizer to do automatic conflict resolution.
81
82### Conflict Resolution
83Conflicts can occur at two points in the client:
84
85* While i.e. an editor is open and we receive an update for the same entity
86* After a modification is sent to the syncronizer but before it's processed
87
88In the first case the client is repsonsible to resolve the conflict, in the latter case it's the syncronizer's responsibility.
89A small window exists where the client has already started the modification (i.e. command is in socket), and a notification has not yet arrived that the same entity has been changed. In such a case the syncronizer may reject the modification because it has the revision the modification refers to no longer available.
90
91This design allows the syncronizer to be in control of the revisions, and keeps it from having to wait for all clients to update until it can drop revisions.
92
93## Query System
94The query system should allow for efficient retrieval for just the amount of data required by the client. Efficient querying will be supported by the indexes povided by the resources.
95
96The query always retrieves a set of entities matching the query, while not necessarily all properties of the entity need to be populated.
97
98Queries should be declarative to keep the specification simple and to allow the implementation to choose the most efficient execution.
99
100Queries can be kept open to receive updates as the store changes, and modified to adjust the result set.
101
102### Query
103The query consists of:
104* a declarative set of filters to match the wanted entities
105* the set of properties to retrieve for each entity
106* a limit for the amount of entities to retrieve
107* an offset to retrieve more entities
108
109Queryable properties are defined by the [[Domain Types]] above.
110
111Other Requirements:
112* modifiable: to facilitate adjustments, such as a date-range while scrolling in the mail view.
113* serializable: to persist queries, i.e. to store a "smart folder" query to a config file.
114
115#### Filter
116A filter consists of:
117
118* a property to filter on as defined by the [[Domain Types]]
119* a comparator to use
120* a value
121
122The available comparators are:
123
124* equal
125* greater than
126* less than
127* inclusive range
128
129Value types include:
130
131* Null
132* Bool
133* Regular Expression
134* Substring
135* A type-specific literal value (e.g. string, number, date, ..)
136
137Filters can be combined using AND, OR, NOT.
138
139#### Example
140```
141query = {
142 offset: int
143 limit: int
144 filter = {
145 and {
146 collection = foo
147 or {
148 resource = res1
149 resource = res2
150 }
151 }
152 }
153}
154```
155
156possible API:
157
158```
159query.filter().and().property("collection") = "foo"
160query.filter().and().or().property("resource") = "res1"
161query.filter().and().or().property("resource") = "res2"
162query.filter().and().property("start-date") = InclusiveRange(QDateTime, QDateTime)
163```
164
165The problem is that it is difficult to adjust an individual resource property like that.
166
167### Usecases ###
168Mail:
169
170* All mails in folder X within date-range Y that are unread.
171* All mails (in all folders) that contain the string X in property Y.
172
173Todos:
174
175* Give me all the todos in that collection where their RELATED-TO field maps to no other todo UID field in the collection
176* Give me all the todos in that collection where their RELATED-TO field has a given value
177* Give me all the collections which have a given collection as parent and which have a descendant matching a criteria on its attributes;
178
179Events:
180
181* All events of calendar X within date-range Y.
182
183Generic:
184* entity with identifier X
185* all entities of resource X
186
187### Lazy Loading ###
188The system provides property-level lazy loading. This allows i.e. to defer downloading of attachments until the attachments is accessed, at the expense of having to have access to the source (which could be connected via internet).
189
190To achieve this, the query system must check for the availability of all requested properties on all matched entities. If a property is not available the a command should be sent to the synchronizer to retrieve said properties. Once all properties are available the query can complete.
191
192Note: We should perhaps define a minimum set of properties that *must* be available. Otherwise local search will not work. On the other hand, if a resource implements server-side search, it may not care if local search doesn't work.
193
194### Data streaming ###
195Large objects such as attachments should be streamable. An API that allows to retrieve a single property of a defined entity in a streamable fashion is probably enough.
196
197### Indexes ###
198Since only properties of the domain types can be queried, default implementations for commonly used indexes can be provided. These indexes are populated by generic preprocessors that use the domain-type interface to extract properties from individual entites.
199
200## Notifications ##
201A notification mechanism is required to inform clients about changes. Running queries will automatically update the result-set if a notification is received.
202
203A notification constist of:
204
205* The latest revision of the store
206* A hint what properties changed
207
208The revision allows the client to only fetch the data that changed.
209The hint allows the client to avoid fetching that it's not interested in.
210A running query can do all of that transparently behind the scenes.
211
212Note that the hints should indeed only hint what has changed, and not supply the actual changeset. These hints should be tailored to what we see as useful, and must therefore be easy to modify.
213