archive plugin

This commit is contained in:
royalcat 2025-04-03 03:42:18 +04:00
parent 1912b5baf0
commit a02733a926
4 changed files with 26 additions and 14 deletions
edition
plugins
archive
qbittorrent
server/tstor

View file

@ -8,7 +8,7 @@ import (
func main() {
tstor.Run([]tstor.Plugin{
archive.Plugin,
archive.ArchivePlugin{},
qbittorrent.QBittorrentPlugin{},
})
}

View file

@ -17,14 +17,19 @@ const daemonName = "archive"
type ArchivePlugin struct{}
var _ tstor.Plugin = (*ArchivePlugin)(nil)
// Name implements tstor.Plugin.
func (a *ArchivePlugin) Name() string {
func (ArchivePlugin) Name() string {
return daemonName
}
var _ tstor.Plugin = (*ArchivePlugin)(nil)
var _ tstor.DaemonPlugin = (*ArchivePlugin)(nil)
var _ daemon.DaemonConstructor = NewDaemon
// NewDaemon implements tstor.DaemonPlugin.
func (a *ArchivePlugin) NewDaemon(context.Context, *koanf.Koanf) (daemon.Daemon, error) {
return &Daemon{}, nil
}
func NewDaemon(ctx context.Context, koanf *koanf.Koanf) (daemon.Daemon, error) {
return &Daemon{}, nil

View file

@ -17,6 +17,7 @@ import (
"git.kmsign.ru/royalcat/tstor/server/src/daemon"
"git.kmsign.ru/royalcat/tstor/server/src/logwrap"
"git.kmsign.ru/royalcat/tstor/server/src/vfs"
"git.kmsign.ru/royalcat/tstor/server/tstor"
"github.com/anacrolix/torrent/metainfo"
"github.com/anacrolix/torrent/types/infohash"
infohash_v2 "github.com/anacrolix/torrent/types/infohash-v2"
@ -26,6 +27,21 @@ import (
"go.opentelemetry.io/otel"
)
type QBittorrentPlugin struct {
}
var _ tstor.Plugin = (*QBittorrentPlugin)(nil)
func (QBittorrentPlugin) Name() string {
return daemonName
}
var _ tstor.DaemonPlugin = (*QBittorrentPlugin)(nil)
func (QBittorrentPlugin) NewDaemon(ctx context.Context, koanf *koanf.Koanf) (daemon.Daemon, error) {
return newDaemon(ctx, koanf)
}
var trace = otel.Tracer("git.kmsign.ru/royalcat/tstor/plugins/qbittorrent")
type Daemon struct {
@ -53,14 +69,7 @@ WebUI\Password_PBKDF2="@ByteArray(qef5I4wZBkDG+PP6/5mQwA==:LoTmorQM/QM5RHI4+dOiu
const daemonName = "qbittorrent"
type QBittorrentPlugin struct {
}
func (QBittorrentPlugin) Name() string {
return daemonName
}
func (QBittorrentPlugin) NewDaemon(ctx context.Context, koanf *koanf.Koanf) (daemon.Daemon, error) {
func newDaemon(ctx context.Context, koanf *koanf.Koanf) (daemon.Daemon, error) {
log := rlog.Component(daemonName)
log.Debug(ctx, "QBittorrent plugin loaded. Starting qbittorrent-nox")

View file

@ -4,7 +4,6 @@ import (
"context"
"git.kmsign.ru/royalcat/tstor/server/src/daemon"
"github.com/99designs/gqlgen/graphql"
"github.com/knadh/koanf/v2"
)
@ -14,5 +13,4 @@ type Plugin interface {
type DaemonPlugin interface {
NewDaemon(context.Context, *koanf.Koanf) (daemon.Daemon, error)
GraphQLExecutableSchema() graphql.ExecutableSchema
}