You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
953 B
37 lines
953 B
4 years ago
|
package metadata
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
4 years ago
|
"github.com/go-kratos/kratos/v2/api/proto/kratos/api"
|
||
4 years ago
|
"google.golang.org/grpc"
|
||
|
anypb "google.golang.org/protobuf/types/known/anypb"
|
||
|
)
|
||
|
|
||
|
// Server is api meta server
|
||
|
type Server struct {
|
||
|
api.UnimplementedMetadataServer
|
||
|
s *Service
|
||
|
}
|
||
|
|
||
|
// NewServer create server instance
|
||
|
func NewServer(grpcSrv ...*grpc.Server) *Server {
|
||
|
return &Server{s: NewService(grpcSrv...)}
|
||
|
}
|
||
|
|
||
|
// ListServices return all services
|
||
|
func (s *Server) ListServices(ctx context.Context, in *anypb.Any) (*api.ListServicesReply, error) {
|
||
|
var reply api.ListServicesReply
|
||
|
var err error
|
||
|
reply.Services, err = s.s.ListServices(ctx)
|
||
|
return &reply, err
|
||
|
}
|
||
|
|
||
|
// GetServiceMeta return service meta by name
|
||
|
func (s *Server) GetServiceMeta(ctx context.Context, in *api.GetServiceMetaRequest) (*api.GetServiceMetaReply, error) {
|
||
|
var reply api.GetServiceMetaReply
|
||
|
var err error
|
||
|
reply.ProtoSet, err = s.s.GetServiceMeta(ctx, in.Name)
|
||
|
return &reply, err
|
||
|
}
|