CleanupPublisher will cleanup the publishing side of JetStreamContext. This will unsubscribe from the internal reply subject if needed. All pending async publishes will fail with ErrJetStreamContextClosed. If an error handler was provided, it will be called for each pending async publish and Publi
()
| 777 | // will be recreated on next publish, but the acks from previous publishes will |
| 778 | // be lost. |
| 779 | func (js *js) CleanupPublisher() { |
| 780 | js.cleanupReplySub() |
| 781 | js.mu.Lock() |
| 782 | errCb := js.opts.aecb |
| 783 | for id, paf := range js.pafs { |
| 784 | paf.err = ErrJetStreamPublisherClosed |
| 785 | if paf.errCh != nil { |
| 786 | paf.errCh <- paf.err |
| 787 | } |
| 788 | if errCb != nil { |
| 789 | defer errCb(js, paf.msg, ErrJetStreamPublisherClosed) |
| 790 | } |
| 791 | delete(js.pafs, id) |
| 792 | } |
| 793 | if js.dch != nil { |
| 794 | close(js.dch) |
| 795 | js.dch = nil |
| 796 | } |
| 797 | js.mu.Unlock() |
| 798 | } |
| 799 | |
| 800 | func (js *js) cleanupReplySub() { |
| 801 | js.mu.Lock() |
nothing calls this directly
no test coverage detected