docs: 优化 README.md 导航中无法跳转结构体的情况

This commit is contained in:
kercylan98
2024-01-15 10:41:10 +08:00
parent bd7a3fee6b
commit e7e679ea86
51 changed files with 480 additions and 240 deletions

View File

@@ -54,26 +54,26 @@ server 提供了包含多种网络类型的服务器实现
|类型|名称|描述
|:--|:--|:--
|`STRUCT`|[Bot](#bot)|暂无描述...
|`STRUCT`|[BotOption](#botoption)|暂无描述...
|`STRUCT`|[Conn](#conn)|服务器连接单次消息的包装
|`STRUCT`|[ConsoleParams](#consoleparams)|控制台参数
|`STRUCT`|[MessageReadyEventHandler](#messagereadyeventhandler)|暂无描述...
|`STRUCT`|[Http](#http)|基于 gin.Engine 包装的 http 服务器
|`STRUCT`|[HttpContext](#httpcontext)|基于 gin.Context 的 http 请求上下文
|`STRUCT`|[HandlerFunc](#handlerfunc)|暂无描述...
|`STRUCT`|[ContextPacker](#contextpacker)|暂无描述...
|`STRUCT`|[HttpRouter](#httprouter)|暂无描述...
|`STRUCT`|[HttpWrapperHandleFunc](#httpwrapperhandlefunc)|暂无描述...
|`STRUCT`|[HttpWrapper](#httpwrapper)|http 包装器
|`STRUCT`|[HttpWrapperGroup](#httpwrappergroup)|http 包装器
|`STRUCT`|[MessageType](#messagetype)|暂无描述...
|`STRUCT`|[Message](#message)|服务器消息
|`STRUCT`|[MultipleServer](#multipleserver)|暂无描述...
|`STRUCT`|[Network](#network)|暂无描述...
|`STRUCT`|[Option](#option)|暂无描述...
|`STRUCT`|[Server](#server)|网络服务器
|`INTERFACE`|[Service](#service)|兼容传统 service 设计模式的接口
|`STRUCT`|[Bot](#struct_Bot)|暂无描述...
|`STRUCT`|[BotOption](#struct_BotOption)|暂无描述...
|`STRUCT`|[Conn](#struct_Conn)|服务器连接单次消息的包装
|`STRUCT`|[ConsoleParams](#struct_ConsoleParams)|控制台参数
|`STRUCT`|[MessageReadyEventHandler](#struct_MessageReadyEventHandler)|暂无描述...
|`STRUCT`|[Http](#struct_Http)|基于 gin.Engine 包装的 http 服务器
|`STRUCT`|[HttpContext](#struct_HttpContext)|基于 gin.Context 的 http 请求上下文
|`STRUCT`|[HandlerFunc](#struct_HandlerFunc)|暂无描述...
|`STRUCT`|[ContextPacker](#struct_ContextPacker)|暂无描述...
|`STRUCT`|[HttpRouter](#struct_HttpRouter)|暂无描述...
|`STRUCT`|[HttpWrapperHandleFunc](#struct_HttpWrapperHandleFunc)|暂无描述...
|`STRUCT`|[HttpWrapper](#struct_HttpWrapper)|http 包装器
|`STRUCT`|[HttpWrapperGroup](#struct_HttpWrapperGroup)|http 包装器
|`STRUCT`|[MessageType](#struct_MessageType)|暂无描述...
|`STRUCT`|[Message](#struct_Message)|服务器消息
|`STRUCT`|[MultipleServer](#struct_MultipleServer)|暂无描述...
|`STRUCT`|[Network](#struct_Network)|暂无描述...
|`STRUCT`|[Option](#struct_Option)|暂无描述...
|`STRUCT`|[Server](#struct_Server)|网络服务器
|`INTERFACE`|[Service](#struct_Service)|兼容传统 service 设计模式的接口
</details>
@@ -385,6 +385,7 @@ func TestBindService(t *testing.T) {
***
<span id="struct_Bot"></span>
### Bot `STRUCT`
```go
@@ -413,11 +414,13 @@ type Bot struct {
#### func (*Bot) SendWSPacket(wst int, packet []byte)
> 发送 WebSocket 数据包到服务器
***
<span id="struct_BotOption"></span>
### BotOption `STRUCT`
```go
type BotOption func(bot *Bot)
```
<span id="struct_Conn"></span>
### Conn `STRUCT`
服务器连接单次消息的包装
```go
@@ -501,6 +504,7 @@ type Conn struct {
#### func (*Conn) Close(err ...error)
> 关闭连接
***
<span id="struct_ConsoleParams"></span>
### ConsoleParams `STRUCT`
控制台参数
```go
@@ -527,11 +531,13 @@ type ConsoleParams map[string][]string
#### func (ConsoleParams) Clear()
> 清空参数
***
<span id="struct_MessageReadyEventHandler"></span>
### MessageReadyEventHandler `STRUCT`
```go
type MessageReadyEventHandler func(srv *Server)
```
<span id="struct_Http"></span>
### Http `STRUCT`
基于 gin.Engine 包装的 http 服务器
```go
@@ -543,6 +549,7 @@ type Http[Context any] struct {
```
#### func (*Http) Gin() *gin.Engine
***
<span id="struct_HttpContext"></span>
### HttpContext `STRUCT`
基于 gin.Context 的 http 请求上下文
```go
@@ -556,16 +563,19 @@ type HttpContext struct {
#### func (*HttpContext) ReadTo(dest any) error
> 读取请求数据到指定结构体,如果失败则返回错误
***
<span id="struct_HandlerFunc"></span>
### HandlerFunc `STRUCT`
```go
type HandlerFunc[Context any] func(ctx Context)
```
<span id="struct_ContextPacker"></span>
### ContextPacker `STRUCT`
```go
type ContextPacker[Context any] func(ctx *gin.Context) Context
```
<span id="struct_HttpRouter"></span>
### HttpRouter `STRUCT`
```go
@@ -639,11 +649,13 @@ type HttpRouter[Context any] struct {
#### func (*HttpRouter) Use(middleware ...HandlerFunc[Context]) *HttpRouter[Context]
> 将中间件附加到路由组。
***
<span id="struct_HttpWrapperHandleFunc"></span>
### HttpWrapperHandleFunc `STRUCT`
```go
type HttpWrapperHandleFunc[CTX any] func(ctx CTX)
```
<span id="struct_HttpWrapper"></span>
### HttpWrapper `STRUCT`
http 包装器
```go
@@ -703,6 +715,7 @@ type HttpWrapper[CTX any] struct {
#### func (*HttpWrapper) Group(relativePath string, handlers ...HttpWrapperHandleFunc[CTX]) *HttpWrapperGroup[CTX]
> 创建一个新的路由组。您应该添加所有具有共同中间件的路由。
***
<span id="struct_HttpWrapperGroup"></span>
### HttpWrapperGroup `STRUCT`
http 包装器
```go
@@ -738,6 +751,7 @@ type HttpWrapperGroup[CTX any] struct {
#### func (*HttpWrapperGroup) Group(relativePath string, handlers ...HttpWrapperHandleFunc[CTX]) *HttpWrapperGroup[CTX]
> 创建分组
***
<span id="struct_MessageType"></span>
### MessageType `STRUCT`
```go
@@ -746,6 +760,7 @@ type MessageType byte
#### func (MessageType) String() string
> 返回消息类型的字符串表示
***
<span id="struct_Message"></span>
### Message `STRUCT`
服务器消息
```go
@@ -771,6 +786,7 @@ type Message struct {
#### func (*Message) String() string
> 返回消息的字符串表示
***
<span id="struct_MultipleServer"></span>
### MultipleServer `STRUCT`
```go
@@ -787,6 +803,7 @@ type MultipleServer struct {
***
#### func (*MultipleServer) OnExitEvent()
***
<span id="struct_Network"></span>
### Network `STRUCT`
```go
@@ -795,11 +812,13 @@ type Network string
#### func (Network) IsSocket() bool
> 返回当前服务器的网络模式是否为 Socket 模式
***
<span id="struct_Option"></span>
### Option `STRUCT`
```go
type Option func(srv *Server)
```
<span id="struct_Server"></span>
### Server `STRUCT`
网络服务器
```go
@@ -966,6 +985,7 @@ func ExampleServer_Run() {
#### func (*Server) HasMessageStatistics() bool
> 是否了开启消息统计
***
<span id="struct_Service"></span>
### Service `INTERFACE`
兼容传统 service 设计模式的接口
```go

View File

@@ -27,13 +27,13 @@
|类型|名称|描述
|:--|:--|:--
|`STRUCT`|[Client](#client)|客户端
|`INTERFACE`|[Core](#core)|暂无描述...
|`STRUCT`|[ConnectionClosedEventHandle](#connectionclosedeventhandle)|暂无描述...
|`STRUCT`|[Packet](#packet)|暂无描述...
|`STRUCT`|[TCP](#tcp)|暂无描述...
|`STRUCT`|[UnixDomainSocket](#unixdomainsocket)|暂无描述...
|`STRUCT`|[Websocket](#websocket)|websocket 客户端
|`STRUCT`|[Client](#struct_Client)|客户端
|`INTERFACE`|[Core](#struct_Core)|暂无描述...
|`STRUCT`|[ConnectionClosedEventHandle](#struct_ConnectionClosedEventHandle)|暂无描述...
|`STRUCT`|[Packet](#struct_Packet)|暂无描述...
|`STRUCT`|[TCP](#struct_TCP)|暂无描述...
|`STRUCT`|[UnixDomainSocket](#struct_UnixDomainSocket)|暂无描述...
|`STRUCT`|[Websocket](#struct_Websocket)|websocket 客户端
</details>
@@ -63,6 +63,7 @@
> 创建 websocket 客户端
***
<span id="struct_Client"></span>
### Client `STRUCT`
客户端
```go
@@ -138,6 +139,7 @@ func TestClient_WriteWS(t *testing.T) {
#### func (*Client) GetServerAddr() string
> 获取服务器地址
***
<span id="struct_Core"></span>
### Core `INTERFACE`
```go
@@ -149,11 +151,13 @@ type Core interface {
Clone() Core
}
```
<span id="struct_ConnectionClosedEventHandle"></span>
### ConnectionClosedEventHandle `STRUCT`
```go
type ConnectionClosedEventHandle func(conn *Client, err any)
```
<span id="struct_Packet"></span>
### Packet `STRUCT`
```go
@@ -163,6 +167,7 @@ type Packet struct {
callback func(err error)
}
```
<span id="struct_TCP"></span>
### TCP `STRUCT`
```go
@@ -182,6 +187,7 @@ type TCP struct {
***
#### func (*TCP) Clone() Core
***
<span id="struct_UnixDomainSocket"></span>
### UnixDomainSocket `STRUCT`
```go
@@ -243,6 +249,7 @@ func TestUnixDomainSocket_Write(t *testing.T) {
***
#### func (*UnixDomainSocket) Clone() Core
***
<span id="struct_Websocket"></span>
### Websocket `STRUCT`
websocket 客户端
```go

View File

@@ -32,13 +32,13 @@ gateway 是用于处理服务器消息的网关模块,适用于对客户端消
|类型|名称|描述
|:--|:--|:--
|`STRUCT`|[Endpoint](#endpoint)|网关端点
|`STRUCT`|[EndpointOption](#endpointoption)|网关端点选项
|`STRUCT`|[ConnectionOpenedEventHandle](#connectionopenedeventhandle)|暂无描述...
|`STRUCT`|[EndpointSelector](#endpointselector)|暂无描述...
|`STRUCT`|[Gateway](#gateway)|基于 server.Server 实现的网关服务器
|`STRUCT`|[Option](#option)|网关选项
|`INTERFACE`|[Scanner](#scanner)|端点扫描器
|`STRUCT`|[Endpoint](#struct_Endpoint)|网关端点
|`STRUCT`|[EndpointOption](#struct_EndpointOption)|网关端点选项
|`STRUCT`|[ConnectionOpenedEventHandle](#struct_ConnectionOpenedEventHandle)|暂无描述...
|`STRUCT`|[EndpointSelector](#struct_EndpointSelector)|暂无描述...
|`STRUCT`|[Gateway](#struct_Gateway)|基于 server.Server 实现的网关服务器
|`STRUCT`|[Option](#struct_Option)|网关选项
|`INTERFACE`|[Scanner](#struct_Scanner)|端点扫描器
</details>
@@ -105,6 +105,7 @@ gateway 是用于处理服务器消息的网关模块,适用于对客户端消
> - | ipv4(4) | port(2) | cost(4) | packet |
***
<span id="struct_Endpoint"></span>
### Endpoint `STRUCT`
网关端点
- 每一个端点均表示了一个目标服务,网关会将数据包转发到该端点,由该端点负责将数据包转发到目标服务。
@@ -141,21 +142,25 @@ type Endpoint struct {
> 转发数据包到该端点
> - 端点在处理数据包时,应区分数据包为普通直连数据包还是网关数据包。可通过 UnmarshalGatewayOutPacket 进行数据包解析,当解析失败且无其他数据包协议时,可认为该数据包为普通直连数据包。
***
<span id="struct_EndpointOption"></span>
### EndpointOption `STRUCT`
网关端点选项
```go
type EndpointOption func(endpoint *Endpoint)
```
<span id="struct_ConnectionOpenedEventHandle"></span>
### ConnectionOpenedEventHandle `STRUCT`
```go
type ConnectionOpenedEventHandle func(gateway *Gateway, conn *server.Conn)
```
<span id="struct_EndpointSelector"></span>
### EndpointSelector `STRUCT`
```go
type EndpointSelector func(endpoints []*Endpoint) *Endpoint
```
<span id="struct_Gateway"></span>
### Gateway `STRUCT`
基于 server.Server 实现的网关服务器
- 网关服务器是一个特殊的服务器,它会通过扫描器扫描端点列表,然后连接到端点列表中的所有端点,当端点连接成功后,网关服务器会将客户端的连接数据转发到端点服务器
@@ -230,11 +235,13 @@ func TestGateway_Run(t *testing.T) {
#### func (*Gateway) SwitchEndpoint(source *Endpoint, dest *Endpoint)
> 将端点端点的所有连接切换到另一个端点
***
<span id="struct_Option"></span>
### Option `STRUCT`
网关选项
```go
type Option func(gateway *Gateway)
```
<span id="struct_Scanner"></span>
### Scanner `INTERFACE`
端点扫描器
```go

View File

@@ -24,12 +24,12 @@
|类型|名称|描述
|:--|:--|:--
|`STRUCT`|[Action](#action)|消息分发器操作器,用于暴露外部可操作的消息分发器函数
|`STRUCT`|[Handler](#handler)|消息处理器
|`STRUCT`|[Dispatcher](#dispatcher)|用于服务器消息处理的消息分发器
|`STRUCT`|[Manager](#manager)|消息分发器管理器
|`INTERFACE`|[Message](#message)|暂无描述...
|`INTERFACE`|[Producer](#producer)|暂无描述...
|`STRUCT`|[Action](#struct_Action)|消息分发器操作器,用于暴露外部可操作的消息分发器函数
|`STRUCT`|[Handler](#struct_Handler)|消息处理器
|`STRUCT`|[Dispatcher](#struct_Dispatcher)|用于服务器消息处理的消息分发器
|`STRUCT`|[Manager](#struct_Manager)|消息分发器管理器
|`INTERFACE`|[Message](#struct_Message)|暂无描述...
|`INTERFACE`|[Producer](#struct_Producer)|暂无描述...
</details>
@@ -165,6 +165,7 @@ func TestNewManager(t *testing.T) {
***
<span id="struct_Action"></span>
### Action `STRUCT`
消息分发器操作器,用于暴露外部可操作的消息分发器函数
```go
@@ -173,11 +174,13 @@ type Action[P Producer, M Message[P]] struct {
d *Dispatcher[P, M]
}
```
<span id="struct_Handler"></span>
### Handler `STRUCT`
消息处理器
```go
type Handler[P Producer, M Message[P]] func(dispatcher *Dispatcher[P, M], message M)
```
<span id="struct_Dispatcher"></span>
### Dispatcher `STRUCT`
用于服务器消息处理的消息分发器
@@ -207,6 +210,7 @@ type Dispatcher[P Producer, M Message[P]] struct {
abort chan struct{}
}
```
<span id="struct_Manager"></span>
### Manager `STRUCT`
消息分发器管理器
```go
@@ -223,6 +227,7 @@ type Manager[P Producer, M Message[P]] struct {
createdHandler func(name string)
}
```
<span id="struct_Message"></span>
### Message `INTERFACE`
```go
@@ -230,6 +235,7 @@ type Message[P comparable] interface {
GetProducer() P
}
```
<span id="struct_Producer"></span>
### Producer `INTERFACE`
```go

View File

@@ -16,14 +16,15 @@
|类型|名称|描述
|:--|:--|:--
|`STRUCT`|[Ants](#ants)|暂无描述...
|`STRUCT`|[GNet](#gnet)|暂无描述...
|`STRUCT`|[Ants](#struct_Ants)|暂无描述...
|`STRUCT`|[GNet](#struct_GNet)|暂无描述...
</details>
***
## 详情信息
<span id="struct_Ants"></span>
### Ants `STRUCT`
```go
@@ -31,6 +32,7 @@ type Ants struct{}
```
#### func (*Ants) Printf(format string, args ...interface {})
***
<span id="struct_GNet"></span>
### GNet `STRUCT`
```go

View File

@@ -27,10 +27,10 @@
|类型|名称|描述
|:--|:--|:--
|`INTERFACE`|[Client](#client)|帧同步客户端接口定义
|`STRUCT`|[StoppedEventHandle](#stoppedeventhandle)|暂无描述...
|`STRUCT`|[Lockstep](#lockstep)|锁步(帧)同步默认实现
|`STRUCT`|[Option](#option)|暂无描述...
|`INTERFACE`|[Client](#struct_Client)|帧同步客户端接口定义
|`STRUCT`|[StoppedEventHandle](#struct_StoppedEventHandle)|暂无描述...
|`STRUCT`|[Lockstep](#struct_Lockstep)|锁步(帧)同步默认实现
|`STRUCT`|[Option](#struct_Option)|暂无描述...
</details>
@@ -108,6 +108,7 @@ func TestNewLockstep(t *testing.T) {
> - 默认情况下为 0即第一帧索引为 0
***
<span id="struct_Client"></span>
### Client `INTERFACE`
帧同步客户端接口定义
- 客户端应该具备ID及写入数据包的实现
@@ -117,11 +118,13 @@ type Client[ID comparable] interface {
Write(packet []byte, callback ...func(err error))
}
```
<span id="struct_StoppedEventHandle"></span>
### StoppedEventHandle `STRUCT`
```go
type StoppedEventHandle[ClientID comparable, Command any] func(lockstep *Lockstep[ClientID, Command])
```
<span id="struct_Lockstep"></span>
### Lockstep `STRUCT`
锁步(帧)同步默认实现
- 支持最大帧上限 WithFrameLimit
@@ -149,6 +152,7 @@ type Lockstep[ClientID comparable, Command any] struct {
lockstepStoppedEventHandles []StoppedEventHandle[ClientID, Command]
}
```
<span id="struct_Option"></span>
### Option `STRUCT`
```go

View File

@@ -24,9 +24,9 @@
|类型|名称|描述
|:--|:--|:--
|`STRUCT`|[MultistageBind](#multistagebind)|多级分类路由绑定函数
|`STRUCT`|[Multistage](#multistage)|支持多级分类的路由器
|`STRUCT`|[MultistageOption](#multistageoption)|路由器选项
|`STRUCT`|[MultistageBind](#struct_MultistageBind)|多级分类路由绑定函数
|`STRUCT`|[Multistage](#struct_Multistage)|支持多级分类的路由器
|`STRUCT`|[MultistageOption](#struct_MultistageOption)|路由器选项
</details>
@@ -53,6 +53,7 @@ func ExampleNewMultistage() {
> - 将在路由注册前对路由进行对应处理
***
<span id="struct_MultistageBind"></span>
### MultistageBind `STRUCT`
多级分类路由绑定函数
```go
@@ -61,6 +62,7 @@ type MultistageBind[HandleFunc any] func(HandleFunc)
#### func (MultistageBind) Bind(handleFunc HandleFunc)
> 将处理函数绑定到预设的路由中
***
<span id="struct_Multistage"></span>
### Multistage `STRUCT`
支持多级分类的路由器
```go
@@ -164,6 +166,7 @@ func ExampleMultistage_Sub() {
```
***
<span id="struct_MultistageOption"></span>
### MultistageOption `STRUCT`
路由器选项
```go

View File

@@ -24,9 +24,9 @@
|类型|名称|描述
|:--|:--|:--
|`STRUCT`|[Channel](#channel)|基于 chan 的写循环,与 Unbounded 相同,但是使用 Channel 实现
|`STRUCT`|[Unbounded](#unbounded)|写循环
|`INTERFACE`|[WriteLoop](#writeloop)|暂无描述...
|`STRUCT`|[Channel](#struct_Channel)|基于 chan 的写循环,与 Unbounded 相同,但是使用 Channel 实现
|`STRUCT`|[Unbounded](#struct_Unbounded)|写循环
|`INTERFACE`|[WriteLoop](#struct_WriteLoop)|暂无描述...
</details>
@@ -106,6 +106,7 @@ func TestNewUnbounded(t *testing.T) {
***
<span id="struct_Channel"></span>
### Channel `STRUCT`
基于 chan 的写循环,与 Unbounded 相同,但是使用 Channel 实现
```go
@@ -119,6 +120,7 @@ type Channel[T any] struct {
#### func (*Channel) Close()
> 关闭写循环
***
<span id="struct_Unbounded"></span>
### Unbounded `STRUCT`
写循环
- 用于将数据并发安全的写入到底层连接
@@ -217,6 +219,7 @@ func TestUnbounded_Close(t *testing.T) {
***
<span id="struct_WriteLoop"></span>
### WriteLoop `INTERFACE`
```go