()
| 128 | } |
| 129 | |
| 130 | func (w *subscribeWorker) start() { |
| 131 | w.l.Lock() |
| 132 | defer w.l.Unlock() |
| 133 | |
| 134 | // update subscription status to database |
| 135 | _ = w.s.saveSubscriptionStatus(w.dbID, w.getHead()) |
| 136 | |
| 137 | if w.isStopped() { |
| 138 | w.stopCh = make(chan struct{}) |
| 139 | w.wg = new(sync.WaitGroup) |
| 140 | w.wg.Add(1) |
| 141 | go w.run() |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | func (w *subscribeWorker) getHead() int32 { |
| 146 | return atomic.LoadInt32(&w.head) |