The store is one of the two core agents provided by Bongo, with the other one being the queue. The store itself runs on TCP port 689, and has its own communtication protocol.

The store is probably the most important part of Bongo. This document is an attempt at an introduction to the design of the store.

Contents

[edit] The role of the Store

The store is basically the document repository for the entire system. It takes the role of the mail spool in tradtional UNIX mail setups, but also holds calendar items, contacts, etc. It also implements a fine-grained access control system, to ensure security and facilitiate sharing.

[edit] The internal design

The store is closely modelled on a traditional filesytem, but with slight specialisations.

At the "root" of this filesystem are "stores", and in general, each store represents a single user (usually named after them).

Each store will contain collections or documents: these are roughly analogous to directories and files, although a collection can also be read like a file. Collections may contain other collections.

Documents are typed within the store: they may be mail items, a mail conversation, events, contacts, or some other type.

Collections and documents can also be given an access control list (which determines who can access the resource), properties (usually, meta-data about the resource), and flags.

image:store-design.png

[edit] An example Store conversation

On the left is the actual protocol: you can connect to the store by using a tool such as telnet, to port 689 on the server which is running the store.

Commands entered by the client are prefixed with an asterisk, the response from the server is not. The prefixes themselves are not part of the protocol. To get an idea of the commands available, check out the main store protocol documentation.

  4242 NMAP <b5b1ebb0server45cef8cc>

Greeting from the store server

* AUTH USER admin bongo
  1000 127.0.0.1
* STORE admin
  1000 OK

This is authenticating to the store as the admin user

* COLLECTIONS
  2001 0000000000000002 4096 0 /addressbook
  2001 0000000000000003 4096 0 /calendars
  2001 0000000000000005 4096 0 /mail
  2001 000000000000000b 4096 0 /preferences
  2001 000000000000000c 4096 0 /conversations
  2001 000000000000000d 4096 0 /events
  2001 0000000000000006 4096 0 /mail/INBOX
  2001 0000000000000007 4096 0 /mail/drafts
  2001 0000000000000008 4096 0 /mail/archives
  2001 0000000000000009 4096 0 /addressbook/personal
  2001 000000000000000a 4096 0 /addressbook/collected
  1000 OK

Listing the collections that exist in this store

* PROPGET /mail
  2001 nmap.guid 16
  0000000000000005
  2001 nmap.type 4
  4096
  2001 nmap.collection 16
  0000000000000001
  2001 nmap.index 1
  0
  2001 nmap.flags 1
  0
  2001 nmap.version 1
  0
  2001 nmap.created 20
  1970-01-01 00:00:00Z
  2001 nmap.lastmodified 20
  2007-01-25 13:38:27Z
  1000 OK

Looking at the properties of the mail collection

[edit] What else can it do?

The store is, in many ways, the brains of Bongo. A lot of the work that the system performs in terms of data storage, retrieval and manipulation happens in the store.

Clients can set a WATCH on any particular part of a store, which means that a client is given a notice whenever something about that store changes. It could be a new document, or a removed one, or simply a change of attribute or permission.

The store is also responsible for the search capability of the system. The store indexes incoming data, and maintains that index - search is then performed quickly and efficiently when a client requests.