MEDIUM: Add support for "mode tcp"#16
Conversation
pierresouchay
left a comment
There was a problem hiding this comment.
Sounds Ok to me, we have to add to CHANGELOG.md (see #23) that this is a breaking change (since using TCP instead of HTTP by default now).
Since it is intended to mimic Envoy's Consul Connect, it seems legit to me.
@ShimmerGlass Any comment
Just to be clear this won't change the default to TCP yet. I was recommending that we make that change in the future after accepting this PR. For now, this just adds TCP but keeps default to HTTP |
|
@dcorbett-haproxy yes, you are right, that's only when you'll default it to TCP in a similar way as Envoy's. Let's wait for @ShimmerGlass to review it, but I think we are good. |
|
Hello @dcorbett-haproxy , Since we now run the unit tests on Travis (with end-to-end tests), can you please rebase with origin ? Thank you |
consul/watcher.go
Outdated
| } | ||
|
|
||
| if up.Config["protocol"] != nil { | ||
| u.Protocol = up.Config["protocol"].(string) |
There was a problem hiding this comment.
There should be a type assertion here. If "protocol" is not a string it will crash.
There was a problem hiding this comment.
Thanks for catching this. I added a type assertion
New frontends and backends only had support for using models.FrontendModeHTTP
and models.BackendModeHTTP which limited them to "mode http" only. This commit
adds support for "mode tcp" using both upstream and downstream specific
configuration options. It defaults to http.
To use add a "config" option within an upstream similar to the below example:
Sample downstream service file for Redis
{
"service": {
"name": "redis",
"port": 6379,
"connect": {
"sidecar_service": {
"proxy" : {
"config": { "protocol" : "tcp" }
}
}
}
}
}
Sample upstream configuration:
"upstreams": [{
"destination_name": "redis",
"local_bind_port": 6379,
"config": { "protocol" : "tcp" }
}
ec5a1c5 to
9420fa5
Compare
|
Thanks for the review. I have rebased and made the type assertion checks suggested by @ShimmerGlass |
New frontends and backends only had support for using models.FrontendModeHTTP
and models.BackendModeHTTP which limited them to "mode http" only. This commit
adds support for "mode tcp" using both upstream and downstream specific
configuration options. It defaults to http.
To use add a "config" option within an upstream similar to the below example:
Sample downstream service file for Redis
Sample upstream configuration: