Skip to content

Commit 17b0555

Browse files
committed
tests passing
1 parent 3255162 commit 17b0555

File tree

4 files changed

+368
-367
lines changed

4 files changed

+368
-367
lines changed
Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
namespace Ocelot.Provider.Eureka
2-
{
3-
using Microsoft.Extensions.DependencyInjection;
4-
using Ocelot.ServiceDiscovery;
1+
namespace Ocelot.Provider.Eureka
2+
{
3+
using Microsoft.Extensions.DependencyInjection;
4+
using Ocelot.ServiceDiscovery;
55
using Steeltoe.Discovery;
66

7-
public static class EurekaProviderFactory
8-
{
9-
public static ServiceDiscoveryFinderDelegate Get = (provider, config, route) =>
10-
{
11-
var client = provider.GetService<IDiscoveryClient>();
12-
13-
if (config.Type?.ToLower() == "eureka" && client != null)
14-
{
15-
return new Eureka(route.ServiceName, client);
16-
}
17-
18-
return null;
19-
};
20-
}
21-
}
7+
public static class EurekaProviderFactory
8+
{
9+
public static ServiceDiscoveryFinderDelegate Get = (provider, config, route) =>
10+
{
11+
var client = provider.GetService<IDiscoveryClient>();
12+
13+
if (config.Type?.ToLower() == "eureka" && client != null)
14+
{
15+
return new Eureka(route.ServiceName, client);
16+
}
17+
18+
return null;
19+
};
20+
}
21+
}

src/Ocelot.Provider.Eureka/Ocelot.Provider.Eureka.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
</ItemGroup>
2929
<ItemGroup>
3030
<PackageReference Include="Steeltoe.Discovery.ClientCore" Version="3.0.1" />
31+
<PackageReference Include="Steeltoe.Discovery.Eureka" Version="3.0.1" />
3132
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.164">
3233
<PrivateAssets>all</PrivateAssets>
3334
</PackageReference>

test/Ocelot.AcceptanceTests/EurekaServiceDiscoveryTests.cs

Lines changed: 50 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
namespace Ocelot.AcceptanceTests
22
{
3-
using Configuration.File;
3+
using Ocelot.Configuration.File;
44
using Microsoft.AspNetCore.Http;
55
using Newtonsoft.Json;
66
using Steeltoe.Common.Discovery;
@@ -38,24 +38,24 @@ public void should_use_eureka_service_discovery_and_make_request()
3838
var configuration = new FileConfiguration
3939
{
4040
Routes = new List<FileRoute>
41+
{
42+
new FileRoute
4143
{
42-
new FileRoute
43-
{
44-
DownstreamPathTemplate = "/",
45-
DownstreamScheme = "http",
46-
UpstreamPathTemplate = "/",
47-
UpstreamHttpMethod = new List<string> { "Get" },
48-
ServiceName = serviceName,
49-
LoadBalancerOptions = new FileLoadBalancerOptions { Type = "LeastConnection" },
50-
}
44+
DownstreamPathTemplate = "/",
45+
DownstreamScheme = "http",
46+
UpstreamPathTemplate = "/",
47+
UpstreamHttpMethod = new List<string> { "Get" },
48+
ServiceName = serviceName,
49+
LoadBalancerOptions = new FileLoadBalancerOptions { Type = "LeastConnection" },
5150
},
51+
},
5252
GlobalConfiguration = new FileGlobalConfiguration()
5353
{
5454
ServiceDiscoveryProvider = new FileServiceDiscoveryProvider()
5555
{
56-
Type = "Eureka"
57-
}
58-
}
56+
Type = "Eureka",
57+
},
58+
},
5959
};
6060

6161
this.Given(x => x.GivenEurekaProductServiceOneIsRunning(downstreamServiceOneUrl))
@@ -91,42 +91,42 @@ private void GivenThereIsAFakeEurekaServiceDiscoveryProvider(string url, string
9191
{
9292
name = serviceName,
9393
instance = new List<Instance>
94+
{
95+
new Instance
96+
{
97+
instanceId = $"{serviceInstance.Host}:{serviceInstance}",
98+
hostName = serviceInstance.Host,
99+
app = serviceName,
100+
ipAddr = "127.0.0.1",
101+
status = "UP",
102+
overriddenstatus = "UNKNOWN",
103+
port = new Port {value = serviceInstance.Port, enabled = "true"},
104+
securePort = new SecurePort {value = serviceInstance.Port, enabled = "true"},
105+
countryId = 1,
106+
dataCenterInfo = new DataCenterInfo {value = "com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo", name = "MyOwn"},
107+
leaseInfo = new LeaseInfo
108+
{
109+
renewalIntervalInSecs = 30,
110+
durationInSecs = 90,
111+
registrationTimestamp = 1457714988223,
112+
lastRenewalTimestamp= 1457716158319,
113+
evictionTimestamp = 0,
114+
serviceUpTimestamp = 1457714988223,
115+
},
116+
metadata = new Metadata
94117
{
95-
new Instance
96-
{
97-
instanceId = $"{serviceInstance.Host}:{serviceInstance}",
98-
hostName = serviceInstance.Host,
99-
app = serviceName,
100-
ipAddr = "127.0.0.1",
101-
status = "UP",
102-
overriddenstatus = "UNKNOWN",
103-
port = new Port {value = serviceInstance.Port, enabled = "true"},
104-
securePort = new SecurePort {value = serviceInstance.Port, enabled = "true"},
105-
countryId = 1,
106-
dataCenterInfo = new DataCenterInfo {value = "com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo", name = "MyOwn"},
107-
leaseInfo = new LeaseInfo
108-
{
109-
renewalIntervalInSecs = 30,
110-
durationInSecs = 90,
111-
registrationTimestamp = 1457714988223,
112-
lastRenewalTimestamp= 1457716158319,
113-
evictionTimestamp = 0,
114-
serviceUpTimestamp = 1457714988223
115-
},
116-
metadata = new Metadata
117-
{
118-
value = "java.util.Collections$EmptyMap"
119-
},
120-
homePageUrl = $"{serviceInstance.Host}:{serviceInstance.Port}",
121-
statusPageUrl = $"{serviceInstance.Host}:{serviceInstance.Port}",
122-
healthCheckUrl = $"{serviceInstance.Host}:{serviceInstance.Port}",
123-
vipAddress = serviceName,
124-
isCoordinatingDiscoveryServer = "false",
125-
lastUpdatedTimestamp = "1457714988223",
126-
lastDirtyTimestamp = "1457714988172",
127-
actionType = "ADDED"
128-
}
129-
}
118+
value = "java.util.Collections$EmptyMap",
119+
},
120+
homePageUrl = $"{serviceInstance.Host}:{serviceInstance.Port}",
121+
statusPageUrl = $"{serviceInstance.Host}:{serviceInstance.Port}",
122+
healthCheckUrl = $"{serviceInstance.Host}:{serviceInstance.Port}",
123+
vipAddress = serviceName,
124+
isCoordinatingDiscoveryServer = "false",
125+
lastUpdatedTimestamp = "1457714988223",
126+
lastDirtyTimestamp = "1457714988172",
127+
actionType = "ADDED",
128+
},
129+
},
130130
};
131131

132132
apps.Add(a);
@@ -138,8 +138,8 @@ private void GivenThereIsAFakeEurekaServiceDiscoveryProvider(string url, string
138138
{
139139
application = apps,
140140
apps__hashcode = "UP_1_",
141-
versions__delta = "1"
142-
}
141+
versions__delta = "1",
142+
},
143143
};
144144

145145
var json = JsonConvert.SerializeObject(applications);

0 commit comments

Comments
 (0)