parent
73793a506c
commit
de863e37c0
@ -0,0 +1,32 @@
|
|||||||
|
# Spring Cloud Tencent Polaris Gateway
|
||||||
|
|
||||||
|
## Module Introduction
|
||||||
|
|
||||||
|
```spring-cloud-tencent-polaris-gateway``` is used in Spring Cloud project joint with
|
||||||
|
[Polaris](https://github.com/PolarisMesh/polaris)'s Polaris Gateway component.
|
||||||
|
You can use Polaris's extension microservice gateway features by importing dependency.
|
||||||
|
|
||||||
|
## Features Instruction
|
||||||
|
|
||||||
|
### Metadata Delivery
|
||||||
|
|
||||||
|
Support metadata delivery between gateways and microservices.
|
||||||
|
|
||||||
|
## User Guide
|
||||||
|
|
||||||
|
This chapter will explain how to use Spring Cloud Tencent Polaris Gateway's features in the Spring Cloud project.
|
||||||
|
Before starting MicroService, one needs to launch Polaris.
|
||||||
|
Please refer to [Polaris Getting Started](https://github.com/PolarisMesh/polaris#getting-started).
|
||||||
|
|
||||||
|
1. you can add ```spring-cloud-tencent-polaris-gateway``` in your project to use Polaris's microservice gateway extension features
|
||||||
|
(meaning you still need to add microservice gateway modules yourself, such as zuul, spring-cloud-gateway).
|
||||||
|
For example, in Maven's project, add listed configurations in pom:
|
||||||
|
|
||||||
|
```XML
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.tencent.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-tencent-polaris-gateway</artifactId>
|
||||||
|
</dependency>
|
||||||
|
```
|
||||||
|
|
||||||
|
2. For further instructions, please refer to [Polaris Gateway Example](../../../../spring-cloud-tencent-examples/polaris-gateway-example/README.md)。.
|
@ -0,0 +1,77 @@
|
|||||||
|
# Spring Cloud Polaris Gateway example
|
||||||
|
|
||||||
|
## Example Introduction
|
||||||
|
|
||||||
|
This example shows how to use ```spring-cloud-tencent-polaris-gateway`` in Spring Cloud project for its features.
|
||||||
|
|
||||||
|
This example contains ```gateway-zuul-service```, ```gateway-scg-service``` and ```gateway-callee-service```. ```gateway-zuul-service``` and ```gateway-scg-service``` invoke ```gateway-callee-service```.
|
||||||
|
|
||||||
|
## Instruction
|
||||||
|
|
||||||
|
### Configuration
|
||||||
|
|
||||||
|
The configuration is as the following shows. ${ip} and ${port} are Polaris backend IP address and port number.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
spring:
|
||||||
|
application:
|
||||||
|
name: ${application.name}
|
||||||
|
cloud:
|
||||||
|
polaris:
|
||||||
|
address: ${ip}:${port}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Launching Example
|
||||||
|
|
||||||
|
#### Launching Polaris Backend Service
|
||||||
|
|
||||||
|
Reference to [Polaris Getting Started](https://github.com/PolarisMesh/polaris#getting-started)
|
||||||
|
|
||||||
|
#### Launching Application
|
||||||
|
|
||||||
|
- IDEA Launching
|
||||||
|
|
||||||
|
Launching ```spring-cloud-tencent-examples/polaris-gateway-example/gateway-zuul-service```'s ```GatewayZuulService```, ```spring-cloud-tencent-examples/polaris-gateway-example/gateway-scg-service```'s ```GatewayScgService``` and ```spring-cloud-tencent-examples/polaris-gateway-example/gateway-callee-service```'s ```GatewayCalleeService```
|
||||||
|
|
||||||
|
- Maven Package Launching
|
||||||
|
|
||||||
|
Execute under ```spring-cloud-tencent-examples/polaris-gateway-example```
|
||||||
|
|
||||||
|
```sh
|
||||||
|
mvn clean package
|
||||||
|
```
|
||||||
|
|
||||||
|
Then find the jars under ```gateway-zuul-service```, ```gateway-scg-service``` and ```gateway-callee-service```, and run it:
|
||||||
|
|
||||||
|
```
|
||||||
|
java -jar ${app.jar}
|
||||||
|
```
|
||||||
|
|
||||||
|
Launch application, change ${app.jar} to jar's package name.
|
||||||
|
|
||||||
|
### Verify
|
||||||
|
|
||||||
|
#### Zuul Invoke
|
||||||
|
|
||||||
|
```shell
|
||||||
|
curl -L -X GET 'http://localhost:48082/GatewayCalleeService/gateway/example/callee/echo' -H 'SCT-CUSTOM-METADATA: {"b": 2}'
|
||||||
|
```
|
||||||
|
|
||||||
|
Expected return rate
|
||||||
|
|
||||||
|
```
|
||||||
|
{"a":"1","b":2}
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Spring-Cloud-Gateway Invoke
|
||||||
|
|
||||||
|
```shell
|
||||||
|
curl -L -X GET 'http://localhost:48083/GatewayCalleeService/gateway/example/callee/echo' -H 'SCT-CUSTOM-METADATA: {"b": 2}'
|
||||||
|
```
|
||||||
|
|
||||||
|
Expected return rate
|
||||||
|
|
||||||
|
```
|
||||||
|
{"a":"1","b":2}
|
||||||
|
```
|
||||||
|
|
Loading…
Reference in new issue