Skip to content

provide new endpoints regarding new service types - #5367

Merged
yeszhanov95 merged 5 commits into
masterfrom
feature/5262-provide-new-endpoints
Aug 11, 2022
Merged

provide new endpoints regarding new service types#5367
yeszhanov95 merged 5 commits into
masterfrom
feature/5262-provide-new-endpoints

Conversation

@yeszhanov95

@yeszhanov95 yeszhanov95 commented Aug 10, 2022

Copy link
Copy Markdown
Contributor

Update endpoint /services: add optional query param "include_all" (boolean). when include_all=true return all services, otherwise only running.
Add endpoint /v2/prices/current, which will return current prices for all service types.

According to #5262

@yeszhanov95
yeszhanov95 marked this pull request as ready for review August 11, 2022 10:36
Comment thread core/service/manager.go Outdated
}

// ListAll returns array of all services
func (manager *Manager) ListAll() []*Instance {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are many reasons to use non pointer slices. Less memory, fewer allocations needed and it's also faster. Pointer slices also serve little practical use, especially in this case here. It's almost always more trouble than its worth.

I see it's been done here like that before, am I just missing something?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually yes, there's similar method called List, which also uses pointer instead of struct. So, I decided to go this way

func (se *ServiceEndpoint) ServiceList(c *gin.Context) {
instances := se.serviceManager.List()
includeAll := false
includeAllStr := c.Request.URL.Query().Get("include_all")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is c.Get or c.GetBool wouldn't those do the same but better?

@yeszhanov95 yeszhanov95 Aug 11, 2022

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as I understand those methods doesn't fetch data from query params. it only looks inside c.Keys map[string]interface{}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

c.Query("include_all") ?

Comment thread tequilapi/endpoints/service.go Outdated
}

instances := make([]*service.Instance, 0)
if includeAll {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could these be a method on the serviceManager itself? Would be nice to not have this if / else logic in the handler and the manager itself could decide if it should return all or some portion based on given params.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good point, I thought about it too

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

Merging #5367 (448135f) into master (8a1fd42) will decrease coverage by 0.13%.
The diff coverage is 36.11%.

@@            Coverage Diff             @@
##           master    #5367      +/-   ##
==========================================
- Coverage   38.66%   38.53%   -0.14%     
==========================================
  Files         357      357              
  Lines       19476    19533      +57     
==========================================
- Hits         7531     7527       -4     
- Misses      11211    11267      +56     
- Partials      734      739       +5     
Impacted Files Coverage Δ
core/service/manager.go 52.99% <0.00%> (-9.64%) ⬇️
tequilapi/endpoints/proposals.go 34.00% <4.76%> (-4.76%) ⬇️
tequilapi/endpoints/service.go 82.16% <66.66%> (-2.67%) ⬇️
core/service/pool.go 73.40% <100.00%> (+0.87%) ⬆️
core/state/state.go 69.90% <100.00%> (+0.29%) ⬆️
core/policy/oracle.go 86.48% <0.00%> (-5.41%) ⬇️
nat/traversal/pinger.go 77.51% <0.00%> (-4.27%) ⬇️
session/pingpong/invoice_tracker.go 63.38% <0.00%> (-2.26%) ⬇️
p2p/channel.go 68.23% <0.00%> (+2.16%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@yeszhanov95
yeszhanov95 requested a review from tomasmik August 11, 2022 13:10
@yeszhanov95
yeszhanov95 merged commit 7e4079c into master Aug 11, 2022
@yeszhanov95
yeszhanov95 deleted the feature/5262-provide-new-endpoints branch August 11, 2022 20:16
Snawoot added a commit that referenced this pull request Aug 19, 2022
…rovide-new-endpoints"

This reverts commit 7e4079c, reversing
changes made to 8a1fd42.
Snawoot added a commit that referenced this pull request Aug 19, 2022
…rovide-new-endpoints"

This reverts commit 7e4079c, reversing
changes made to 8a1fd42.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants