package
0.0.3
Repository: https://github.com/sfomuseum/go-activitypub.git
Documentation: pkg.go.dev

# README

Databases

Databases in go-activitypub are really more akin to traditional RDBMS "tables" in that all of the database (or tables) listed below have one or more associations with each other.

Each of these databases is defined as a Go-language interface with one or more default implementations provided by this package. For example:

type GetFollowersCallbackFunc func(context.Context, string) error

type FollowersDatabase interface {
	GetFollowersForAccount(context.Context, int64, GetFollowersCallbackFunc) error
	GetFollower(context.Context, int64, string) (*Follower, error)
	AddFollower(context.Context, *Follower) error
	RemoveFollower(context.Context, *Follower) error
	Close(context.Context) error
}

The idea here is that the various tools for performing actions (posting, serving ActivityPub requests, etc.) don't know anything about the underlying database implementation. Maybe you want to run things locally using a SQLite database, or you want to run it in "production" using a MySQL database or in a "serverless" environment using something like DynamoDB. The answer is: Yes. So long as your database of choice implements the different database (or table) interfaces then it is supported.

Implementations

Like everything else in the go-activitypub package these databases implement a subset of all the functionality defined in the ActivityPub and ActivityStream standards and reflect the ongoing investigation in translating those standards in to working code.

As of this writing two "classes" of databases are supported:

database/sql

Anything that implements the built-in Go database/sql DB interface. As of this writing only SQLite databases have been tested using the mattn/go-sqlite3 package. There are two things to note about the SQLite implementation:

  • The use of the mattn/go-sqlite3 package means you'll need to have a C complier to build the code.
  • The SQLite databases themselves not infrequenely get themselves in to a state where they are locked preventing other operations from completing. This is a SQLite thing so you probably don't want to deploy it to "production" but it is generally good enough for testing things. It's also possible that I am simply misconfiguring SQLite and if I am I would appreciate any pointers on how to fix these mistakes.

To add a different database "driver", for example MySQL, you will need to clone the respective tools and add the relevant import statement. For example to update the cmd/server tool to use MySQL you would replace the _ "github.com/mattn/go-sqlite3" import statement with _ "github.com/go-sql-driver/mysql" like this:

package main

import (
	"context"
	"os"

	_ "github.com/go-sql-driver/mysql"
	"github.com/sfomuseum/go-activitypub/app/server"
	"github.com/sfomuseum/go-activitypub/slog"
)

func main() {
	ctx := context.Background()
	logger := slog.Default()
	server.Run(ctx, logger)
}

SQL schemas

  • SQLite
  • MySQLNote: These have not been tested yet.

gocloud.dev/docstore

Anything that implements the gocloud.dev/docstore Docstore interface. As of this writing only DynamoDB document stores have been tested using the awsdynamodb and the aaronland/gocloud-docstore packages. A few things to note:

  • One side effect of using the aaronland/gocloud-docstore package is that the gocloud.dev/docstore/awsdynamodb "driver" is always imported and available regardless of whether you include in an import statement.
  • The "global secondary indices" for the schema/dynamodb definitions are inefficient and could stand to be optimized at some point in the future.

To add a different docstore "driver", for example MongoDB, you will need to clone the respective tools and add the relevant import statement. For example to update the cmd/server tool to use MongoDB you would replace the _ "github.com/mattn/go-sqlite3" import statement with _ "gocloud.dev/docstore/mongodocstore" like this:

package main

import (
	"context"
	"os"
	
	_ "gocloud.dev/docstore/mongodocstore"
	"github.com/sfomuseum/go-activitypub/app/server"
	"github.com/sfomuseum/go-activitypub/slog"
)

func main() {
	ctx := context.Background()
	logger := slog.Default()
	server.Run(ctx, logger)
}

Document Store table definitions

Interfaces

AccountsDatabase

This is where accounts specific to an atomic instance of the go-activitypub package, for example example1.social versus example2.social, are stored.

ActivitiesDatabase

