Skip to content

Commit

Permalink
Add v0.1.1 docs (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mkabaka authored Jun 17, 2021
1 parent ede3bf1 commit 5ae88ad
Show file tree
Hide file tree
Showing 116 changed files with 4,184 additions and 2 deletions.
File renamed without changes.
6 changes: 6 additions & 0 deletions docs/Reference_Doc/v0.1.0/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
sort: 2
---

# V0.1.0
{% include list.liquid all=true %}
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions docs/Reference_Doc/v0.1.1/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
sort: 1
---

# V0.1.1
{% include list.liquid all=true %}
15 changes: 15 additions & 0 deletions docs/Reference_Doc/v0.1.1/actuator_support/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
sort: 5
---

# Spring Boot Actuator支持

Restlight适配了[Spring Boot Actuator](https://github.com/spring-projects/spring-boot/tree/master/spring-boot-project/spring-boot-actuator), 提供详细的健康检查以及监控等接口

```note
仅支持`Spring Boot2X`版本
```

{% include list.liquid all=true %}


Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
---
sort: 3
---

# 自定义`Endpoint`

用户可以自己定义`Endpoint`实现定制化的健康检查接口

eg

```java
@Endpoint(id = "appId")
public class AppIdEndpoint {

@ReadOperation
public String appId() {
return "esa-restlight";
}
}
```

上面的代码自定义了一个`Endpoint`接口并返回appid

将上面接口注入Spring容器

```java
@Bean
public AppIdEndpoint endpoint() {
return new AppIdEndpoint();
}
```

启动之后访问`curl -X GET localhost:8080/actuator/appId`

返回

```properties
esa-restlight
```

## 自定义异步`EndPoint`

用户可以自己定义基于`Completablefture``Endpoint`实现定制化的健康检查接口

eg

```java
@Endpoint(id = "appId")
public class AppIdEndpoint {

@ReadOperation
public CompletableFuture<String> appId() {
return CompletableFuture.supplyAsync(() -> {

// do something...

return "esa-restlight";
});
}
}
```

上面的代码自定义了一个异步的`Endpoint`接口并返回appid

将上面接口注入Spring容器

```java
@Bean
public AppIdEndpoint endpoint() {
return new AppIdEndpoint();
}
```

启动之后访问`curl -X GET localhost:8080/actuator/appId`

返回

```pro
esa-restlight
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
sort: 4
---

# 使用独立的端口

默认情况下健康检查的接口都将与`Restight`使用同一个HttpServer服务, 如果需要将健康检查接口与业务接口分别使用不同的端口则可以添加一下配置

```properties
#配置健康检查暴露的端口
management.server.port=8081
```

启动后看到日志打印

```properties
Started Restlight(Actuator) server in 386 millis on port:8081
```

```warning
独立端口启动后所有的`Filter`, 序列化, `ArgumentResolver`等扩展将与`Restlight`隔离
```

## 辅助配置

`SpringBoot`场景下大多数的配置可通过`application.properties`(或者yaml)配置文件即可完成配置,但是配置文件配置还是会有其缺陷

- 无法动态配置(这里的动态指的是通过代码计算等方式决定配置)
- 语法表达能力有限
- 配置过多变得冗杂

等问题。

### `ManagementConfigure`

用于支持`SpringBoot`场景显式配置

eg.

```java
@Bean
public ManagementConfigure configure() {
return restlight -> {
restlight.address(8081)
.addFilter((request, response, chain) -> {
// biz logic
return chain.doFilter(request, response);
});
restlight.options().setCoreBizThreads(16);
restlight.options().setMaxBizThreads(32);
// more...
};
}
```
30 changes: 30 additions & 0 deletions docs/Reference_Doc/v0.1.1/actuator_support/quick_start.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
sort: 1
---

# Quick Start

引入Maven依赖:

```xml
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<version>2.1.1.RELEASE</version>
</dependency>
<dependency>
<groupId>io.esastack</groupId>
<artifactId>restlight-starter-actuator</artifactId>
<version>${restlight.version}</version>
</dependency>
```

```note
Actuator的版本请配合对应的Spring Boot版本引入
```

访问 `Get` `localhost:8080/actuator/info`返回`{}`

```tip
Spring Boot2.0之后的Atctuator默认只开启了`info`和`health`两个接口, 可以使用`management.endpoints.web.exposure.include=info,health,foo`开启。
```
Loading

0 comments on commit 5ae88ad

Please sign in to comment.