From de0352ae6bd76c22c8ab49687b6519623fcd7cc3 Mon Sep 17 00:00:00 2001
From: Dave Syer
Date: Fri, 4 Sep 2015 08:26:56 +0000
Subject: [PATCH] Sync docs from master to gh-pages
---
spring-cloud.html | 198 ++++++++++++++++++++++++++++++++++++++++------
1 file changed, 174 insertions(+), 24 deletions(-)
diff --git a/spring-cloud.html b/spring-cloud.html
index 5865e7d..a2a4068 100644
--- a/spring-cloud.html
+++ b/spring-cloud.html
@@ -476,6 +476,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
-Declarative REST Client: Feign
+Declarative REST Client: Feign
+
+
External Configuration: Archaius
Router and Filter: Zuul
@@ -754,8 +759,8 @@ things with their parent.
Changing the Location of Bootstrap Properties
-
The bootstrap.yml (or .properties) location can be specified using
-`spring.cloud.bootstrap.name (default "bootstrap") or
+
The bootstrap.yml (or .properties) location can be specified using
+spring.cloud.bootstrap.name (default "bootstrap") or
spring.cloud.bootstrap.location (default empty), e.g. in System
properties. Those properties behave like the spring.config.*
variants with the same name, in fact they are used to set up the
@@ -1057,12 +1062,7 @@ the provided `@LoadBalanced Qualifier:
Spring Cloud Config
-
-
Spring Cloud Config provides server and client-side support for externalized configuration in a distributed system. With the Config Server you have a central place to manage external properties for applications across all environments. The concepts on both client and server map identically to the Spring Environment and PropertySource abstractions, so they fit very well with Spring applications, but can be used with any application running in any language. As an application moves through the deployment pipeline from dev to test and into production you can manage the configuration between those environments and be certain that applications have everything they need to run when they migrate. The default implementation of the server storage backend uses git so it easily supports labelled versions of configuration environments, as well as being accessible to a wide range of tooling for managing the content. It is easy to add alternative implementations and plug them in with Spring configuration.
-
-
+Spring Cloud Config provides server and client-side support for externalized configuration in a distributed system. With the Config Server you have a central place to manage external properties for applications across all environments. The concepts on both client and server map identically to the Spring
Environment and
PropertySource abstractions, so they fit very well with Spring applications, but can be used with any application running in any language. As an application moves through the deployment pipeline from dev to test and into production you can manage the configuration between those environments and be certain that applications have everything they need to run when they migrate. The default implementation of the server storage backend uses git so it easily supports labelled versions of configuration environments, as well as being accessible to a wide range of tooling for managing the content. It is easy to add alternative implementations and plug them in with Spring configuration.
@@ -1272,7 +1272,78 @@ the config server URL.
The Server provides an HTTP, resource-based API for external
configuration (name-value pairs, or equivalent YAML content). The
server is easily embeddable in a Spring Boot application using the
-@EnableConfigServer annotation.
+
@EnableConfigServer annotation. So this app is a config server:
+
+
+
ConfigServer.java
+
+
@SpringBootApplication
+@EnableConfigServer
+public class ConfigServer {
+ public static void main(String[] args) {
+ SpringApplication.run(ConfigServer.class, args);
+ }
+}
+
+
+
+
Like all Spring Boot apps it runs on port 8080 by default, but you
+can switch it to the conventional port 8888 in various ways. The
+easiest, which also sets a default configuration repository,
+is by launching it with spring.config.name=configserver (there
+is a configserver.yml in the Config Server jar). Another is
+to use your own application.properties, e.g.
+
+
+
application.properties
+
+
server.port: 8888
+spring.cloud.config.server.git.uri: file://${HOME}/config-repo
+
+
+
+
where ${HOME}/config-repo is a git repository containing
+YAML and properties files.
+
+
+
+
+|
+ Tip
+ |
+
+
+ Here’s a recipe for creating the git repository in the example
+above:
+
+
+
+ $ cd $HOME
+$ mkdir config-repo
+$ cd config-repo
+$ git init .
+$ echo info.foo: bar > application.properties
+$ git add -A .
+$ git commit -m "Add application.properties"
+
+
+ |
+
+
+
+
+
+
+|
+ Warning
+ |
+
+using the local filesystem for your git repository is
+intended for testing only. Use a server to host your
+configuration repositories in production.
+ |
+
+
Environment Repository
@@ -1654,9 +1725,9 @@ mysecret
-
Take the encypted value and add the {cipher} prefix before you put
+
Take the encrypted value and add the {cipher} prefix before you put
it in the YAML or properties file, and before you commit and push it
-to a remote, potentially insecure store. The /encypt and /decrypt
+to a remote, potentially insecure store. The /encrypt and /decrypt
endpoints also both accept paths of the form /*/{name}/{profiles}
which can be used to control cryptography per application (name)
and profile when clients call into the main Environment resource.
@@ -1689,7 +1760,7 @@ mysecret
-
To use a key in a file (e.g. an RSA public key for encyption) prepend
+
To use a key in a file (e.g. an RSA public key for encryption) prepend
the key value with "@" and provide the file path, e.g.
@@ -2121,17 +2192,43 @@ non-default context path or servlet path
eureka:
instance:
- statusPageUrlPath: ${management.contextPath}/info
- healthCheckUrlPath: ${management.contextPath}/health
+ statusPageUrlPath: ${management.context-path}/info
+ healthCheckUrlPath: ${management.context-path}/health
-
These links show up in the metadata that is consumers by clients, and
+
These links show up in the metadata that is consumed by clients, and
used in some scenarios to decide whether to send requests to your
application, so it’s helpful if they are accurate.
+
Eureka’s Health Checks
+
+
By default, Eureka uses the client heartbeat to determine if a client is up.
+Unless specified otherwise the Discovery Client will not propagate the
+application Spring Boot Actuator current health check status. Which means
+that after successful registration Eureka will always announce that the
+application is in 'UP' state. This behaviour can be altered by enabling
+Eureka health checks, which results in propagating application status
+to Eureka, as a consequence every other application will not sending
+traffic to application in state other then 'UP'.
+
+
+
application.yml
+
+
eureka:
+ client:
+ healthcheck:
+ enabled: true
+
+
+
+
If you require more control over the health checks, you may consider
+implementing your own com.netflix.appinfo.HealthCheckHandler.
+
+
+
It’s worth spending a bit of time understanding how the Eureka metadata works, so you can use it in a way that makes sense in your platform. There is standard metadata for things like hostname, IP address, port numbers, status page and health check. These are published in the service registry and used by clients to contact the services in a straightforward way. Additional metadata can be added to the instance registration in the eureka.instance.metadataMap, and this will be accessible in the remote clients, but in general will not change the behaviour of the client, unless it is made aware of the meaning of the metadata. There are a couple of special cases described below where Spring Cloud already assigns meaning to the metadata map.
@@ -2541,9 +2638,6 @@ for details on the properties available.
The same thing applies if you are using @SessionScope or @RequestScope. You will know when you need to do this because of a runtime exception that says it can’t find the scoped context.
-
-
In particular you might be interested
-
Health Indicator
@@ -2758,7 +2852,7 @@ explicitly in the
@ComponentScan).
IPing ribbonPing: NoOpPing
-ServerList<Server> ribbonServerList: `ConfigurationBasedServerList
+ServerList<Server> ribbonServerList: ConfigurationBasedServerList
ServerListFilter<Server> ribbonServerListFilter: ZonePreferenceServerListFilter
@@ -2803,7 +2897,7 @@ server list will be constructed with "zone" information as provided in
the instance metadata (so on the client set
eureka.instance.metadataMap.zone), and if that is missing it can use
the domain name from the server hostname as a proxy for zone (if the
-flag approximateZoneFromDomain is set). Once the zone information is
+flag approximateZoneFromHostname is set). Once the zone information is
available it can be used in a ServerListFilter (by default it will
be used to locate a server in the same zone as the client because the
default is a ZonePreferenceServerListFilter).
@@ -2919,6 +3013,43 @@ don’t want to use Eureka, you can simply configure a list of servers
in your external configuration (see
above for example).
+
+
Feign Inheritance Support
+
+
Feign supports boilerplate apis via single-inheritance interfaces.
+This allows grouping common operations into convenient base interfaces.
+Together with Spring MVC you can share the same contract for your
+REST endpoint and Feign client.
+
+
+
UserService.java
+
+
public interface UserService {
+
+ @RequestMapping(method = RequestMethod.GET, value ="/users/{id}")
+ User getUser(@PathVariable("id") long id);
+}
+
+
+
+
UserResource.java
+
+
@RestController
+public class UserResource implements UserService {
+
+}
+
+
+
+
UserClient.java
+
+
@FeignClient("users")
+public interface UserClient extends UserService {
+
+}
+
+
+
@@ -3022,7 +3153,7 @@ configured routes map, then it will be unignored. Example:
application.yml
zuul:
- ignoredServices: *
+ ignoredServices: '*'
routes:
users: /myusers/**
@@ -3133,7 +3264,7 @@ Set that flag to "true" to have the Ribbon client automatically retry failed req
the Ribbon client configuration).
-
The X-Forwarded-Host header added to the forwarded requests by
+
The X-Forwarded-Host header is added to the forwarded requests by
default. To turn it off set zuul.addProxyHeaders = false. The
prefix path is stripped by default, and the request to the backend
picks up a header "X-Forwarded-Prefix" ("/myusers" in the examples
@@ -3144,6 +3275,25 @@ above).
server if you set a default route ("/"), for example
zuul.route.home:
/ would route all traffic (i.e. "/**") to the "home" service.
+
+
If more fine-grained ignoring is needed, you can specify specific patterns to ignore.
+These patterns are being evaluated at the end of the route location process, which
+means prefixes should be included in the pattern to warrant a match. Ignored patterns
+span all services and supersede any other route specification.
+
+
+
application.yml
+
+
zuul:
+ ignoredPatterns: */admin/**
+ routes:
+ users: /myusers/**
+
+
+
+
This means that all calls such as "/myusers/101" will be forwarded to "/101" on the "users" service.
+But calls including "/admin/" will not resolve.
+
Uploading Files through Zuul
@@ -3546,7 +3696,7 @@ AQAjPgt3eFZQXwt8tsHAVv/QHiY5sI2dRcR+...