You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on May 17, 2019. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,8 @@ While the primary usage of the providers is intended to be with ASP.NET Core app
20
20
21
21
Currently all of the code and samples have been tested on .NET Core 1.1, .NET 4.5.1/4.6.x, and on ASP.NET Core 1.1.0.
22
22
# Usage
23
-
See the Readme for each enclosed project for more details on how to make use of it in an application.
23
+
24
+
For more information on how to use these components see the online [Steeltoe documentation](http://steeltoe.io/).
24
25
25
26
# Nuget Feeds
26
27
All new development is done on the dev branch. More stable versions of the packages can be found on the master branch. The latest prebuilt packages from each branch can be found on one of two MyGet feeds. Released version can be found on nuget.org.
Copy file name to clipboardExpand all lines: src/Steeltoe.Discovery.Client/README.md
+1-165Lines changed: 1 addition & 165 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,168 +4,4 @@ This project contains the Steeltoe Discovery Client. This client provides a gen
4
4
5
5
Currently the client only supports [Spring Cloud Eureka Server](http://projects.spring.io/spring-cloud/docs/1.0.3/spring-cloud.html#spring-cloud-eureka-server), but in the future we will support additional service registries.
[Release or Release Candidate feed](https://www.nuget.org/) - https://www.nuget.org/
16
-
17
-
## Basic ASP.NET Core Usage
18
-
You should have a good understanding of how the new .NET [Configuration model](http://docs.asp.net/en/latest/fundamentals/configuration.html) works before starting to use the client. A basic understanding of the `ConfigurationBuilder` and how to add providers to the builder is necessary in order to configure the client. You should also have a good understanding of how the ASP.NET Core [Startup](https://docs.asp.net/en/latest/fundamentals/startup.html) class is used in configuring the application services and the middleware used in the app. Specfically pay particular attention to the usage of the `Configure` and `ConfigureServices` methods. Its also important you have a good understanding of how to setup and use a Spring Cloud Eureka Server. Detailed information on its usage can be found [here](http://projects.spring.io/spring-cloud/docs/1.0.3/spring-cloud.html#spring-cloud-eureka-server).
19
-
20
-
In order to use the Discovery client you need to do the following:
21
-
```
22
-
1. Confiure the settings the Discovery client will use to register servives in the service registry.
23
-
2. Configure the settings the Discovery client will use to discover services in the service registry.
24
-
3. Add and Use the Discovery client as a service in the application.
25
-
```
26
-
## Eureka Settings needed to Register
27
-
Below is an example of the clients settings in JSON that are necessary to get the application to register a service named `fortuneService` with a Eureka Server at address `http://localhost:8761/eureka/`. The `eureka:instance:port` setting is the port upon which the service can be found. The `eureka:client:shouldFetchRegistry` setting instructs the client not to fetch the registry as the app will not be needing to discover services; it only wants to register a service. The default for this property is true.
28
-
29
-
```
30
-
{
31
-
"spring": {
32
-
"application": {
33
-
"name": "fortuneService"
34
-
}
35
-
},
36
-
"eureka": {
37
-
"client": {
38
-
"serviceUrl": "http://localhost:8761/eureka/",
39
-
"shouldFetchRegistry": false
40
-
},
41
-
"instance": {
42
-
"port": 5000
43
-
}
44
-
}
45
-
.....
46
-
}
47
-
```
48
-
## Eureka Settings needed to Discover
49
-
Below is an example of the clients settings in JSON that are necessary to get the application to fetch the service registry from the Eureka Server at address `http://localhost:8761/eureka/` at startup. The `eureka:client:shouldRegisterWithEureka` instructs the client to not register any services in the registry, as the app will not be offering up any services; it only wants to discover.
50
-
51
-
```
52
-
{
53
-
"spring": {
54
-
"application": {
55
-
"name": "fortuneUI"
56
-
}
57
-
},
58
-
"eureka": {
59
-
"client": {
60
-
"serviceUrl": "http://localhost:8761/eureka/",
61
-
"shouldRegisterWithEureka": false
62
-
}
63
-
}
64
-
.....
65
-
}
66
-
```
67
-
68
-
For a complete list of client settings see the documentation in the [IEurekaClientConfig](https://github.com/SteeltoeOSS/Discovery/blob/master/src/Steeltoe.Discovery.Eureka.Client/IEurekaClientConfig.cs) and [IEurekaInstanceConfig](https://github.com/SteeltoeOSS/Discovery/blob/master/src/Steeltoe.Discovery.Eureka.Client/IEurekaInstanceConfig.cs) files.
69
-
70
-
## Add and Use the Discovery Client
71
-
Once the providers settings have been defined and put in a file, the next step is to get them read in and make them available to the client. Using the C# example below, you can see that the clients configuration settings from above would be put in `appsettings.json` and the using the off-the-shelf JSON configuration provider we are able to read in the settings from the file using the provider (e.g. `AddJsonFile("appsettings.json")`.
72
-
73
-
```
74
-
#using Steeltoe.Discovery.Client;
75
-
76
-
public class Startup {
77
-
.....
78
-
public IConfigurationRoot Configuration { get; private set; }
79
-
public Startup(IHostingEnvironment env)
80
-
{
81
-
// Set up configuration sources.
82
-
var builder = new ConfigurationBuilder()
83
-
.SetBasePath(env.ContentRootPath)
84
-
85
-
// Read in Discovery clients configuration
86
-
.AddJsonFile("appsettings.json")
87
-
.AddEnvironmentVariables();
88
-
89
-
Configuration = builder.Build();
90
-
}
91
-
....
92
-
```
93
-
The next step is to Add and Use the Discovery Client. You do these two things in `ConfigureServices(..)` and the `Configure(..)` methods of the startup class:
94
-
```
95
-
#using Steeltoe.Discovery.Client;
96
-
97
-
public class Startup {
98
-
.....
99
-
public IConfigurationRoot Configuration { get; private set; }
100
-
public Startup(...)
101
-
{
102
-
.....
103
-
}
104
-
public void ConfigureServices(IServiceCollection services)
105
-
{
106
-
// Add Steeltoe Discovery Client service
107
-
services.AddDiscoveryClient(Configuration);
108
-
109
-
// Add framework services.
110
-
services.AddMvc();
111
-
...
112
-
}
113
-
public void Configure(IApplicationBuilder app, ....)
114
-
{
115
-
....
116
-
app.UseStaticFiles();
117
-
app.UseMvc();
118
-
119
-
// Use the Steeltoe Discovery Client service
120
-
app.UseDiscoveryClient();
121
-
}
122
-
....
123
-
```
124
-
## Discovering Services
125
-
Once the app has started, the Discovery client will begin to operate in the background, both registering services and periodically fetching the service registry from the server.
126
-
127
-
The simplest way of using the registry to lookup services when using the `HttpClient` is to use the Steeltoe `DiscoveryHttpClientHandler`. For example, see below the `FortuneService` class. It is intended to be used to retrieve Fortunes from a Fortune micro service. The micro service is registered under the name `fortuneService`.
128
-
129
-
First, notice that the `FortuneService` constructor takes the `IDiscoveryClient` as a parameter. This is the discovery client interface which you use to lookup services in the service registry. Upon app startup, it is registered with the DI service so it can be easily used in any controller, view or service in your app. Notice that the constructor code makes use of the client by creating an instance of the `DiscoveryHttpClientHandler`, giving it a reference to the `IDiscoveryClient`.
130
-
131
-
Next, notice that when the `RandomFortuneAsync()` method is called, you see that the `HttpClient` is created with the handler. The handlers role is to intercept any requests made and evaluate the URL to see if the host portion of the URL can be resolved from the service registry. In this case it will attempt to resolve the "fortuneService" name into an actual `host:port` before allowing the request to continue. If the name can't be resolved the handler will still allow the request to continue, but in this case, the request will fail.
132
-
133
-
Of course you don't have to use the handler, you can make lookup requests directly on the `IDiscoveryClient` interface if you need to.
This client references a [Eureka 1.0 client](https://github.com/Netflix/eureka/wiki), not a 2.0 client. Eureka 2.0 is expected to have significant updates to its architecture and public API.
162
-
163
-
### Eureka AWS Support
164
-
The Eureka client for Java contains features which enable operation on AWS. The Steeltoe version does not currently implement those features, and instead, this version has been optimized for CloudFoundry environments. We will look at adding AWS cloud features at a future point in time.
165
-
166
-
### Eureak Configuration
167
-
Not all configuration properties found in the Java client are available for configuration. See [IEurekaClientConfig](https://github.com/SteeltoeOSS/Discovery/blob/master/src/Steeltoe.Discovery.Eureka.Client/IEurekaClientConfig.cs) and [IEurekaInstanceConfig](https://github.com/SteeltoeOSS/Discovery/blob/master/src/Steeltoe.Discovery.Eureka.Client/IEurekaInstanceConfig.cs) for configuration options.
168
-
169
-
170
-
171
-
7
+
For more information on how to use this component see the online [Steeltoe documentation](http://steeltoe.io/).
[Release or Release Candidate feed](https://www.nuget.org/) - https://www.nuget.org/
14
-
15
-
## Basic Usage
16
-
You should have a good understanding of how to setup and use a Spring Cloud Netflix Eureka Server. Detailed information on its usage can be found [here](http://projects.spring.io/spring-cloud/docs/1.0.3/spring-cloud.html#spring-cloud-eureka-server).
17
-
18
-
In order to use the Eureka client you need to do the following:
19
-
```
20
-
1. Confiure the settings the client will use to register services in the Eureka server.
21
-
2. Configure the settings the client will use to discover services in the Eureka server.
22
-
3. Initialize the `DiscoveryManager` with the configured settings.
23
-
```
24
-
## Eureka Settings needed to Register
25
-
You use an instance of `EurekaInstanceConfig` to hold the settings the Eureka client will use when registering with the Eureka server. Below is an example which registers an instance named `instance_id` of the service `myServiceName` with the Eureka server. There are many other configuration settings you can apply here and you should look at the documentation in [IEurekaInstanceConfig](https://github.com/SteeltoeOSS/Discovery/blob/master/src/Steeltoe.Discovery.Eureka.Client/IEurekaInstanceConfig.cs) for more details.
26
-
```
27
-
#using Steeltoe.Discovery.Eureka;
28
-
29
-
EurekaInstanceConfig instanceConfig = new EurekaInstanceConfig()
30
-
{
31
-
AppName = "myServiceName",
32
-
InstanceId = "instance_id",
33
-
IsInstanceEnabledOnInit = true
34
-
}
35
-
```
36
-
## Eureka Settings needed to Discover
37
-
You use an instance of `EurekaClientConfig` to hold the settings the client will use when fetching the service registry from the server. Below is an example which configures the Eureka server address to be `http://localhost:8761/eureka/`. There are many other configuration settings you can apply here and you should look at the documentation in [IEurekaClientConfig](https://github.com/SteeltoeOSS/Discovery/blob/master/src/Steeltoe.Discovery.Eureka.Client/IEurekaClientConfig.cs) for more details.
38
-
```
39
-
#using Steeltoe.Discovery.Eureka;
40
-
41
-
EurekaClientConfig clientConfig = new EurekaClientConfig()
You use the `DiscoveryManager` class to initialize the client and cause it to register services and fetch the service registry. If you don't need to register any services, then use the `Initialize()` method supplying the client config only.
This is a [Eureka 1.0 client](https://github.com/Netflix/eureka/wiki), not a 2.0 client. Eureka 2.0 is expected to have significant updates to its architecture and public API.
73
-
74
-
### AWS Support
75
-
The Eureka client for Java contains features which enable operation on AWS. The Steeltoe version does not currently implement those features, and instead, this version has been optimized for CloudFoundry environments. We will look at adding AWS cloud features at a future point in time.
76
-
77
-
### Configuration
78
-
Not all configuration properties found in the Java client are available for configuration. See [IEurekaClientConfig](https://github.com/SteeltoeOSS/Discovery/blob/master/src/Steeltoe.Discovery.Eureka.Client/IEurekaClientConfig.cs) and [IEurekaInstanceConfig](https://github.com/SteeltoeOSS/Discovery/blob/master/src/Steeltoe.Discovery.Eureka.Client/IEurekaInstanceConfig.cs) for configuration options.
79
5
6
+
For more information on how to use this component see the online [Steeltoe documentation](http://steeltoe.io/).
0 commit comments