mirror of
https://github.com/MetaCubeX/mihomo.git
synced 2026-02-27 01:07:10 +00:00
chore: cleanup import path for constant/provider
This commit is contained in:
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
"github.com/metacubex/mihomo/common/utils"
|
||||
"github.com/metacubex/mihomo/component/slowdown"
|
||||
types "github.com/metacubex/mihomo/constant/provider"
|
||||
P "github.com/metacubex/mihomo/constant/provider"
|
||||
"github.com/metacubex/mihomo/log"
|
||||
|
||||
"github.com/metacubex/fswatch"
|
||||
@@ -22,7 +22,7 @@ type Fetcher[V any] struct {
|
||||
ctxCancel context.CancelFunc
|
||||
resourceType string
|
||||
name string
|
||||
vehicle types.Vehicle
|
||||
vehicle P.Vehicle
|
||||
updatedAt time.Time
|
||||
hash utils.HashType
|
||||
parser Parser[V]
|
||||
@@ -37,11 +37,11 @@ func (f *Fetcher[V]) Name() string {
|
||||
return f.name
|
||||
}
|
||||
|
||||
func (f *Fetcher[V]) Vehicle() types.Vehicle {
|
||||
func (f *Fetcher[V]) Vehicle() P.Vehicle {
|
||||
return f.vehicle
|
||||
}
|
||||
|
||||
func (f *Fetcher[V]) VehicleType() types.VehicleType {
|
||||
func (f *Fetcher[V]) VehicleType() P.VehicleType {
|
||||
return f.vehicle.Type()
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ func (f *Fetcher[V]) Update() (V, bool, error) {
|
||||
f.backoff.AddAttempt() // add a failed attempt to backoff
|
||||
return lo.Empty[V](), false, err
|
||||
}
|
||||
return f.loadBuf(buf, hash, f.vehicle.Type() != types.File)
|
||||
return f.loadBuf(buf, hash, f.vehicle.Type() != P.File)
|
||||
}
|
||||
|
||||
func (f *Fetcher[V]) SideUpdate(buf []byte) (V, bool, error) {
|
||||
@@ -180,7 +180,7 @@ func (f *Fetcher[V]) pullLoop(forceUpdate bool) {
|
||||
|
||||
func (f *Fetcher[V]) startPullLoop(forceUpdate bool) (err error) {
|
||||
// pull contents automatically
|
||||
if f.vehicle.Type() == types.File {
|
||||
if f.vehicle.Type() == P.File {
|
||||
f.watcher, err = fswatch.NewWatcher(fswatch.Options{
|
||||
Path: []string{f.vehicle.Path()},
|
||||
Callback: f.updateCallback,
|
||||
@@ -218,7 +218,7 @@ func (f *Fetcher[V]) updateWithLog() {
|
||||
return
|
||||
}
|
||||
|
||||
func NewFetcher[V any](name string, interval time.Duration, vehicle types.Vehicle, parser Parser[V], onUpdate func(V)) *Fetcher[V] {
|
||||
func NewFetcher[V any](name string, interval time.Duration, vehicle P.Vehicle, parser Parser[V], onUpdate func(V)) *Fetcher[V] {
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
minBackoff := 10 * time.Second
|
||||
if interval < minBackoff {
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/metacubex/mihomo/common/utils"
|
||||
mihomoHttp "github.com/metacubex/mihomo/component/http"
|
||||
"github.com/metacubex/mihomo/component/profile/cachefile"
|
||||
types "github.com/metacubex/mihomo/constant/provider"
|
||||
P "github.com/metacubex/mihomo/constant/provider"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -50,8 +50,8 @@ type FileVehicle struct {
|
||||
path string
|
||||
}
|
||||
|
||||
func (f *FileVehicle) Type() types.VehicleType {
|
||||
return types.File
|
||||
func (f *FileVehicle) Type() P.VehicleType {
|
||||
return P.File
|
||||
}
|
||||
|
||||
func (f *FileVehicle) Path() string {
|
||||
@@ -91,15 +91,15 @@ type HTTPVehicle struct {
|
||||
timeout time.Duration
|
||||
sizeLimit int64
|
||||
inRead func(response *http.Response)
|
||||
provider types.ProxyProvider
|
||||
provider P.ProxyProvider
|
||||
}
|
||||
|
||||
func (h *HTTPVehicle) Url() string {
|
||||
return h.url
|
||||
}
|
||||
|
||||
func (h *HTTPVehicle) Type() types.VehicleType {
|
||||
return types.HTTP
|
||||
func (h *HTTPVehicle) Type() P.VehicleType {
|
||||
return P.HTTP
|
||||
}
|
||||
|
||||
func (h *HTTPVehicle) Path() string {
|
||||
|
||||
Reference in New Issue
Block a user