This is where outbound (ActivityPub) actvities related to accounts are stored. This database stores both the raw (JSON-encoded) ActvityPub activity record as well as other properties (account id, activity type, etc.) specific to the go-activitypub package.

AliasesDatabase

This is where aliases (alternate names) for accounts are stored.

BlocksDatabase

This is where records describing external actors or hosts that are blocked by individual accounts are stored.

DeliveriesDatabase

This is where a log of outbound deliveries of (ActivityPub) actvities for individual accounts are stored.

FollowersDatabase

This is where records describing the external actors following (internal) accounts are stored.

FollowingDatabase

This is where records describing the external actors that (internal) accounts are following are stored.

LikesDatabase

This is where records describing boost activities by external actors (of activities by internal accounts) are stored.

There are currently no database tables for storing boost events by internal accounts.

MessagesDatabase

This is where the pointer to a "Note" activity (stored in an implementation of the NotesDatabase) delivered to a specific account is stored.

NotesDatabase

This is where the details of a "Note" activity from an external actor is stored.

PostTagsDatabase

This is where the details of the "Tags" associated with a post (or "Note") activitiy are stored.

Currently, this interface is tightly-coupled with "Notes" (posts) which may be revisited in the future.

PostsDatabase

This is where the details of a "Note" activity (or "post") by an account are stored. These details do not include ActivityStream "Tags" which are stored separately in an implementation of the PostTagsDatabase.

PropertiesDatabase

This is where arbitrary key-value property records for individual accounts are stored.

# Functions

Schemes returns the list of schemes that have been registered.
Schemes returns the list of schemes that have been registered.
Schemes returns the list of schemes that have been registered.
Schemes returns the list of schemes that have been registered.
Schemes returns the list of schemes that have been registered.
Schemes returns the list of schemes that have been registered.
Schemes returns the list of schemes that have been registered.
Schemes returns the list of schemes that have been registered.
Schemes returns the list of schemes that have been registered.
Schemes returns the list of schemes that have been registered.
NewAccountsDatabase returns a new `AccountsDatabase` instance configured by 'uri'.
NewActivitiesDatabase returns a new `ActivitiesDatabase` instance configured by 'uri'.
NewAliasesDatabase returns a new `AliasesDatabase` instance configured by 'uri'.
NewBlocksDatabase returns a new `BlocksDatabase` instance configured by 'uri'.
NewBoostsDatabase returns a new `BoostsDatabase` instance configured by 'uri'.
NewDeliveriesDatabase returns a new `DeliveriesDatabase` instance configured by 'uri'.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewFollowersDatabase returns a new `FollowersDatabase` instance configured by 'uri'.
NewFollowingDatabase returns a new `FollowingDatabase` instance configured by 'uri'.
NewLikesDatabase returns a new `LikesDatabase` instance configured by 'uri'.
NewMessagesDatabase returns a new `MessagesDatabase` instance configured by 'uri'.
NewNotesDatabase returns a new `NotesDatabase` instance configured by 'uri'.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewPostsDatabase returns a new `PostsDatabase` instance configured by 'uri'.
NewPostTagsDatabase returns a new `PostTagsDatabase` instance configured by 'uri'.
NewPropertiesDatabase returns a new `PropertiesDatabase` instance configured by 'uri'.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Schemes returns the list of schemes that have been registered.
Schemes returns the list of schemes that have been registered.
Schemes returns the list of schemes that have been registered.
Schemes returns the list of schemes that have been registered.
RegisterAccountsDatabase registers 'scheme' as a key pointing to 'init_func' in an internal lookup table used to create new `AccountsDatabase` instances by the `NewAccountsDatabase` method.
RegisterActivitiesDatabase registers 'scheme' as a key pointing to 'init_func' in an internal lookup table used to create new `ActivitiesDatabase` instances by the `NewActivitiesDatabase` method.
RegisterAliasesDatabase registers 'scheme' as a key pointing to 'init_func' in an internal lookup table used to create new `AliasesDatabase` instances by the `NewAliasesDatabase` method.
RegisterBlocksDatabase registers 'scheme' as a key pointing to 'init_func' in an internal lookup table used to create new `BlocksDatabase` instances by the `NewBlocksDatabase` method.
RegisterBoostsDatabase registers 'scheme' as a key pointing to 'init_func' in an internal lookup table used to create new `BoostsDatabase` instances by the `NewBoostsDatabase` method.
RegisterDeliveriesDatabase registers 'scheme' as a key pointing to 'init_func' in an internal lookup table used to create new `DeliveriesDatabase` instances by the `NewDeliveriesDatabase` method.
RegisterFollowersDatabase registers 'scheme' as a key pointing to 'init_func' in an internal lookup table used to create new `FollowersDatabase` instances by the `NewFollowersDatabase` method.
RegisterFollowingDatabase registers 'scheme' as a key pointing to 'init_func' in an internal lookup table used to create new `FollowingDatabase` instances by the `NewFollowingDatabase` method.
RegisterLikesDatabase registers 'scheme' as a key pointing to 'init_func' in an internal lookup table used to create new `LikesDatabase` instances by the `NewLikesDatabase` method.
RegisterMessagesDatabase registers 'scheme' as a key pointing to 'init_func' in an internal lookup table used to create new `MessagesDatabase` instances by the `NewMessagesDatabase` method.
RegisterNotesDatabase registers 'scheme' as a key pointing to 'init_func' in an internal lookup table used to create new `NotesDatabase` instances by the `NewNotesDatabase` method.
RegisterPostsDatabase registers 'scheme' as a key pointing to 'init_func' in an internal lookup table used to create new `PostsDatabase` instances by the `NewPostsDatabase` method.
RegisterPostTagsDatabase registers 'scheme' as a key pointing to 'init_func' in an internal lookup table used to create new `PostTagsDatabase` instances by the `NewPostTagsDatabase` method.
RegisterPropertiesDatabase registers 'scheme' as a key pointing to 'init_func' in an internal lookup table used to create new `PropertiesDatabase` instances by the `NewPropertiesDatabase` method.

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
SQL_POST_TAGS_TABLE_NAME
No description provided by the author
No description provided by the author
No description provided by the author

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Interfaces

