Skip to content

Commit

Permalink
v8(services): get large pages for services and marketplace (#2111)
Browse files Browse the repository at this point in the history
These commands can potentially get a lot of data, and they are much
faster if they get 5000 results per page, instead of the default of 50
per page.

[#175715881](https://www.pivotaltracker.com/story/show/175715881)
  • Loading branch information
blgm authored Nov 19, 2020
1 parent f4eef72 commit b823ae5
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion actor/v7action/marketplace.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ type MarketplaceFilter struct {
}

func (actor Actor) Marketplace(filter MarketplaceFilter) ([]ServiceOfferingWithPlans, Warnings, error) {
var query []ccv3.Query
query := []ccv3.Query{{Key: ccv3.PerPage, Values: []string{ccv3.MaxPerPage}}}

if filter.SpaceGUID != "" {
query = append(query, ccv3.Query{
Expand Down
9 changes: 5 additions & 4 deletions actor/v7action/marketplace_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,10 @@ var _ = Describe("marketplace", func() {

Expect(fakeCloudControllerClient.GetServicePlansWithOfferingsCallCount()).To(Equal(1))
queries := fakeCloudControllerClient.GetServicePlansWithOfferingsArgsForCall(0)
Expect(queries).To(ConsistOf(ccv3.Query{
Key: ccv3.AvailableFilter,
Values: []string{"true"},
}))
Expect(queries).To(ConsistOf(
ccv3.Query{Key: ccv3.AvailableFilter, Values: []string{"true"}},
ccv3.Query{Key: ccv3.PerPage, Values: []string{ccv3.MaxPerPage}},
))
})

It("returns a list of service offerings and plans", func() {
Expand Down Expand Up @@ -162,6 +162,7 @@ var _ = Describe("marketplace", func() {
ccv3.Query{Key: ccv3.SpaceGUIDFilter, Values: []string{"space-guid"}},
ccv3.Query{Key: ccv3.ServiceOfferingNamesFilter, Values: []string{"my-service-offering"}},
ccv3.Query{Key: ccv3.AvailableFilter, Values: []string{"true"}},
ccv3.Query{Key: ccv3.PerPage, Values: []string{ccv3.MaxPerPage}},
))
})
})
Expand Down
3 changes: 2 additions & 1 deletion actor/v7action/service_instance_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ func (actor Actor) GetServiceInstancesForSpace(spaceGUID string, omitApps bool)
ccv3.Query{Key: ccv3.FieldsServicePlan, Values: []string{"guid", "name", "relationships.service_offering"}},
ccv3.Query{Key: ccv3.FieldsServicePlanServiceOffering, Values: []string{"guid", "name", "relationships.service_broker"}},
ccv3.Query{Key: ccv3.FieldsServicePlanServiceOfferingServiceBroker, Values: []string{"guid", "name"}},
ccv3.Query{Key: ccv3.OrderBy, Values: []string{"name"}},
ccv3.Query{Key: ccv3.OrderBy, Values: []string{ccv3.NameOrder}},
ccv3.Query{Key: ccv3.PerPage, Values: []string{ccv3.MaxPerPage}},
)
return
},
Expand Down
3 changes: 2 additions & 1 deletion actor/v7action/service_instance_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,8 @@ var _ = Describe("Service Instance List Action", func() {
ccv3.Query{Key: ccv3.FieldsServicePlan, Values: []string{"guid", "name", "relationships.service_offering"}},
ccv3.Query{Key: ccv3.FieldsServicePlanServiceOffering, Values: []string{"guid", "name", "relationships.service_broker"}},
ccv3.Query{Key: ccv3.FieldsServicePlanServiceOfferingServiceBroker, Values: []string{"guid", "name"}},
ccv3.Query{Key: ccv3.OrderBy, Values: []string{"name"}},
ccv3.Query{Key: ccv3.OrderBy, Values: []string{ccv3.NameOrder}},
ccv3.Query{Key: ccv3.PerPage, Values: []string{ccv3.MaxPerPage}},
))
})

Expand Down
3 changes: 3 additions & 0 deletions api/cloudcontroller/ccv3/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ const (

// Purge is a query parameter used on a Delete request to indicate that dependent resources should also be deleted
Purge = "purge"

// MaxPerPage is the largest value of "per_page" that should be used
MaxPerPage = "5000"
)

// Query is additional settings that can be passed to some requests that can
Expand Down

0 comments on commit b823ae5

Please sign in to comment.