Skip to content

Commit

Permalink
Allow custom registry to get the actual address for registering (#1061)
Browse files Browse the repository at this point in the history
  • Loading branch information
XiaoYi-byte authored May 30, 2024
1 parent 87c326e commit 150b3d4
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
15 changes: 15 additions & 0 deletions content/en/docs/kitex/Tutorials/framework-exten/registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ type Info struct {

// extend other infos with Tags.
Tags map[string]string

// SkipListenAddr is used to prevent the listen addr from overriding the Addr(available from Kitex v0.10.0)
SkipListenAddr bool
}
```

Expand Down Expand Up @@ -75,3 +78,15 @@ Specify your own registration module and customized registration information thr
```go
svr := xxxservice.NewServer(handler, server.WithRegistry(yourRegistry), server.WithRegistryInfo(yourRegistryInfo))
```

- Allow custom registry to get the actual address for registering(available from Kitex v0.10.0)

When the Client cannot access the Listen Address of the Server and needs to use a public IP address to access the Server, it can be set by specifying `Addr` and `SkipListenAddr` in RegistryInfo.
```go
info := &registry.Info{
Addr: YourServerAddress,
SkipListenAddr: true,
...
}
svr := xxxservice.NewServer(handler, server.WithRegistry(yourRegistry), server.WithRegistryInfo(info))
```
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ description: "泛化调用接入 dynamicgo 指南;高性能泛化调用实现"
- `NewThriftFileProviderWithDynamicGo(path string, includeDirs ...string)`:创建 thriftFileProvider,它从给定的路径实现 DescriptorProvider 并包含目录
- `NewThriftContentProviderWithDynamicGo(main string, includes map[string]string)`:创建 ThriftContentProvider 它实现了 DescriptorProvider 与动态从内容
- 您可以 IDL 与旧方法相同的方法 `UpdateIDL`
- `NewThriftContentWithAbsIncludePathProviderWithDynamicGo(mainIDLPath字符串,包括map[string]string)`:创建 ThriftContentWithAbsIncludePathProvider 实现 DescriptorProvider(absinclude path)和从 content
- `NewThriftContentWithAbsIncludePathProviderWithDynamicGo(mainIDLPath string,includes map[string]string)`:创建 ThriftContentWithAbsIncludePathProvider 实现 DescriptorProvider(absinclude path)和从 content
- 您可以与旧方法相同的方法更新 IDL

- Provider option
Expand Down
14 changes: 14 additions & 0 deletions content/zh/docs/kitex/Tutorials/framework-exten/registry.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ type Info struct {

// extend other infos with Tags.
Tags map[string]string

// SkipListenAddr is used to prevent the listen addr from overriding the Addr(available from Kitex v0.10.0)
SkipListenAddr bool
}
```

Expand Down Expand Up @@ -75,3 +78,14 @@ type Info struct {
```go
svr := xxxservice.NewServer(handler, server.WithRegistry(yourRegistry), server.WithRegistryInfo(yourRegistryInfo))
```
- 自定义的 Registry 获取 Client 可访问的实际地址(Kitex v0.10.0 版本开始可用)

当 Client 端无法访问 Server 端的 Listen Address,而需要使用公共的 IP 地址访问 Server 端时,可以通过指定 RegistryInfo 中的 `Addr``SkipListenAddr` 进行设置
```go
info := &registry.Info{
Addr: YourServerAddress,
SkipListenAddr: true,
...
}
svr := xxxservice.NewServer(handler, server.WithRegistry(yourRegistry), server.WithRegistryInfo(info))
```

0 comments on commit 150b3d4

Please sign in to comment.