1 Star 0 Fork 0

evan / newtbig

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
proxy.go 1.86 KB
一键复制 编辑 原始数据 按行查看 历史
evan 提交于 2024-05-09 01:57 . v0.2.0
// Copyright 2020 newtbig Author. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package dispatcher
import (
"fmt"
"path/filepath"
"gitee.com/lakertt/newtbig/common"
"gitee.com/lakertt/newtbig/module"
"gitee.com/lakertt/newtbig/msg/framepb"
)
type proxy struct {
msgKey string
bcKey string
key string
serType string
serName string
appName string
ver string
app module.App
serStatus []byte
}
func (p *proxy) init(serType string, key string, app module.App, status []byte) {
p.app = app
p.key = key
p.appName = app.Options().AppName
p.ver = app.Options().Version
p.serType = filepath.Base(serType)
p.serName = filepath.Base(p.key)
p.msgKey = fmt.Sprintf("%s.%s.%s", p.appName, p.serType, p.serName)
p.bcKey = fmt.Sprintf("%s.%s.%s.%s", p.appName, p.serType, p.serName, common.BROATCAST)
p.serStatus = status
}
func (p *proxy) OnClose() error {
return nil
}
func (p *proxy) GetKey() string {
return p.key
}
func (p *proxy) GetMsgKey() string {
return p.msgKey
}
func (p *proxy) GetBCKey() string {
return p.bcKey
}
func (p *proxy) forward(msg *framepb.Msg) error {
err := p.app.GetRPC().CallNR(msg)
return err
}
func (p *proxy) update(status []byte) error {
p.serStatus = status
return nil
}
func (p *proxy) GetStatus() []byte {
return p.serStatus
}
func (p *proxy) GetSerName() string {
return p.serName
}
Go
1
https://gitee.com/lakertt/newtbig.git
git@gitee.com:lakertt/newtbig.git
lakertt
newtbig
newtbig
v0.2.0

搜索帮助