Skip to content

Commit

Permalink
chore: add Count for ProxyProvider
Browse files Browse the repository at this point in the history
  • Loading branch information
wwqgtxx committed Sep 9, 2024
1 parent b1301b1 commit 595a575
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions adapter/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ func (pp *proxySetProvider) Proxies() []C.Proxy {
return pp.proxies
}

func (pp *proxySetProvider) Count() int {
return len(pp.proxies)
}

func (pp *proxySetProvider) Touch() {
pp.healthCheck.touch()
}
Expand Down Expand Up @@ -267,6 +271,10 @@ func (cp *compatibleProvider) Proxies() []C.Proxy {
return cp.proxies
}

func (cp *compatibleProvider) Count() int {
return len(cp.proxies)
}

func (cp *compatibleProvider) Touch() {
cp.healthCheck.touch()
}
Expand Down
1 change: 1 addition & 0 deletions constant/provider/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ type Provider interface {
type ProxyProvider interface {
Provider
Proxies() []constant.Proxy
Count() int
// Touch is used to inform the provider that the proxy is actually being used while getting the list of proxies.
// Commonly used in DialContext and DialPacketConn
Touch()
Expand Down

0 comments on commit 595a575

Please sign in to comment.