Skip to content
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

Remove unused tags from discovery #110

Merged
merged 2 commits into from
Jul 15, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Remove unused tags from discovery
soffokl committed Jul 15, 2024

Verified

This commit was signed with the committer’s verified signature.
soffokl Dmitry Shihovtsev
commit b85962d54913d5030754b10694c65ee5b2f616d0
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@
### Features
* Fetch MYST prices from the public API
* Create prices for nodes based on the load and multiplier in the countries
* Listen for proposals from NATS Broker and enhance them with quality metrics and tags
* Listen for proposals from NATS Broker and enhance them with quality metrics
* Run proposal expiration job
* Update price config by Universe Admin
* Use Postgres to save proposals, configs, and country multipliers
@@ -27,7 +27,6 @@ MYSTERIUM_LOG_MODE=json
PORT=8080
QUALITY_ORACLE_URL=https://testnet3-quality.mysterium.network
QUALITY_CACHE_TTL=20s
BADGER_ADDRESS=https://testnet3-badger.mysterium.network
BROKER_URL=nats://testnet3-broker.mysterium.network
UNIVERSE_JWT_SECRET=Some_Secret
REDIS_ADDRESS=redis:6379
@@ -63,7 +62,6 @@ COINRANKING_TOKEN=Some_Token
#### Code structure

* `/config` - [Discovery] config parser. Env params
* `/tags` - [Discovery] Tags proposals enhancer for SuperProxy
* `/docs` - [Discovery] Auto generated Swagger for REST API
* `/e2e` - e2e tests
* `/health` - [Discovery] health checker REST API
4 changes: 1 addition & 3 deletions cmd/main.go
Original file line number Diff line number Diff line change
@@ -25,7 +25,6 @@ import (
"github.com/mysteriumnetwork/discovery/proposal"
"github.com/mysteriumnetwork/discovery/quality"
"github.com/mysteriumnetwork/discovery/quality/oracleapi"
"github.com/mysteriumnetwork/discovery/tags"
"github.com/mysteriumnetwork/go-rest/apierror"
mlog "github.com/mysteriumnetwork/logger"
)
@@ -62,8 +61,7 @@ func main() {
pprof.RouteRegister(devGroup, "pprof")
}