AccountsDatabase defines an interface for working with individual accounts associated with an atomic instance of the `go-activity` tools and services.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Type aliases

AccountsDatabaseInitializationFunc is a function defined by individual account_database package and used to create an instance of that account_database.
ActivitiesDatabaseInitializationFunc is a function defined by individual activities_database package and used to create an instance of that activities_database.
AliasesDatabaseInitializationFunc is a function defined by individual alias_database package and used to create an instance of that alias_database.
BlocksDatabaseInitializationFunc is a function defined by individual block_database package and used to create an instance of that block_database.
BoostsDatabaseInitializationFunc is a function defined by individual boost_database package and used to create an instance of that boost_database.
DeliveriesDatabaseInitializationFunc is a function defined by individual deliveries_database package and used to create an instance of that deliveries_database.
FollowersDatabaseInitializationFunc is a function defined by individual followers_database package and used to create an instance of that followers_database.
FollowingDatabaseInitializationFunc is a function defined by individual following_database package and used to create an instance of that following_database.
GetAccountIdsCallbackFunc is a custom function used to process an `activitypub.Account` identifier.
GetAccountsCallbackFunc is a custom function used to process an `activitypub.Account` record.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
LikesDatabaseInitializationFunc is a function defined by individual like_database package and used to create an instance of that like_database.
MessagesDatabaseInitializationFunc is a function defined by individual messages_database package and used to create an instance of that messages_database.
NotesDatabaseInitializationFunc is a function defined by individual notes_database package and used to create an instance of that notes_database.
PostsDatabaseInitializationFunc is a function defined by individual post_database package and used to create an instance of that post_database.
PostTagsDatabaseInitializationFunc is a function defined by individual post_tags_database package and used to create an instance of that post_tags_database.
PropertiesDatabaseInitializationFunc is a function defined by individual properties_database package and used to create an instance of that properties_database.