From 8d8cd358e22c025fc587b5689a3587cfdc44245c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Th=C3=B6mmes?= Date: Mon, 14 Oct 2024 12:22:34 +0200 Subject: [PATCH] Add protocol to AppSpec and pending to detect responses This adds the new protocol field to AppSpecs to be able to specify either HTTP or HTTP2 traffic. It also adds the pending field to detect responses which reflects whether a request is still in-flight in the background. --- apps.gen.go | 14 +++++++++++++- apps_accessors.go | 16 ++++++++++++++++ apps_accessors_test.go | 14 ++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/apps.gen.go b/apps.gen.go index 22970540..5bef89aa 100644 --- a/apps.gen.go +++ b/apps.gen.go @@ -495,7 +495,8 @@ type AppServiceSpec struct { InstanceCount int64 `json:"instance_count,omitempty"` Autoscaling *AppAutoscalingSpec `json:"autoscaling,omitempty"` // The internal port on which this service's run command will listen. Default: 8080 If there is not an environment variable with the name `PORT`, one will be automatically added with its value set to the value of this field. - HTTPPort int64 `json:"http_port,omitempty"` + HTTPPort int64 `json:"http_port,omitempty"` + Protocol ServingProtocol `json:"protocol,omitempty"` // (Deprecated) A list of HTTP routes that should be routed to this component. Routes []*AppRouteSpec `json:"routes,omitempty"` HealthCheck *AppServiceSpecHealthCheck `json:"health_check,omitempty"` @@ -917,6 +918,8 @@ type DetectResponse struct { TemplateFound bool `json:"template_found,omitempty"` TemplateValid bool `json:"template_valid,omitempty"` TemplateError string `json:"template_error,omitempty"` + // Whether or not the underlying detection is still pending. If true, the request can be retried as-is until this field is false and the response contains the detection result. + Pending bool `json:"pending,omitempty"` } // DetectResponseComponent struct for DetectResponseComponent @@ -1252,6 +1255,15 @@ type ResetDatabasePasswordResponse struct { Deployment *Deployment `json:"deployment,omitempty"` } +// ServingProtocol - HTTP: The app is serving the HTTP protocol. Default. - HTTP2: The app is serving the HTTP/2 protocol. Currently, this needs to be implemented in the service by serving HTTP/2 with prior knowledge. +type ServingProtocol string + +// List of ServingProtocol +const ( + SERVINGPROTOCOL_HTTP ServingProtocol = "HTTP" + SERVINGPROTOCOL_HTTP2 ServingProtocol = "HTTP2" +) + // AppStringMatch struct for AppStringMatch type AppStringMatch struct { // Exact string match. Only 1 of `exact`, `prefix`, or `regex` must be set. diff --git a/apps_accessors.go b/apps_accessors.go index 05c5ac4b..244a7f90 100644 --- a/apps_accessors.go +++ b/apps_accessors.go @@ -1757,6 +1757,14 @@ func (a *AppServiceSpec) GetName() string { return a.Name } +// GetProtocol returns the Protocol field. +func (a *AppServiceSpec) GetProtocol() ServingProtocol { + if a == nil { + return "" + } + return a.Protocol +} + // GetRoutes returns the Routes field. func (a *AppServiceSpec) GetRoutes() []*AppRouteSpec { if a == nil { @@ -3093,6 +3101,14 @@ func (d *DetectResponse) GetComponents() []*DetectResponseComponent { return d.Components } +// GetPending returns the Pending field. +func (d *DetectResponse) GetPending() bool { + if d == nil { + return false + } + return d.Pending +} + // GetTemplate returns the Template field. func (d *DetectResponse) GetTemplate() *DeployTemplate { if d == nil { diff --git a/apps_accessors_test.go b/apps_accessors_test.go index fc8a7705..ad780853 100644 --- a/apps_accessors_test.go +++ b/apps_accessors_test.go @@ -1539,6 +1539,13 @@ func TestAppServiceSpec_GetName(tt *testing.T) { a.GetName() } +func TestAppServiceSpec_GetProtocol(tt *testing.T) { + a := &AppServiceSpec{} + a.GetProtocol() + a = nil + a.GetProtocol() +} + func TestAppServiceSpec_GetRoutes(tt *testing.T) { a := &AppServiceSpec{} a.GetRoutes() @@ -2708,6 +2715,13 @@ func TestDetectResponse_GetComponents(tt *testing.T) { d.GetComponents() } +func TestDetectResponse_GetPending(tt *testing.T) { + d := &DetectResponse{} + d.GetPending() + d = nil + d.GetPending() +} + func TestDetectResponse_GetTemplate(tt *testing.T) { d := &DetectResponse{} d.GetTemplate()