MCPcopy Create free account
hub / github.com/buggregator/server / subscribe

Method subscribe

modules/smtp/module.go:85–101  ·  view source on GitHub ↗

subscribe registers a waiter for the wait endpoint and returns a channel and an unsubscribe function. The caller must call unsubscribe when done.

(f MessageFilter)

Source from the content-addressed store, hash-verified

83// subscribe registers a waiter for the wait endpoint and returns a channel and
84// an unsubscribe function. The caller must call unsubscribe when done.
85func (m *Module) subscribe(f MessageFilter) (<-chan event.Event, func()) {
86 ch := make(chan event.Event, 1)
87 w := &waiter{filter: f, ch: ch}
88 m.mu.Lock()
89 m.waiters = append(m.waiters, w)
90 m.mu.Unlock()
91 return ch, func() {
92 m.mu.Lock()
93 defer m.mu.Unlock()
94 for i, ww := range m.waiters {
95 if ww == w {
96 m.waiters = append(m.waiters[:i], m.waiters[i+1:]...)
97 return
98 }
99 }
100 }
101}
102
103func (m *Module) PreviewMapper() event.PreviewMapper {
104 return &previewMapper{}

Callers 1

handleMessagesWaitFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected