WIP: kratos

This commit is contained in:
Chuan Ding
2025-06-04 16:12:45 +08:00
parent ad950f6c28
commit f8203df26a
55 changed files with 7356 additions and 3 deletions

View File

@@ -0,0 +1 @@
# Service

View File

@@ -0,0 +1,29 @@
package service
import (
"context"
v1 "polaris/api/helloworld/v1"
"polaris/internal/biz"
)
// GreeterService is a greeter service.
type GreeterService struct {
v1.UnimplementedGreeterServer
uc *biz.GreeterUsecase
}
// NewGreeterService new a greeter service.
func NewGreeterService(uc *biz.GreeterUsecase) *GreeterService {
return &GreeterService{uc: uc}
}
// SayHello implements helloworld.GreeterServer.
func (s *GreeterService) SayHello(ctx context.Context, in *v1.HelloRequest) (*v1.HelloReply, error) {
g, err := s.uc.CreateGreeter(ctx, &biz.Greeter{Hello: in.Name})
if err != nil {
return nil, err
}
return &v1.HelloReply{Message: "Hello " + g.Hello}, nil
}

View File

@@ -0,0 +1,6 @@
package service
import "github.com/google/wire"
// ProviderSet is service providers.
var ProviderSet = wire.NewSet(NewGreeterService)