dht store and stats query
This commit is contained in:
parent
93892a6f1d
commit
d5aa78cb39
13 changed files with 1114 additions and 74 deletions
src/delivery
File diff suppressed because it is too large
Load diff
|
@ -191,7 +191,8 @@ type TorrentDaemonMutation struct {
|
|||
}
|
||||
|
||||
type TorrentDaemonQuery struct {
|
||||
Torrents []*Torrent `json:"torrents"`
|
||||
Torrents []*Torrent `json:"torrents"`
|
||||
Stats *TorrentStats `json:"stats"`
|
||||
}
|
||||
|
||||
type TorrentFs struct {
|
||||
|
@ -269,6 +270,22 @@ func (TorrentProgress) IsProgress() {}
|
|||
func (this TorrentProgress) GetCurrent() int64 { return this.Current }
|
||||
func (this TorrentProgress) GetTotal() int64 { return this.Total }
|
||||
|
||||
type TorrentStats 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 TorrentsFilter struct {
|
||||
Infohash *StringFilter `json:"infohash,omitempty"`
|
||||
Name *StringFilter `json:"name,omitempty"`
|
||||
|
|
|
@ -86,6 +86,26 @@ func (r *torrentDaemonQueryResolver) Torrents(ctx context.Context, obj *model.To
|
|||
return tr, nil
|
||||
}
|
||||
|
||||
// Stats is the resolver for the stats field.
|
||||
func (r *torrentDaemonQueryResolver) Stats(ctx context.Context, obj *model.TorrentDaemonQuery) (*model.TorrentStats, error) {
|
||||
stats := r.Service.Stats()
|
||||
return &model.TorrentStats{
|
||||
BytesWritten: stats.BytesWritten.Int64(),
|
||||
BytesRead: stats.BytesRead.Int64(),
|
||||
BytesWrittenData: stats.BytesWrittenData.Int64(),
|
||||
BytesReadData: stats.BytesReadData.Int64(),
|
||||
BytesReadUsefulData: stats.BytesReadUsefulData.Int64(),
|
||||
BytesReadUsefulIntendedData: stats.BytesReadUsefulIntendedData.Int64(),
|
||||
ChunksWritten: stats.ChunksWritten.Int64(),
|
||||
ChunksRead: stats.ChunksRead.Int64(),
|
||||
ChunksReadUseful: stats.ChunksReadUseful.Int64(),
|
||||
ChunksReadWasted: stats.ChunksReadWasted.Int64(),
|
||||
MetadataChunksRead: stats.MetadataChunksRead.Int64(),
|
||||
PiecesDirtiedGood: stats.PiecesDirtiedGood.Int64(),
|
||||
PiecesDirtiedBad: stats.PiecesDirtiedBad.Int64(),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// TorrentDaemonQuery returns graph.TorrentDaemonQueryResolver implementation.
|
||||
func (r *Resolver) TorrentDaemonQuery() graph.TorrentDaemonQueryResolver {
|
||||
return &torrentDaemonQueryResolver{r}
|
||||
|
|
|
@ -23,7 +23,7 @@ func New(fc *filecache.Cache, s *torrent.Daemon, vfs vfs.Filesystem, logPath str
|
|||
// middleware.Recover(),
|
||||
middleware.Gzip(),
|
||||
middleware.Decompress(),
|
||||
Logger(),
|
||||
// Logger(),
|
||||
)
|
||||
|
||||
echopprof.Register(r)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue