mirror of
https://github.com/J3vb/OwnCord.git
synced 2026-09-03 03:50:00 +03:00
Deletes Server/store (SQLiteStore, MemStore, the composed Store interface) and collapses to a single sqlc-backed db package, executing the prior audit's P4 "single data layer" direction (finding #6). SQLiteStore was a pure pass-through to *db.DB, so consumers now depend on narrow interfaces that *db.DB satisfies directly: - service.Store (service/datastore.go, renamed from store/store.go) - ws.EventStore (ws/eventstore.go) - plugin.PluginStore (plugin/pluginstore.go) The event- and plugin-KV methods that lived in the store's SQLite implementation move into the db package (db/event_queries.go, db/plugin_queries.go), keeping their raw-SQL form. Tests: the MemStore-based unit tests now run against a real in-memory SQLite db opened per-test with migrations applied, via package-local seed helpers. Fault-injection tests embed a real *db.DB and override the single method under test, preserving error-path coverage. Full server suite and sqlc-verify are green. Docs: audit finding #6 and A-2026-07-06 marked resolved; decisions D3 updated; architecture server.md / data-model.md diagrams and prose updated to the api -> service -> db layering. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UA17KPvqGBX3XbXYnMf1rA
26 lines
1.0 KiB
Go
26 lines
1.0 KiB
Go
package plugin
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/owncord/server/db"
|
|
)
|
|
|
|
// PluginStore manages installed plugins and per-plugin KV namespaces.
|
|
// *db.DB satisfies it (the methods moved into the db package when the store
|
|
// abstraction was removed in D3).
|
|
type PluginStore interface {
|
|
InstallPlugin(ctx context.Context, name, version, manifestJSON string) (int64, error)
|
|
EnablePlugin(ctx context.Context, id int64) error
|
|
DisablePlugin(ctx context.Context, id int64) error
|
|
UninstallPlugin(ctx context.Context, id int64) error
|
|
GetPlugin(ctx context.Context, id int64) (*db.PluginRow, error)
|
|
GetPluginByName(ctx context.Context, name string) (*db.PluginRow, error)
|
|
ListPlugins(ctx context.Context) ([]db.PluginRow, error)
|
|
|
|
PluginKVGet(ctx context.Context, pluginID int64, key string) ([]byte, error)
|
|
PluginKVSet(ctx context.Context, pluginID int64, key string, value []byte) error
|
|
PluginKVDelete(ctx context.Context, pluginID int64, key string) error
|
|
PluginKVScan(ctx context.Context, pluginID int64, prefix string, limit int) (map[string][]byte, error)
|
|
}
|