Skip to content

Commit 852088d

Browse files
committed
Support for Load Balancers in host routes
1 parent 56b361f commit 852088d

File tree

3 files changed

+36
-21
lines changed

3 files changed

+36
-21
lines changed

api/host/converter.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func toRouteSettingsDto(settings *host.RouteSettings) *routeSettingsDto {
153153
}
154154
}
155155

156-
func toStaticResponseDto(response *host.RouteStaticResponse) *staticResponseDto {
156+
func toStaticResponseDto(response *host.StaticResponse) *staticResponseDto {
157157
if response == nil {
158158
return nil
159159
}
@@ -165,7 +165,7 @@ func toStaticResponseDto(response *host.RouteStaticResponse) *staticResponseDto
165165
}
166166
}
167167

168-
func toIntegrationConfigDto(config *host.RouteIntegrationConfig) *integrationConfigDto {
168+
func toIntegrationConfigDto(config *host.Integration) *integrationConfigDto {
169169
if config == nil {
170170
return nil
171171
}
@@ -176,7 +176,7 @@ func toIntegrationConfigDto(config *host.RouteIntegrationConfig) *integrationCon
176176
}
177177
}
178178

179-
func toRouteSourceCodeDto(sourceCode *host.RouteSourceCode) *routeSourceCodeDto {
179+
func toRouteSourceCodeDto(sourceCode *host.SourceCode) *routeSourceCodeDto {
180180
if sourceCode == nil {
181181
return nil
182182
}
@@ -268,35 +268,35 @@ func toRouteSettings(input *routeSettingsDto) *host.RouteSettings {
268268
}
269269
}
270270

271-
func toRouteStaticResponse(input *staticResponseDto) *host.RouteStaticResponse {
271+
func toRouteStaticResponse(input *staticResponseDto) *host.StaticResponse {
272272
if input == nil {
273273
return nil
274274
}
275275

276-
return &host.RouteStaticResponse{
276+
return &host.StaticResponse{
277277
StatusCode: getIntValue(input.StatusCode),
278278
Payload: input.Payload,
279279
Headers: getMapValue(input.Headers),
280280
}
281281
}
282282

283-
func toRouteIntegrationConfig(input *integrationConfigDto) *host.RouteIntegrationConfig {
283+
func toRouteIntegrationConfig(input *integrationConfigDto) *host.Integration {
284284
if input == nil {
285285
return nil
286286
}
287287

288-
return &host.RouteIntegrationConfig{
288+
return &host.Integration{
289289
IntegrationID: getUuidValue(input.IntegrationId),
290290
OptionID: getStringValue(input.OptionId),
291291
}
292292
}
293293

294-
func toRouteSourceCode(input *routeSourceCodeDto) *host.RouteSourceCode {
294+
func toRouteSourceCode(input *routeSourceCodeDto) *host.SourceCode {
295295
if input == nil {
296296
return nil
297297
}
298298

299-
return &host.RouteSourceCode{
299+
return &host.SourceCode{
300300
Language: *input.Language,
301301
Contents: getStringValue(input.Code),
302302
MainFunction: input.MainFunction,

core/host/model.go

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ type Route struct {
5959
RedirectCode *int
6060
AccessListID *uuid.UUID
6161
Settings RouteSettings
62-
Response *RouteStaticResponse
63-
Integration *RouteIntegrationConfig
64-
SourceCode *RouteSourceCode
62+
Response *StaticResponse
63+
Integration *Integration
64+
SourceCode *SourceCode
6565
}
6666

67-
type RouteSourceCode struct {
67+
type SourceCode struct {
6868
Language CodeLanguage
6969
Contents string
7070
MainFunction *string
@@ -78,13 +78,13 @@ type RouteSettings struct {
7878
Custom *string
7979
}
8080

81-
type RouteStaticResponse struct {
81+
type StaticResponse struct {
8282
StatusCode int
8383
Headers map[string]string
8484
Payload *string
8585
}
8686

87-
type RouteIntegrationConfig struct {
87+
type Integration struct {
8888
IntegrationID uuid.UUID
8989
OptionID string
9090
}
@@ -102,3 +102,18 @@ type VPN struct {
102102
Name string
103103
Host *string
104104
}
105+
106+
type LoadBalancer struct {
107+
Backends []LoadBalancerBackend
108+
}
109+
110+
type LoadBalancerBackend struct {
111+
Weight *int
112+
Address string
113+
CircuitBreaker *CircuitBreaker
114+
}
115+
116+
type CircuitBreaker struct {
117+
MaxFailures int
118+
OpenSeconds int
119+
}

database/host/converter.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,26 +37,26 @@ func toDomain(model *hostModel) (*host.Host, error) {
3737
return nil, err
3838
}
3939

40-
var response *host.RouteStaticResponse
40+
var response *host.StaticResponse
4141
if route.StaticResponseCode != nil {
42-
response = &host.RouteStaticResponse{
42+
response = &host.StaticResponse{
4343
StatusCode: *route.StaticResponseCode,
4444
Headers: headers,
4545
Payload: route.StaticResponsePayload,
4646
}
4747
}
4848

49-
var integration *host.RouteIntegrationConfig
49+
var integration *host.Integration
5050
if route.IntegrationOptionID != nil {
51-
integration = &host.RouteIntegrationConfig{
51+
integration = &host.Integration{
5252
IntegrationID: *route.IntegrationID,
5353
OptionID: *route.IntegrationOptionID,
5454
}
5555
}
5656

57-
var sourceCode *host.RouteSourceCode
57+
var sourceCode *host.SourceCode
5858
if route.CodeLanguage != nil {
59-
sourceCode = &host.RouteSourceCode{
59+
sourceCode = &host.SourceCode{
6060
Language: host.CodeLanguage(*route.CodeLanguage),
6161
Contents: *route.CodeContents,
6262
MainFunction: route.CodeMainFunction,

0 commit comments

Comments
 (0)