Method
Publish
(event string, message []byte)
Source from the content-addressed store, hash-verified
| 64 | } |
| 65 | |
| 66 | func (m *MemoryPubsub) Publish(event string, message []byte) error { |
| 67 | m.mut.RLock() |
| 68 | defer m.mut.RUnlock() |
| 69 | listeners, ok := m.listeners[event] |
| 70 | if !ok { |
| 71 | return nil |
| 72 | } |
| 73 | var wg sync.WaitGroup |
| 74 | for _, listener := range listeners { |
| 75 | wg.Add(1) |
| 76 | go func() { |
| 77 | defer wg.Done() |
| 78 | listener.send(context.Background(), message) |
| 79 | }() |
| 80 | } |
| 81 | wg.Wait() |
| 82 | |
| 83 | return nil |
| 84 | } |
| 85 | |
| 86 | func (*MemoryPubsub) Close() error { |
| 87 | return nil |
Callers
nothing calls this directly
Tested by
no test coverage detected