2024-09-14 11:27:28 -05:00
|
|
|
package store
|
|
|
|
|
|
|
|
|
|
import (
|
2024-10-28 13:48:22 -05:00
|
|
|
"codeberg.org/danjones000/combluotion/config"
|
2024-09-14 11:27:28 -05:00
|
|
|
st "github.com/go-ap/fedbox/storage"
|
|
|
|
|
proc "github.com/go-ap/processing"
|
|
|
|
|
"github.com/openshift/osin"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type ClientSaver interface {
|
|
|
|
|
// UpdateClient updates the client (identified by it's id) and replaces the values with the values of client.
|
|
|
|
|
UpdateClient(c osin.Client) error
|
|
|
|
|
// CreateClient stores the client in the database and returns an error, if something went wrong.
|
|
|
|
|
CreateClient(c osin.Client) error
|
|
|
|
|
// RemoveClient removes a client (identified by id) from the database. Returns an error if something went wrong.
|
|
|
|
|
RemoveClient(id string) error
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type ClientLister interface {
|
|
|
|
|
// ListClients lists existing clients
|
|
|
|
|
ListClients() ([]osin.Client, error)
|
|
|
|
|
GetClient(id string) (osin.Client, error)
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-14 20:37:51 -05:00
|
|
|
type Bootstrapper interface {
|
|
|
|
|
// Bootstrap should initialize the data store so that it can be used.
|
|
|
|
|
// This will be called every time the application starts, so it MUST be idempotent and doesn't delete existing data.
|
|
|
|
|
// An option is to run migrations in this method.
|
|
|
|
|
Bootstrap(config.Config) error
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-14 11:27:28 -05:00
|
|
|
type Store interface {
|
2024-09-14 20:37:51 -05:00
|
|
|
Bootstrapper
|
|
|
|
|
PartStore
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type PartStore interface {
|
2024-09-14 11:27:28 -05:00
|
|
|
ClientSaver
|
|
|
|
|
ClientLister
|
|
|
|
|
proc.Store
|
|
|
|
|
proc.KeyLoader
|
|
|
|
|
osin.Storage
|
|
|
|
|
st.MetadataTyper
|
|
|
|
|
}
|