GoActivityPub Wiki

The documentation page was updated.

Storage

The main layout for storage backends is defined by the following interfaces in the processing module:

Implementations

The library provides the following modules as implementations:

FS

Direct filesystem storage, every activity and object corresponds to a file on disk under a folder structure that closely mimics the layout found when querying server. It is generally meant to be used for development environments. It makes use of filesystem symlinks to aggregate items into collections without duplication.

SQLite

A simple object storage on top of a single SQLite database.

Boltdb

BoltDB is a performant key value store.

Badger

Another, more modern key value store.

PostgreSQL

Storage on top of PostgreSQL, but still used as an object storage, similar to the the SQLite one.

All

A wrapper around all of the above that allows using any of them.

In order to simplify the API of the storage interfaces we decided to not make a distinction between loading single objects and loading of collection objects.

As a result the Load(vocab.IRI, filters ...filters.Check) method can receive a variable argument list of filters that can be applied when loading a collection.

This ensures that the collection contains only items that match those filters.

For more details about how filters work see the corresponding module.

Storage conformance suite

To help with the work of implementing your own storage backend we created a storage-conformance-suite which is a convenient helper module to that end.

Its internal storage implementation contains some of the implicit rules that the storage backends need to implement in order to pass the suite, which are not apparent from the API.

Most of these are related to loading dependent objects that are represented just by an IRI in the stored value when the Load() method receives filters that refer to their respective properties.

Other functionality

On top of the functionality required by the ActivityPub specification through the processing module, there are some additional elements that other parts of the library make use of. The conformance suite provides tests for them also, but their absence is not make the conformance suite fail.

One such piece of functionality is saving and retrieving metadata based on the object IDs. This allows Actor objects for example to have an attached private key, or password, or in the cases of Application actors that are used as OAuth2 clients there are methods that facilitate the backends’ use with the osin library in order to support OAuth2 authorization flows.

However this part of the API is not yet set in stone, it might evolve a little over time.