Add a possibility to change service name dynamically because of Consul tags
See original GitHub issueHello,
At the moment service name is chosen based on first segment in the path. I would like to be able to map one (or multiple) path segments to service name in Consul.
Few examples:
authorization
=> would mapped to authorization.service.web
authorization/api
=> would be mapped to authorization.service.api
Reason for this, that my routes are defined in Consul tags and I would like to use them as a key when selecting service name in Consul.
At the moment to achieve this I have to replace whole DownstreamRouteCreator
class, while I would be keen to keep custom part as small as possible.
Would you mind if I make a PR for this?
So something like:
public interface IServiceNameProvider
{
string GetServiceName(string upstreamUrlPath);
}
public class ServiceNameProvider: IServiceNameProvider
{
public string GetServiceName(string upstreamUrlPath)
{
if (upstreamUrlPath.IndexOf('/', 1) == -1)
{
return upstreamUrlPath
.Substring(1);
}
return upstreamUrlPath
.Substring(1, upstreamUrlPath.IndexOf('/', 1))
.TrimEnd('/');
}
}
and use this such provider in CustomDownstreamRouteCreator
class.
with best regards
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Dynamically set service tags tags
I have a scenario where I've got a database cluster running, and would like the clients to use a Consul DNS address (e.g. ......
Read more >Dynamic tags applied like health checks. #1048
I would like to have master.mongodb.service.consul resolve to the one IP of the master ... Set up my service definition with dynamic tags....
Read more >Remotely update service tags on client node - Consul
I want to update tag value in client node config files. I do it manually by SSHing the node and updating the tag...
Read more >Dynamic traffic tagging with Consul - luisico
This exercise is a way to show built-in service discovery, tagging and k/v capabilities in Consul. It's not production ready configuration, so ...
Read more >Consul nodes and service are not getting created/updated ...
Because the service objects are connected to the node objects by name, the Consul provider can't tell that nodes are being replaced when ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Sorry, no chance…
But you can do it on your own… just IDownstreamServiceFinder should have this signature:
Not really. Path is just a key to configuration item. That item has all necessary information about downstream service.
To be honest - now I would do this PR a bit differently. Finder should take HttpRequest as parameter and then you can have various logics in routing where service instance can be identified by:
In microservices world where services are created and registered kind of dynamically such kind of flexibility is necessary. In our infrastructure there are hundreds of microservices running and routing rules might vary quite a lot thus in application gateway a lot of flexibility is required 😃