Nats.go 408 B

1234567891011121314151617181920212223
  1. package Nats
  2. import (
  3. "Cold_DeductionNotice/conf"
  4. "Cold_DeductionNotice/lib"
  5. "Cold_DeductionNotice/logs"
  6. "github.com/nats-io/nats.go"
  7. "time"
  8. )
  9. func NatsInit() {
  10. time.Sleep(time.Second * 3)
  11. var err error
  12. // 连接Nats服务器
  13. lib.Nats, err = nats.Connect("nats://" + conf.NatsServer_Url)
  14. if err != nil {
  15. logs.Println("nats 连接失败!")
  16. panic(any(err))
  17. }
  18. logs.Println("nats OK!")
  19. }