servicecontext.go 567 B

12345678910111213141516171819202122
  1. package svc
  2. import (
  3. "github.com/zeromicro/go-zero/zrpc"
  4. "ylink/comm/kafka"
  5. "ylink/core/cmd/rpc/internal/config"
  6. "ylink/core/inner/rpc/inner"
  7. )
  8. type ServiceContext struct {
  9. Config config.Config
  10. InnerRpc inner.Inner
  11. KqMsgBoxProducer *kafka.Producer
  12. }
  13. func NewServiceContext(c config.Config) *ServiceContext {
  14. return &ServiceContext{
  15. Config: c,
  16. InnerRpc: inner.NewInner(zrpc.MustNewClient(c.InnerRpcConf)),
  17. KqMsgBoxProducer: kafka.NewKafkaProducer(c.KqMsgBoxProducerConf.Brokers, c.KqMsgBoxProducerConf.Topic),
  18. }
  19. }