servicecontext.go 410 B

1234567891011121314151617181920
  1. package svc
  2. import (
  3. "shorturl/api/internal/config"
  4. "shorturl/rpc/transform/transformer"
  5. "github.com/tal-tech/go-zero/zrpc"
  6. )
  7. type ServiceContext struct {
  8. Config config.Config
  9. Transformer transformer.Transformer
  10. }
  11. func NewServiceContext(c config.Config) *ServiceContext {
  12. return &ServiceContext{
  13. Config: c,
  14. Transformer: transformer.NewTransformer(zrpc.MustNewClient(c.Transform)),
  15. }
  16. }