Documentation ¶
Index ¶
- type TakeOverServer
- func (tos *TakeOverServer) AddBusiServer(name string, routerName string, port int64, ...)
- func (tos *TakeOverServer) BusiSrvMonitor()
- func (tos *TakeOverServer) GetFrontendAssets() (fs.FS, error)
- func (tos *TakeOverServer) GetRouterName(name string) string
- func (tos *TakeOverServer) InitRouter()
- func (tos *TakeOverServer) RunTakeOverServer(port int)
- func (tos *TakeOverServer) Shutdown()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TakeOverServer ¶
type TakeOverServer struct { // zap 日志对象 Log *zap.SugaredLogger // versionrouter RouterVersion *gin.RouterGroup // 添加业务 BusiSrvChan chan *model.ServerInfo // contains filtered or unexported fields }
接管服务
func (*TakeOverServer) AddBusiServer ¶
func (tos *TakeOverServer) AddBusiServer(name string, routerName string, port int64, busiServer model.BusiServerInterface)
添加业务实例
func (*TakeOverServer) BusiSrvMonitor ¶
func (tos *TakeOverServer) BusiSrvMonitor()
监听添加业务服务 分为两部分内容 1.
启用服务,使用runServer,因为使用到 map 避免不安全存在 所以在将服务信息添加到 map 的时候添加了锁
2.
将启用的服务的名称作为路由组,然后默认这个路由组的子路由全部转发到 该服务
示例:
服务: costbusi 则 costbusi/test1 costbusi/test2 POST GET ... 等所有方法的路由 服务: registerbusi 则 registerbusi/test1 registerbusi/test1 POST GET ... 等所有方法的路由
func (*TakeOverServer) GetFrontendAssets ¶
func (tos *TakeOverServer) GetFrontendAssets() (fs.FS, error)
获取静态文件
func (*TakeOverServer) GetRouterName ¶
func (tos *TakeOverServer) GetRouterName(name string) string
获取路由名称 名称中如果包含 / 的话就沿用 没有就需要添加 示例
router ==> router/ router/ ==> router/
func (*TakeOverServer) RunTakeOverServer ¶
func (tos *TakeOverServer) RunTakeOverServer(port int)
运行托管服务
Click to show internal directories.
Click to hide internal directories.