Skip to content

Commit

Permalink
chore: code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
wwqgtxx committed Mar 12, 2024
1 parent 012e448 commit 81c832e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
14 changes: 2 additions & 12 deletions adapter/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,13 @@ type proxySetProvider struct {
}

func (pp *proxySetProvider) MarshalJSON() ([]byte, error) {
expectedStatus := "*"
if pp.healthCheck.expectedStatus != nil {
expectedStatus = pp.healthCheck.expectedStatus.ToString()
}

return json.Marshal(map[string]any{
"name": pp.Name(),
"type": pp.Type().String(),
"vehicleType": pp.VehicleType().String(),
"proxies": pp.Proxies(),
"testUrl": pp.healthCheck.url,
"expectedStatus": expectedStatus,
"expectedStatus": pp.healthCheck.expectedStatus.String(),
"updatedAt": pp.UpdatedAt,
"subscriptionInfo": pp.subscriptionInfo,
})
Expand Down Expand Up @@ -221,18 +216,13 @@ type compatibleProvider struct {
}

func (cp *compatibleProvider) MarshalJSON() ([]byte, error) {
expectedStatus := "*"
if cp.healthCheck.expectedStatus != nil {
expectedStatus = cp.healthCheck.expectedStatus.ToString()
}

return json.Marshal(map[string]any{
"name": cp.Name(),
"type": cp.Type().String(),
"vehicleType": cp.VehicleType().String(),
"proxies": cp.Proxies(),
"testUrl": cp.healthCheck.url,
"expectedStatus": expectedStatus,
"expectedStatus": cp.healthCheck.expectedStatus.String(),
})
}

Expand Down
6 changes: 5 additions & 1 deletion common/utils/ranges.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (ranges IntRanges[T]) Check(status T) bool {
return false
}

func (ranges IntRanges[T]) ToString() string {
func (ranges IntRanges[T]) String() string {
if len(ranges) == 0 {
return "*"
}
Expand All @@ -134,6 +134,10 @@ func (ranges IntRanges[T]) ToString() string {
}

func (ranges IntRanges[T]) Range(f func(t T) bool) {
if len(ranges) == 0 {
return
}

for _, r := range ranges {
for i := r.Start(); i <= r.End(); i++ {
if !f(i) {
Expand Down

0 comments on commit 81c832e

Please sign in to comment.