svc.tpl 409 B

12345678910111213141516171819202122
  1. package svc
  2. import (
  3. "github.com/zeromicro/go-zero/zrpc"
  4. "greet/api/internal/config"
  5. "greet/rpc/greet"
  6. )
  7. type ServiceContext struct {
  8. Config config.Config
  9. GreetRpc greet.Greet
  10. }
  11. func NewServiceContext(c config.Config) *ServiceContext {
  12. client := zrpc.MustNewClient(zrpc.RpcClientConf{
  13. Target: "127.0.0.1:8080",
  14. })
  15. return &ServiceContext{
  16. Config: c,
  17. GreetRpc: greet.NewGreet(client),
  18. }
  19. }