servicecontext.go 470 B

1234567891011121314151617181920212223
  1. package svc
  2. import (
  3. "bookstore/api/internal/config"
  4. "bookstore/rpc/add/adder"
  5. "bookstore/rpc/check/checker"
  6. "github.com/tal-tech/go-zero/zrpc"
  7. )
  8. type ServiceContext struct {
  9. Config config.Config
  10. Adder adder.Adder
  11. Checker checker.Checker
  12. }
  13. func NewServiceContext(c config.Config) *ServiceContext {
  14. return &ServiceContext{
  15. Config: c,
  16. Adder: adder.NewAdder(zrpc.MustNewClient(c.Add)),
  17. Checker: checker.NewChecker(zrpc.MustNewClient(c.Check)),
  18. }
  19. }