This commit is contained in:
parent
5b11b70370
commit
a89b9e7303
10 changed files with 159 additions and 320 deletions
|
@ -4,18 +4,16 @@ schema:
|
|||
- ../../graphql/types/*.graphql
|
||||
|
||||
exec:
|
||||
filename: generated/graphql/generated.go
|
||||
package: graph
|
||||
|
||||
filename: delivery/graphql/generated.go
|
||||
model:
|
||||
filename: generated/graphql/model/models_gen.go
|
||||
package: model
|
||||
|
||||
filename: delivery/graphql/models_gen.go
|
||||
resolver:
|
||||
type: Resolver
|
||||
layout: follow-schema
|
||||
dir: generated/graphql/resolver
|
||||
package: resolver
|
||||
filename_template: "{name}.resolvers.go"
|
||||
dir: delivery/graphql
|
||||
|
||||
autobind:
|
||||
- "git.kmsign.ru/royalcat/tstor/src/delivery/graphql/model"
|
||||
|
||||
models:
|
||||
DateTime:
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package resolver
|
||||
package graphql
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.kmsign.ru/royalcat/tstor/daemons/atorrent/generated/graphql/model"
|
||||
"git.kmsign.ru/royalcat/tstor/src/delivery/graphql/model"
|
||||
)
|
||||
|
||||
func (r *torrentFSResolver) Entries(ctx context.Context, obj *model.TorrentFs) ([]model.FsEntry, error) {
|
|
@ -1,4 +1,4 @@
|
|||
package model
|
||||
package graphql
|
||||
|
||||
import (
|
||||
"context"
|
140
daemons/atorrent/delivery/graphql/models_gen.go
Normal file
140
daemons/atorrent/delivery/graphql/models_gen.go
Normal file
|
@ -0,0 +1,140 @@
|
|||
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
|
||||
|
||||
package graphql
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"git.kmsign.ru/royalcat/tstor/daemons/atorrent"
|
||||
"git.kmsign.ru/royalcat/tstor/src/delivery/graphql/model"
|
||||
"github.com/anacrolix/torrent"
|
||||
"github.com/anacrolix/torrent/types"
|
||||
)
|
||||
|
||||
type CleanupResponse struct {
|
||||
Count int64 `json:"count"`
|
||||
List []string `json:"list"`
|
||||
}
|
||||
|
||||
type DownloadTorrentResponse struct {
|
||||
TaskID string `json:"taskID"`
|
||||
}
|
||||
|
||||
type Torrent struct {
|
||||
Name string `json:"name"`
|
||||
Infohash string `json:"infohash"`
|
||||
BytesCompleted int64 `json:"bytesCompleted"`
|
||||
TorrentFilePath string `json:"torrentFilePath"`
|
||||
BytesMissing int64 `json:"bytesMissing"`
|
||||
Priority types.PiecePriority `json:"priority"`
|
||||
Files []*TorrentFile `json:"files"`
|
||||
ExcludedFiles []*TorrentFile `json:"excludedFiles"`
|
||||
Peers []*TorrentPeer `json:"peers"`
|
||||
T *atorrent.Controller `json:"-"`
|
||||
}
|
||||
|
||||
type TorrentClientStats struct {
|
||||
BytesWritten int64 `json:"bytesWritten"`
|
||||
BytesWrittenData int64 `json:"bytesWrittenData"`
|
||||
BytesRead int64 `json:"bytesRead"`
|
||||
BytesReadData int64 `json:"bytesReadData"`
|
||||
BytesReadUsefulData int64 `json:"bytesReadUsefulData"`
|
||||
BytesReadUsefulIntendedData int64 `json:"bytesReadUsefulIntendedData"`
|
||||
ChunksWritten int64 `json:"chunksWritten"`
|
||||
ChunksRead int64 `json:"chunksRead"`
|
||||
ChunksReadUseful int64 `json:"chunksReadUseful"`
|
||||
ChunksReadWasted int64 `json:"chunksReadWasted"`
|
||||
MetadataChunksRead int64 `json:"metadataChunksRead"`
|
||||
PiecesDirtiedGood int64 `json:"piecesDirtiedGood"`
|
||||
PiecesDirtiedBad int64 `json:"piecesDirtiedBad"`
|
||||
}
|
||||
|
||||
type TorrentDaemonMutation struct {
|
||||
ValidateTorrent bool `json:"validateTorrent"`
|
||||
SetTorrentPriority bool `json:"setTorrentPriority"`
|
||||
Cleanup *CleanupResponse `json:"cleanup"`
|
||||
}
|
||||
|
||||
type TorrentDaemonQuery struct {
|
||||
Torrents []*Torrent `json:"torrents"`
|
||||
ClientStats *TorrentClientStats `json:"clientStats"`
|
||||
StatsHistory []*TorrentStats `json:"statsHistory"`
|
||||
}
|
||||
|
||||
type TorrentFs struct {
|
||||
Name string `json:"name"`
|
||||
Torrent *Torrent `json:"torrent"`
|
||||
Entries []model.FsEntry `json:"entries"`
|
||||
FS *atorrent.TorrentFS `json:"-"`
|
||||
}
|
||||
|
||||
func (TorrentFs) IsDir() {}
|
||||
|
||||
func (TorrentFs) IsFsEntry() {}
|
||||
|
||||
type TorrentFile struct {
|
||||
Filename string `json:"filename"`
|
||||
Size int64 `json:"size"`
|
||||
BytesCompleted int64 `json:"bytesCompleted"`
|
||||
Priority types.PiecePriority `json:"priority"`
|
||||
F *atorrent.FileController `json:"-"`
|
||||
}
|
||||
|
||||
type TorrentFileEntry struct {
|
||||
Name string `json:"name"`
|
||||
Torrent *Torrent `json:"torrent"`
|
||||
Size int64 `json:"size"`
|
||||
}
|
||||
|
||||
func (TorrentFileEntry) IsFile() {}
|
||||
|
||||
func (TorrentFileEntry) IsFsEntry() {}
|
||||
|
||||
type TorrentFilter struct {
|
||||
Everything *bool `json:"everything,omitempty"`
|
||||
Infohash *string `json:"infohash,omitempty"`
|
||||
}
|
||||
|
||||
type TorrentPeer struct {
|
||||
IP string `json:"ip"`
|
||||
DownloadRate float64 `json:"downloadRate"`
|
||||
Discovery string `json:"discovery"`
|
||||
Port int64 `json:"port"`
|
||||
ClientName string `json:"clientName"`
|
||||
F *torrent.PeerConn `json:"-"`
|
||||
}
|
||||
|
||||
type TorrentPriorityFilter struct {
|
||||
Eq *types.PiecePriority `json:"eq,omitempty"`
|
||||
Gt *types.PiecePriority `json:"gt,omitempty"`
|
||||
Lt *types.PiecePriority `json:"lt,omitempty"`
|
||||
Gte *types.PiecePriority `json:"gte,omitempty"`
|
||||
Lte *types.PiecePriority `json:"lte,omitempty"`
|
||||
In []types.PiecePriority `json:"in,omitempty"`
|
||||
}
|
||||
|
||||
type TorrentProgress struct {
|
||||
Torrent *Torrent `json:"torrent"`
|
||||
Current int64 `json:"current"`
|
||||
Total int64 `json:"total"`
|
||||
}
|
||||
|
||||
func (TorrentProgress) IsProgress() {}
|
||||
|
||||
type TorrentStats struct {
|
||||
Timestamp time.Time `json:"timestamp"`
|
||||
DownloadedBytes uint `json:"downloadedBytes"`
|
||||
UploadedBytes uint `json:"uploadedBytes"`
|
||||
TotalPeers uint `json:"totalPeers"`
|
||||
ActivePeers uint `json:"activePeers"`
|
||||
ConnectedSeeders uint `json:"connectedSeeders"`
|
||||
}
|
||||
|
||||
type TorrentsFilter struct {
|
||||
Infohash *model.StringFilter `json:"infohash,omitempty"`
|
||||
Name *model.StringFilter `json:"name,omitempty"`
|
||||
BytesCompleted *model.IntFilter `json:"bytesCompleted,omitempty"`
|
||||
BytesMissing *model.IntFilter `json:"bytesMissing,omitempty"`
|
||||
PeersCount *model.IntFilter `json:"peersCount,omitempty"`
|
||||
Priority *TorrentPriorityFilter `json:"priority,omitempty"`
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package resolver
|
||||
package graphql
|
||||
|
||||
import (
|
||||
"git.kmsign.ru/royalcat/tstor/daemons/atorrent"
|
|
@ -1,4 +1,4 @@
|
|||
package resolver
|
||||
package graphql
|
||||
|
||||
// This file will be automatically regenerated based on the schema, any resolver implementations
|
||||
// will be copied through when generating and any unknown code will be moved to the end.
|
||||
|
@ -7,14 +7,12 @@ package resolver
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"git.kmsign.ru/royalcat/tstor/daemons/atorrent/generated/graphql/model"
|
||||
)
|
||||
|
||||
type subscriptionResolver struct{ *Resolver }
|
||||
|
||||
func (r *subscriptionResolver) TorrentDownloadUpdates(ctx context.Context) (<-chan *model.TorrentProgress, error) {
|
||||
out := make(chan *model.TorrentProgress)
|
||||
func (r *subscriptionResolver) TorrentDownloadUpdates(ctx context.Context) (<-chan *TorrentProgress, error) {
|
||||
out := make(chan *TorrentProgress)
|
||||
progress, err := r.ATorrentDaemon.DownloadProgress(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -27,12 +25,12 @@ func (r *subscriptionResolver) TorrentDownloadUpdates(ctx context.Context) (<-ch
|
|||
fmt.Println("nil torrent")
|
||||
continue
|
||||
}
|
||||
torrent, err := model.MapTorrent(ctx, p.Torrent)
|
||||
torrent, err := MapTorrent(ctx, p.Torrent)
|
||||
if err != nil {
|
||||
// TODO logs
|
||||
continue
|
||||
}
|
||||
po := &model.TorrentProgress{
|
||||
po := &TorrentProgress{
|
||||
Torrent: torrent,
|
||||
Current: p.Current,
|
||||
Total: p.Total,
|
|
@ -1,4 +1,4 @@
|
|||
package resolver
|
||||
package graphql
|
||||
|
||||
// This file will be automatically regenerated based on the schema, any resolver implementations
|
||||
// will be copied through when generating and any unknown code will be moved to the end.
|
|
@ -1,4 +1,4 @@
|
|||
package resolver
|
||||
package graphql
|
||||
|
||||
// This file will be automatically regenerated based on the schema, any resolver implementations
|
||||
// will be copied through when generating and any unknown code will be moved to the end.
|
|
@ -1,4 +1,4 @@
|
|||
package resolver
|
||||
package graphql
|
||||
|
||||
// This file will be automatically regenerated based on the schema, any resolver implementations
|
||||
// will be copied through when generating and any unknown code will be moved to the end.
|
|
@ -1,297 +0,0 @@
|
|||
// Code generated by github.com/99designs/gqlgen, DO NOT EDIT.
|
||||
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"git.kmsign.ru/royalcat/tstor/daemons/atorrent"
|
||||
"git.kmsign.ru/royalcat/tstor/src/vfs"
|
||||
"github.com/anacrolix/torrent"
|
||||
"github.com/anacrolix/torrent/types"
|
||||
)
|
||||
|
||||
type Dir interface {
|
||||
IsFsEntry()
|
||||
IsDir()
|
||||
GetName() string
|
||||
GetEntries() []FsEntry
|
||||
}
|
||||
|
||||
type File interface {
|
||||
IsFsEntry()
|
||||
IsFile()
|
||||
GetName() string
|
||||
GetSize() int64
|
||||
}
|
||||
|
||||
type FsEntry interface {
|
||||
IsFsEntry()
|
||||
GetName() string
|
||||
}
|
||||
|
||||
type Progress interface {
|
||||
IsProgress()
|
||||
GetCurrent() int64
|
||||
GetTotal() int64
|
||||
}
|
||||
|
||||
type ArchiveFs struct {
|
||||
Name string `json:"name"`
|
||||
Entries []FsEntry `json:"entries"`
|
||||
Size int64 `json:"size"`
|
||||
}
|
||||
|
||||
func (ArchiveFs) IsDir() {}
|
||||
func (this ArchiveFs) GetName() string { return this.Name }
|
||||
func (this ArchiveFs) GetEntries() []FsEntry {
|
||||
if this.Entries == nil {
|
||||
return nil
|
||||
}
|
||||
interfaceSlice := make([]FsEntry, 0, len(this.Entries))
|
||||
for _, concrete := range this.Entries {
|
||||
interfaceSlice = append(interfaceSlice, concrete)
|
||||
}
|
||||
return interfaceSlice
|
||||
}
|
||||
|
||||
func (ArchiveFs) IsFsEntry() {}
|
||||
|
||||
type BooleanFilter struct {
|
||||
Eq *bool `json:"eq,omitempty"`
|
||||
}
|
||||
|
||||
type CleanupResponse struct {
|
||||
Count int64 `json:"count"`
|
||||
List []string `json:"list"`
|
||||
}
|
||||
|
||||
type DateTimeFilter struct {
|
||||
Eq *time.Time `json:"eq,omitempty"`
|
||||
Gt *time.Time `json:"gt,omitempty"`
|
||||
Lt *time.Time `json:"lt,omitempty"`
|
||||
Gte *time.Time `json:"gte,omitempty"`
|
||||
Lte *time.Time `json:"lte,omitempty"`
|
||||
}
|
||||
|
||||
type DownloadTorrentResponse struct {
|
||||
TaskID string `json:"taskID"`
|
||||
}
|
||||
|
||||
type IntFilter struct {
|
||||
Eq *int64 `json:"eq,omitempty"`
|
||||
Gt *int64 `json:"gt,omitempty"`
|
||||
Lt *int64 `json:"lt,omitempty"`
|
||||
Gte *int64 `json:"gte,omitempty"`
|
||||
Lte *int64 `json:"lte,omitempty"`
|
||||
In []int64 `json:"in,omitempty"`
|
||||
}
|
||||
|
||||
type Mutation struct {
|
||||
}
|
||||
|
||||
type Pagination struct {
|
||||
Offset int64 `json:"offset"`
|
||||
Limit int64 `json:"limit"`
|
||||
}
|
||||
|
||||
type Query struct {
|
||||
}
|
||||
|
||||
type ResolverFs struct {
|
||||
Name string `json:"name"`
|
||||
Entries []FsEntry `json:"entries"`
|
||||
}
|
||||
|
||||
func (ResolverFs) IsDir() {}
|
||||
func (this ResolverFs) GetName() string { return this.Name }
|
||||
func (this ResolverFs) GetEntries() []FsEntry {
|
||||
if this.Entries == nil {
|
||||
return nil
|
||||
}
|
||||
interfaceSlice := make([]FsEntry, 0, len(this.Entries))
|
||||
for _, concrete := range this.Entries {
|
||||
interfaceSlice = append(interfaceSlice, concrete)
|
||||
}
|
||||
return interfaceSlice
|
||||
}
|
||||
|
||||
func (ResolverFs) IsFsEntry() {}
|
||||
|
||||
type Schema struct {
|
||||
Query *Query `json:"query,omitempty"`
|
||||
Mutation *Mutation `json:"mutation,omitempty"`
|
||||
}
|
||||
|
||||
type SimpleDir struct {
|
||||
Name string `json:"name"`
|
||||
Entries []FsEntry `json:"entries"`
|
||||
FS vfs.Filesystem `json:"-"`
|
||||
Path string `json:"-"`
|
||||
}
|
||||
|
||||
func (SimpleDir) IsDir() {}
|
||||
func (this SimpleDir) GetName() string { return this.Name }
|
||||
func (this SimpleDir) GetEntries() []FsEntry {
|
||||
if this.Entries == nil {
|
||||
return nil
|
||||
}
|
||||
interfaceSlice := make([]FsEntry, 0, len(this.Entries))
|
||||
for _, concrete := range this.Entries {
|
||||
interfaceSlice = append(interfaceSlice, concrete)
|
||||
}
|
||||
return interfaceSlice
|
||||
}
|
||||
|
||||
func (SimpleDir) IsFsEntry() {}
|
||||
|
||||
type SimpleFile struct {
|
||||
Name string `json:"name"`
|
||||
Size int64 `json:"size"`
|
||||
}
|
||||
|
||||
func (SimpleFile) IsFile() {}
|
||||
func (this SimpleFile) GetName() string { return this.Name }
|
||||
func (this SimpleFile) GetSize() int64 { return this.Size }
|
||||
|
||||
func (SimpleFile) IsFsEntry() {}
|
||||
|
||||
type StringFilter struct {
|
||||
Eq *string `json:"eq,omitempty"`
|
||||
Substr *string `json:"substr,omitempty"`
|
||||
In []string `json:"in,omitempty"`
|
||||
}
|
||||
|
||||
type Torrent struct {
|
||||
Name string `json:"name"`
|
||||
Infohash string `json:"infohash"`
|
||||
BytesCompleted int64 `json:"bytesCompleted"`
|
||||
TorrentFilePath string `json:"torrentFilePath"`
|
||||
BytesMissing int64 `json:"bytesMissing"`
|
||||
Priority types.PiecePriority `json:"priority"`
|
||||
Files []*TorrentFile `json:"files"`
|
||||
ExcludedFiles []*TorrentFile `json:"excludedFiles"`
|
||||
Peers []*TorrentPeer `json:"peers"`
|
||||
T *atorrent.Controller `json:"-"`
|
||||
}
|
||||
|
||||
type TorrentClientStats struct {
|
||||
BytesWritten int64 `json:"bytesWritten"`
|
||||
BytesWrittenData int64 `json:"bytesWrittenData"`
|
||||
BytesRead int64 `json:"bytesRead"`
|
||||
BytesReadData int64 `json:"bytesReadData"`
|
||||
BytesReadUsefulData int64 `json:"bytesReadUsefulData"`
|
||||
BytesReadUsefulIntendedData int64 `json:"bytesReadUsefulIntendedData"`
|
||||
ChunksWritten int64 `json:"chunksWritten"`
|
||||
ChunksRead int64 `json:"chunksRead"`
|
||||
ChunksReadUseful int64 `json:"chunksReadUseful"`
|
||||
ChunksReadWasted int64 `json:"chunksReadWasted"`
|
||||
MetadataChunksRead int64 `json:"metadataChunksRead"`
|
||||
PiecesDirtiedGood int64 `json:"piecesDirtiedGood"`
|
||||
PiecesDirtiedBad int64 `json:"piecesDirtiedBad"`
|
||||
}
|
||||
|
||||
type TorrentDaemonMutation struct {
|
||||
ValidateTorrent bool `json:"validateTorrent"`
|
||||
SetTorrentPriority bool `json:"setTorrentPriority"`
|
||||
Cleanup *CleanupResponse `json:"cleanup"`
|
||||
}
|
||||
|
||||
type TorrentDaemonQuery struct {
|
||||
Torrents []*Torrent `json:"torrents"`
|
||||
ClientStats *TorrentClientStats `json:"clientStats"`
|
||||
StatsHistory []*TorrentStats `json:"statsHistory"`
|
||||
}
|
||||
|
||||
type TorrentFs struct {
|
||||
Name string `json:"name"`
|
||||
Torrent *Torrent `json:"torrent"`
|
||||
Entries []FsEntry `json:"entries"`
|
||||
FS *atorrent.TorrentFS `json:"-"`
|
||||
}
|
||||
|
||||
func (TorrentFs) IsDir() {}
|
||||
func (this TorrentFs) GetName() string { return this.Name }
|
||||
func (this TorrentFs) GetEntries() []FsEntry {
|
||||
if this.Entries == nil {
|
||||
return nil
|
||||
}
|
||||
interfaceSlice := make([]FsEntry, 0, len(this.Entries))
|
||||
for _, concrete := range this.Entries {
|
||||
interfaceSlice = append(interfaceSlice, concrete)
|
||||
}
|
||||
return interfaceSlice
|
||||
}
|
||||
|
||||
func (TorrentFs) IsFsEntry() {}
|
||||
|
||||
type TorrentFile struct {
|
||||
Filename string `json:"filename"`
|
||||
Size int64 `json:"size"`
|
||||
BytesCompleted int64 `json:"bytesCompleted"`
|
||||
Priority types.PiecePriority `json:"priority"`
|
||||
F *atorrent.FileController `json:"-"`
|
||||
}
|
||||
|
||||
type TorrentFileEntry struct {
|
||||
Name string `json:"name"`
|
||||
Torrent *Torrent `json:"torrent"`
|
||||
Size int64 `json:"size"`
|
||||
}
|
||||
|
||||
func (TorrentFileEntry) IsFile() {}
|
||||
func (this TorrentFileEntry) GetName() string { return this.Name }
|
||||
func (this TorrentFileEntry) GetSize() int64 { return this.Size }
|
||||
|
||||
func (TorrentFileEntry) IsFsEntry() {}
|
||||
|
||||
type TorrentFilter struct {
|
||||
Everything *bool `json:"everything,omitempty"`
|
||||
Infohash *string `json:"infohash,omitempty"`
|
||||
}
|
||||
|
||||
type TorrentPeer struct {
|
||||
IP string `json:"ip"`
|
||||
DownloadRate float64 `json:"downloadRate"`
|
||||
Discovery string `json:"discovery"`
|
||||
Port int64 `json:"port"`
|
||||
ClientName string `json:"clientName"`
|
||||
F *torrent.PeerConn `json:"-"`
|
||||
}
|
||||
|
||||
type TorrentPriorityFilter struct {
|
||||
Eq *types.PiecePriority `json:"eq,omitempty"`
|
||||
Gt *types.PiecePriority `json:"gt,omitempty"`
|
||||
Lt *types.PiecePriority `json:"lt,omitempty"`
|
||||
Gte *types.PiecePriority `json:"gte,omitempty"`
|
||||
Lte *types.PiecePriority `json:"lte,omitempty"`
|
||||
In []types.PiecePriority `json:"in,omitempty"`
|
||||
}
|
||||
|
||||
type TorrentProgress struct {
|
||||
Torrent *Torrent `json:"torrent"`
|
||||
Current int64 `json:"current"`
|
||||
Total int64 `json:"total"`
|
||||
}
|
||||
|
||||
func (TorrentProgress) IsProgress() {}
|
||||
func (this TorrentProgress) GetCurrent() int64 { return this.Current }
|
||||
func (this TorrentProgress) GetTotal() int64 { return this.Total }
|
||||
|
||||
type TorrentStats struct {
|
||||
Timestamp time.Time `json:"timestamp"`
|
||||
DownloadedBytes uint `json:"downloadedBytes"`
|
||||
UploadedBytes uint `json:"uploadedBytes"`
|
||||
TotalPeers uint `json:"totalPeers"`
|
||||
ActivePeers uint `json:"activePeers"`
|
||||
ConnectedSeeders uint `json:"connectedSeeders"`
|
||||
}
|
||||
|
||||
type TorrentsFilter struct {
|
||||
Infohash *StringFilter `json:"infohash,omitempty"`
|
||||
Name *StringFilter `json:"name,omitempty"`
|
||||
BytesCompleted *IntFilter `json:"bytesCompleted,omitempty"`
|
||||
BytesMissing *IntFilter `json:"bytesMissing,omitempty"`
|
||||
PeersCount *IntFilter `json:"peersCount,omitempty"`
|
||||
Priority *TorrentPriorityFilter `json:"priority,omitempty"`
|
||||
}
|
Loading…
Reference in a new issue