reid from https://github.com/michuanhaohao/reid-strong-baseline
zhangmeng
2020-02-24 d9b98e947f7b5aae886ff02ec27bd92aa34feaaa
rpc/send.go
@@ -12,7 +12,6 @@
   ipcURL string
   in     <-chan []byte
   shm    bool
   fn     func([]byte, bool)
   fnLogger func(...interface{})
}
@@ -23,7 +22,6 @@
      ipcURL:   ipcURL,
      in:       in,
      shm:      shm,
      fn:       nil,
      fnLogger: fn,
   }
}
@@ -34,7 +32,7 @@
   if s.shm {
      s.runShm(ctx)
   } else {
      i := deliver.NewClient(mode, s.ipcURL)
      i := deliver.NewServer(deliver.PushPull, s.ipcURL)
      if i == nil {
         s.fnLogger("sender 2 pubsub nng create error")
         return
@@ -55,18 +53,27 @@
         if s.shm {
            if err := i.Send(d); err != nil {
               i.Close()
               s.fnLogger("ANALYSIS SENDER ERROR: ", err)
               s.fnLogger("SENDER To:", s.ipcURL, " ERROR: ", err)
               c, err := deliver.NewServerWithError(deliver.Shm, s.ipcURL)
            loopS:
               for {
                  if err == nil {
                     break
                  select {
                  case <-ctx.Done():
                     return
                  default:
                     if err == nil {
                        break loopS
                     }
                     time.Sleep(time.Second)
                     c, err = deliver.NewServerWithError(deliver.Shm, s.ipcURL)
                     s.fnLogger("Sender CLIENT CREATE:", s.ipcURL, " FAILED : ", err)
                  }
                  time.Sleep(time.Second)
                  c, err = deliver.NewServerWithError(deliver.Shm, s.ipcURL)
                  s.fnLogger("CLIENT CREATE FAILED : ", err)
               }
               i = c
               s.fnLogger("Sender Create Shm:", s.ipcURL)
            } else {
            }
@@ -86,13 +93,20 @@
func (s *Sender) runShm(ctx context.Context) {
   c, err := deliver.NewServerWithError(deliver.Shm, s.ipcURL)
loopSBegin:
   for {
      if err == nil {
         break
      select {
      case <-ctx.Done():
         return
      default:
         if err == nil {
            break loopSBegin
         }
         time.Sleep(1 * time.Second)
         c, err = deliver.NewServerWithError(deliver.Shm, s.ipcURL)
         s.fnLogger("Sender CLIENT CREATE:", s.ipcURL, "FAILED : ", err)
      }
      time.Sleep(1 * time.Second)
      c, err = deliver.NewServerWithError(deliver.Shm, s.ipcURL)
      s.fnLogger("CLIENT CREATE FAILED : ", err)
   }
   s.run(ctx, c)
}