interface.go 460 B

12345678910111213141516171819202122232425262728
  1. package mqtt
  2. import (
  3. "context"
  4. "kpt-pasture/config"
  5. "kpt-pasture/service/mqtt2"
  6. "kpt-pasture/store/kptstore"
  7. "gitee.com/xuyiping_admin/pkg/di"
  8. "go.uber.org/dig"
  9. )
  10. var Module = di.Options(di.Provide(NewMqtt))
  11. func NewMqtt(entry Entry) Exec {
  12. return &entry
  13. }
  14. type Entry struct {
  15. dig.In
  16. Cfg *config.AppConfig
  17. DB *kptstore.DB
  18. MqttClient mqtt2.MqttServer
  19. }
  20. type Exec interface {
  21. Subscribe(ctx context.Context, msg <-chan []byte)
  22. }