tagEnhancer := tags.NewEnhancer(tags.NewApi(cfg.BadgerAddress.String()))
proposalRepo := proposal.NewRepository([]proposal.Enhancer{tagEnhancer}, cfg.ProposalsHardLimitPerCountry, cfg.ProposalsSoftLimitPerCountry, cfg.CompatibilityMin)
proposalRepo := proposal.NewRepository(cfg.ProposalsHardLimitPerCountry, cfg.ProposalsSoftLimitPerCountry, cfg.CompatibilityMin)
qualityOracleAPI := oracleapi.New(cfg.QualityOracleURL.String())
qualityService := quality.NewService(qualityOracleAPI, cfg.QualityCacheTTL)
proposalService := proposal.NewService(proposalRepo, qualityService)
7 changes: 0 additions & 7 deletions config/options.go
Original file line number Diff line number Diff line change
@@ -25,8 +25,6 @@ type Options struct {
RedisPass string
RedisDB int

BadgerAddress url.URL

LocationAddress url.URL
LocationUser string
LocationPass string
@@ -74,10 +72,6 @@ func ReadDiscovery() (*Options, error) {
if err != nil {
return nil, err
}
badgerAddress, err := RequiredEnvURL("BADGER_ADDRESS")
if err != nil {
return nil, err
}

compatibility, err := OptionalEnvInt("COMPATIBILITY_MIN", "0")
if err != nil {
@@ -114,7 +108,6 @@ func ReadDiscovery() (*Options, error) {
QualityOracleURL: *qualityOracleURL,
QualityCacheTTL: *qualityCacheTTL,
BrokerURL: *brokerURL,
BadgerAddress: *badgerAddress,
LocationAddress: *locationAddress,
LocationUser: locationUser,
LocationPass: locationPass,
1 change: 0 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
@@ -14,7 +14,6 @@ services:
- PORT=8080
- QUALITY_ORACLE_URL=https://quality.mysterium.network
- QUALITY_CACHE_TTL=20s
- BADGER_ADDRESS=https://badger.mysterium.network
- BROKER_URL=nats://broker.mysterium.network
- UNIVERSE_JWT_SECRET=suchsecret
- REDIS_ADDRESS=redis:6379
7 changes: 4 additions & 3 deletions e2e/api.go
Original file line number Diff line number Diff line change
@@ -11,8 +11,10 @@ import (
v3 "github.com/mysteriumnetwork/discovery/proposal/v3"
)

var DiscoveryAPI = newDiscoveryAPI(DiscoveryAPIurl)
var PricerAPI = newPricingAPI(PricerAPIUrl)
var (
DiscoveryAPI = newDiscoveryAPI(DiscoveryAPIurl)
PricerAPI = newPricingAPI(PricerAPIUrl)
)

func newDiscoveryAPI(basePath string) *discoveryAPI {
return &discoveryAPI{
@@ -47,7 +49,6 @@ type Query struct {
CompatibilityMin int `url:"compatibility_min"`
CompatibilityMax int `url:"compatibility_max"`
QualityMin float64 `url:"quality_min"`
Tags string `url:"tags"`
IncludeMonitoringFailed bool `url:"include_monitoring_failed"`
NATCompatibility string `url:"nat_compatibility"`
}
2 changes: 0 additions & 2 deletions e2e/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -11,7 +11,6 @@ services:
- QUALITY_ORACLE_URL=http://wiremock:8080
- QUALITY_CACHE_TTL=1s
- PROPOSALS_CACHE_TTL=0s
- BADGER_ADDRESS=http://wiremock:8080
- BROKER_URL=nats://broker
- LOCATION_ADDRESS=http://wiremock:8080
- UNIVERSE_JWT_SECRET=suchsecret
@@ -35,7 +34,6 @@ services:
- PORT=8081
- QUALITY_ORACLE_URL=http://wiremock:8004
- QUALITY_CACHE_TTL=20s
- BADGER_ADDRESS=http://wiremock:8004
- SENTINEL_URL=http://wiremock:8004
- BROKER_URL=nats://broker.mysterium.network
- UNIVERSE_JWT_SECRET=suchsecret
15 changes: 0 additions & 15 deletions e2e/wiremock/mappings/tag.json

This file was deleted.

1 change: 0 additions & 1 deletion magefile.go
Original file line number Diff line number Diff line change
@@ -86,7 +86,6 @@ func Run() error {
"COINRANKING_TOKEN": "",
"UNIVERSE_JWT_SECRET": "",
"REDIS_ADDRESS": "localhost:6379",
"BADGER_ADDRESS": "https://badger.mysterium.network",
"LOCATION_ADDRESS": "https://location.mysterium.network/api/v1/location",
"SENTINEL_URL": "https://sentinel.mysterium.network",
}
1 change: 0 additions & 1 deletion proposal/api.go
Original file line number Diff line number Diff line change
@@ -206,7 +206,6 @@ func (a *API) proposalArgs(c *gin.Context) ListOpts {
accessPolicy: c.Query("access_policy"),
accessPolicySource: c.Query("access_policy_source"),
ipType: c.Query("ip_type"),
tags: c.Query("tags"),
}

pids, _ := c.GetQueryArray("provider_id")
22 changes: 1 addition & 21 deletions proposal/inmemory.go
Original file line number Diff line number Diff line change
@@ -6,7 +6,6 @@ package proposal

import (
"errors"
"strings"
"sync"
"time"

@@ -25,7 +24,6 @@ type Repository struct {
expirationDuration time.Duration
mu sync.RWMutex
proposals map[string]record
enhancers []Enhancer
proposalsHardLimitPerCountry int
proposalsSoftLimitPerCountry int
compatibilityMin int
@@ -40,7 +38,6 @@ type repoListOpts struct {
accessPolicySource string
compatibilityMin int
compatibilityMax int
tags string
}

type repoMetadataOpts struct {
@@ -52,12 +49,11 @@ type record struct {
expiresAt time.Time
}

func NewRepository(enhancers []Enhancer, proposalsHardLimitPerCountry, proposalsSoftLimitPerCountry, compatibilityMin int) *Repository {
func NewRepository(proposalsHardLimitPerCountry, proposalsSoftLimitPerCountry, compatibilityMin int) *Repository {
return &Repository{
expirationDuration: 3*time.Minute + 10*time.Second,
expirationJobDelay: 20 * time.Second,
proposals: make(map[string]record),
enhancers: enhancers,
proposalsHardLimitPerCountry: proposalsHardLimitPerCountry,
proposalsSoftLimitPerCountry: proposalsSoftLimitPerCountry,
compatibilityMin: compatibilityMin,
@@ -271,21 +267,5 @@ func match(p v3.Proposal, opts repoListOpts) bool {
}
}

if opts.tags != "" {
found := false

for _, ot := range strings.Split(opts.tags, ",") {
for _, pt := range p.Tags {
if ot == pt {
found = true
}
}
}

if !found {
return false
}
}

return true
}
4 changes: 0 additions & 4 deletions proposal/service.go
Original file line number Diff line number Diff line change
@@ -39,7 +39,6 @@ type ListOpts struct {
compatibilityMax int
bandwidthMin float64
qualityMin float64
tags string
includeMonitoringFailed bool
natCompatibility string
presetID int
@@ -55,7 +54,6 @@ func (s *Service) List(opts ListOpts, limited bool) []v3.Proposal {
accessPolicySource: opts.accessPolicySource,
compatibilityMin: opts.compatibilityMin,
compatibilityMax: opts.compatibilityMax,
tags: opts.tags,
}, limited)

or := &metrics.OracleResponses{}
@@ -88,7 +86,6 @@ func (s *Service) ListCountriesNumbers(opts ListOpts, limited bool) map[string]i
accessPolicySource: opts.accessPolicySource,
compatibilityMin: opts.compatibilityMin,
compatibilityMax: opts.compatibilityMax,
tags: opts.tags,
})
}

@@ -101,7 +98,6 @@ func (s *Service) ListCountriesNumbers(opts ListOpts, limited bool) map[string]i
accessPolicySource: opts.accessPolicySource,
compatibilityMin: opts.compatibilityMin,
compatibilityMax: opts.compatibilityMax,
tags: opts.tags,
}, limited)

or := &metrics.OracleResponses{}
1 change: 0 additions & 1 deletion proposal/v3/proposal.go
Original file line number Diff line number Diff line change
@@ -42,7 +42,6 @@ type Proposal struct {
Contacts []Contact `json:"contacts"`
AccessPolicies []AccessPolicy `json:"access_policies,omitempty"`
Quality Quality `json:"quality"`
Tags []string `json:"tags,omitempty"`
}

func NewProposal(providerID, serviceType string) *Proposal {
26 changes: 2 additions & 24 deletions proposal/v3/proposal_json.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 0 additions & 43 deletions tags/api.go

This file was deleted.

30 changes: 0 additions & 30 deletions tags/tag_enhancer.go

This file was deleted.