Documentation ¶
Overview ¶
Package database is a database interface to federation in.
Index ¶
- type FederationInDB
- func (db *FederationInDB) AddFederationInQuery(ctx context.Context, q *model.FederationInQuery) error
- func (db *FederationInDB) GetFederationInQuery(ctx context.Context, queryID string) (*model.FederationInQuery, error)
- func (db *FederationInDB) GetFederationInSync(ctx context.Context, syncID int64) (*model.FederationInSync, error)
- func (db *FederationInDB) Lock(ctx context.Context, lockID string, ttl time.Duration) (database.UnlockFn, error)
- func (db *FederationInDB) StartFederationInSync(ctx context.Context, q *model.FederationInQuery, started time.Time) (int64, FinalizeSyncFn, error)
- type FinalizeSyncFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FederationInDB ¶
type FederationInDB struct {
// contains filtered or unexported fields
}
func New ¶
func New(db *database.DB) *FederationInDB
func (*FederationInDB) AddFederationInQuery ¶
func (db *FederationInDB) AddFederationInQuery(ctx context.Context, q *model.FederationInQuery) error
AddFederationInQuery adds a FederationInQuery entity. It will overwrite a query with matching q.queryID if it exists.
func (*FederationInDB) GetFederationInQuery ¶
func (db *FederationInDB) GetFederationInQuery(ctx context.Context, queryID string) (*model.FederationInQuery, error)
GetFederationInQuery returns a query for given queryID. If not found, ErrNotFound will be returned.
func (*FederationInDB) GetFederationInSync ¶
func (db *FederationInDB) GetFederationInSync(ctx context.Context, syncID int64) (*model.FederationInSync, error)
GetFederationInSync returns a federation sync record for given syncID. If not found, ErrNotFound will be returned.
func (*FederationInDB) Lock ¶
func (db *FederationInDB) Lock(ctx context.Context, lockID string, ttl time.Duration) (database.UnlockFn, error)
Lock acquires lock with given name that times out after ttl. Returns an UnlockFn that can be used to unlock the lock. ErrAlreadyLocked will be returned if there is already a lock in use.
func (*FederationInDB) StartFederationInSync ¶
func (db *FederationInDB) StartFederationInSync(ctx context.Context, q *model.FederationInQuery, started time.Time) (int64, FinalizeSyncFn, error)
StartFederationInSync stores a historical record of a query sync starting. It returns a FederationInSync key, and a FinalizeSyncFn that must be invoked to finalize the historical record.
type FinalizeSyncFn ¶
type FinalizeSyncFn func(state *federation.FetchState, q *model.FederationInQuery, totalInserted int) error
FinalizeSyncFn is used to finalize a historical sync record.