NewBus runs a new bus and returns bus details
()
| 56 | |
| 57 | // NewBus runs a new bus and returns bus details |
| 58 | func NewBus() Bus { |
| 59 | bus := &bus{ |
| 60 | subscriptions: make(map[*bus]bool), |
| 61 | pubch: make(chan Event), |
| 62 | subch: make(chan chan<- Subscriber), |
| 63 | unsubch: make(chan *bus), |
| 64 | lc: lifecycle.New(), |
| 65 | } |
| 66 | |
| 67 | go bus.run() |
| 68 | |
| 69 | return bus |
| 70 | } |
| 71 | |
| 72 | func (b *bus) Publish(ev Event) error { |
| 73 | select { |