Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:save old service info #2556

Merged
merged 3 commits into from
Jan 5, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions protocol/triple/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import (
"github.com/dubbogo/gost/log/logger"

grpc_go "github.com/dubbogo/grpc-go"

"github.com/dustin/go-humanize"

"google.golang.org/grpc"
Expand Down Expand Up @@ -162,6 +164,7 @@
service := config.GetProviderService(key)
serviceKey := common.ServiceKey(providerService.Interface, providerService.Group, providerService.Version)
exporter, _ := tripleProtocol.ExporterMap().Load(serviceKey)
s.compatSaveServiceInfo(ds.XXX_ServiceDesc())

Check failure on line 167 in protocol/triple/server.go

View workflow job for this annotation

GitHub Actions / ubuntu-latest - Go 1.17

undefined: ds

Check failure on line 167 in protocol/triple/server.go

View workflow job for this annotation

GitHub Actions / lint (1.17)

undeclared name: `ds` (typecheck)
if exporter == nil {
logger.Warnf("no exporter found for serviceKey: %v", serviceKey)
continue
Expand Down Expand Up @@ -318,6 +321,31 @@
s.services[interfaceName] = ret
}

func (s *Server) compatSaveServiceInfo(desc *grpc_go.ServiceDesc) {
ret := grpc.ServiceInfo{}
ret.Methods = make([]grpc.MethodInfo, 0, len(desc.Streams)+len(desc.Methods))
for _, method := range desc.Methods {
md := grpc.MethodInfo{
Name: method.MethodName,
IsClientStream: false,
IsServerStream: false,
}
ret.Methods = append(ret.Methods, md)
}
for _, stream := range desc.Streams {
md := grpc.MethodInfo{
Name: stream.StreamName,
IsClientStream: stream.ClientStreams,
IsServerStream: stream.ServerStreams,
}
ret.Methods = append(ret.Methods, md)
}
ret.Metadata = desc.Metadata
s.mu.Lock()
defer s.mu.Unlock()
s.services[desc.ServiceName] = ret
}

func (s *Server) GetServiceInfo() map[string]grpc.ServiceInfo {
s.mu.RLock()
defer s.mu.RUnlock()
Expand Down
Loading