-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add download stats info #323
Conversation
做 |
Okay, I'll update it later |
是否可以新增一个 base.Stats 直接存放统计的一些信息,直接绕过使用 any 类型断言这种 map 取值的方式 // Stats for download |
这样主要是为了Downloader和Fetcher之间解耦,目前都是这样设计的,比如 Request里的extra,我之前尝试过用go泛型来处理,但是go的泛型做的太拉胯了搞不定,所以只能用any了 |
我懂你意思,但是我看目前抽出来的这三个字段还是只适用于bt协议,并不通用呀,每个协议之间的stats数据都会差异很大,干脆就断言处理吧,golang好像也不支持多态,不然可以定个基类后续有通用的字段再放到基类里 |
ok 晚点我调整后测试完呼叫你我们再看看 |
@monkeyWie 这样如何呢 |
pkg/base/model.go
Outdated
type BtStats struct { | ||
// bt stats | ||
// health indicators of torrents, from large to small, ConnectedSeeders are also the key to the health of seed resources | ||
TotalPeers int `json:"totalPeers"` | ||
ActivePeers int `json:"activePeers"` | ||
ConnectedSeeders int `json:"connectedSeeders"` | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move to pkg/protocol/bt/model.go
pkg/base/model.go
Outdated
type HttpStats struct { | ||
// http stats | ||
// health indicators of http | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move to pkg/protocol/http/model.go
嗯嗯 差不多了,再调整下包路径就行 |
Codecov ReportAttention:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #323 +/- ##
==========================================
- Coverage 61.06% 60.82% -0.24%
==========================================
Files 19 19
Lines 2866 2877 +11
==========================================
Hits 1750 1750
- Misses 920 931 +11
Partials 196 196 ☔ View full report in Codecov by Sentry. |
哦,还有个点得调整下,就是stats应该做成实时去获取的,不用去定时refresh,通过实现fetcher接口的Stats()方法拿就行了,就和Progress()那个定义一样,然后meta那里就不用放stats了 |
ok |
Display bt download health indicators
770ecd8
to
7525766
Compare
internal/fetcher/fetcher.go
Outdated
Req *base.Request `json:"req"` | ||
Res *base.Resource `json:"res"` | ||
Opts *base.Options `json:"opts"` | ||
Stats any `json:"stats"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里可以不要了
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
…map_writes into dc/feature/healthy
Nice! |
应该暂时还没有办法调用到这个 stats 接口吧,这里我后续
|
#218
Hope it can increase health attributes
The ecology of bt resources is not good. Most downloads do not have public IP addresses. Many resources may not be downloadable. The purpose of adding this attribute is to visualize the health of the currently downloaded resources. If the attributes are all 0, you can give up directly. Changed resources
===
Currently three attributes have been added
It can be similar to bitcomet's total number of users, number of active users, and number of seed resources, which can describe the health of seeds to users.
===
可以看看还有什么需要修改注意的地方值得补充的,我在做一下测试,你可以先看看当前的改动有什么问题没有,测完了我同步发到这边,我们一起看看
我基于这个做了一些测试,可以很好的反应下载的健康情况,无效的torrent资源各项值都为0,或者后两者属性都为0,机器热门的资源三个属性数目都极高
==