Skip to content
This repository was archived by the owner on May 17, 2019. It is now read-only.

Commit f696da7

Browse files
committed
Updates to point to new documentation
1 parent 3e0e95f commit f696da7

File tree

3 files changed

+4
-240
lines changed

3 files changed

+4
-240
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ While the primary usage of the providers is intended to be with ASP.NET Core app
2020

2121
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.
2222
# 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/).
2425

2526
# Nuget Feeds
2627
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.

src/Steeltoe.Discovery.Client/README.md

Lines changed: 1 addition & 165 deletions
Original file line numberDiff line numberDiff line change
@@ -4,168 +4,4 @@ This project contains the Steeltoe Discovery Client. This client provides a gen
44

55
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.
66

7-
## Provider Package Name and Feeds
8-
9-
`Steeltoe.Discovery.Client`
10-
11-
[Development feed (Less Stable)](https://www.myget.org/gallery/steeltoedev) - https://www.myget.org/gallery/steeltoedev
12-
13-
[Master feed (Stable)](https://www.myget.org/gallery/steeltoemaster) - https://www.myget.org/gallery/steeltoemaster
14-
15-
[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.
134-
135-
```
136-
using Steeltoe.Discovery.Client;
137-
....
138-
public class FortuneService : IFortuneService
139-
{
140-
DiscoveryHttpClientHandler _handler;
141-
private const string RANDOM_FORTUNE_URL = "http://fortuneService/api/fortunes/random";
142-
public FortuneService(IDiscoveryClient client)
143-
{
144-
_handler = new DiscoveryHttpClientHandler(client);
145-
}
146-
public async Task<string> RandomFortuneAsync()
147-
{
148-
var client = GetClient();
149-
return await client.GetStringAsync(RANDOM_FORTUNE_URL);
150-
}
151-
private HttpClient GetClient()
152-
{
153-
var client = new HttpClient(_handler, false);
154-
return client;
155-
}
156-
}
157-
```
158-
# Known Limitations
159-
160-
### Eureka Version
161-
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/).

src/Steeltoe.Discovery.Eureka.Client/README.md

Lines changed: 1 addition & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -2,78 +2,5 @@
22

33
This project contains the Steeltoe Eureka Client. This client provides access to the Netflix Eureka Server.
44

5-
## Provider Package Name and Feeds
6-
7-
`Steeltoe.Discovery.Eureka.Client`
8-
9-
[Development feed (Less Stable)](https://www.myget.org/gallery/steeltoedev) - https://www.myget.org/gallery/steeltoedev
10-
11-
[Master feed (Stable)](https://www.myget.org/gallery/steeltoemaster) - https://www.myget.org/gallery/steeltoemaster
12-
13-
[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()
42-
{
43-
EurekaServerServiceUrls = "http://localhost:8761/eureka/"
44-
}
45-
```
46-
47-
## Initialize and Use the Eureka Client
48-
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.
49-
```
50-
#using Steeltoe.Discovery.Eureka;
51-
...
52-
53-
// Register services and fetch the registry
54-
DiscoveryManager.Instance.Initialize(clientConfig, instanceConfig);
55-
56-
or
57-
58-
// No services to register
59-
// Note: You also need to set `ShouldRegisterWithEureka` = `false` in EurekaClientConfig, the default is `true`
60-
DiscoveryManager.Instance.Initialize(clientConfig);
61-
```
62-
Once you have initialized the client you can obtain an instance of the `IEurekaClient` and use its methods to lookup services or instances.
63-
```
64-
IEurekaClient client = DiscoveryManager.Instance.Client;
65-
66-
Application app = client.GetApplication("SomeName");
67-
68-
```
69-
# Known Limitations
70-
71-
### Version
72-
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.
795

6+
For more information on how to use this component see the online [Steeltoe documentation](http://steeltoe.io/).

0 commit comments

Comments
 (0)