Close terminates the broker blocking until it stops internal goroutines and releases all resources.
()
| 146 | // Close terminates the broker blocking until it stops internal goroutines and |
| 147 | // releases all resources. |
| 148 | func (b *MockBroker) Close() { |
| 149 | close(b.expectations) |
| 150 | if len(b.expectations) > 0 { |
| 151 | buf := bytes.NewBufferString(fmt.Sprintf("mockbroker/%d: not all expectations were satisfied! Still waiting on:\n", b.BrokerID())) |
| 152 | for e := range b.expectations { |
| 153 | _, _ = buf.WriteString(spew.Sdump(e)) |
| 154 | } |
| 155 | b.t.Error(buf.String()) |
| 156 | } |
| 157 | close(b.closing) |
| 158 | <-b.stopper |
| 159 | } |
| 160 | |
| 161 | // setHandler sets the specified function as the request handler. Whenever |
| 162 | // a mock broker reads a request from the wire it passes the request to the |