Skip to content

Commit

Permalink
feat: implement support for per-route options
Browse files Browse the repository at this point in the history
This commit adds support for per-route options to the CFRoute struct.
Required for route-emitter to forward the route-specific Options field.

Co-authored-by: Tamara Boehm <[email protected]>
See: cloudfoundry/community#909
  • Loading branch information
a18e and b1tamara committed Oct 22, 2024
1 parent dd78756 commit e3b43b6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
11 changes: 6 additions & 5 deletions cfroutes/routing_info_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@ const CF_ROUTER = "cf-router"
type CFRoutes []CFRoute

type CFRoute struct {
Hostnames []string `json:"hostnames"`
Port uint32 `json:"port"`
RouteServiceUrl string `json:"route_service_url,omitempty"`
IsolationSegment string `json:"isolation_segment,omitempty"`
Protocol string `json:"protocol,omitempty"`
Hostnames []string `json:"hostnames"`
Port uint32 `json:"port"`
RouteServiceUrl string `json:"route_service_url,omitempty"`
IsolationSegment string `json:"isolation_segment,omitempty"`
Protocol string `json:"protocol,omitempty"`
Options json.RawMessage `json:"options,omitempty"`
}

func (c CFRoutes) RoutingInfo() models.Routes {
Expand Down
8 changes: 7 additions & 1 deletion cfroutes/routing_info_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var _ = Describe("RoutingInfoHelpers", func() {
route1 cfroutes.CFRoute
route2 cfroutes.CFRoute
route3 cfroutes.CFRoute
route4 cfroutes.CFRoute

routes cfroutes.CFRoutes
)
Expand All @@ -34,8 +35,13 @@ var _ = Describe("RoutingInfoHelpers", func() {
RouteServiceUrl: "rs.example.com",
Protocol: "http2",
}
route4 = cfroutes.CFRoute{
Hostnames: []string{"foo4.example.com", "bar4.examaple.com"},
Port: 44444,
Options: json.RawMessage(`{"lb_algo":"least-connection"}`),
}

routes = cfroutes.CFRoutes{route1, route2, route3}
routes = cfroutes.CFRoutes{route1, route2, route3, route4}
})

Describe("RoutingInfo", func() {
Expand Down

0 comments on commit e3b43b6

Please sign in to comment.