MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / raiseEvent

Method raiseEvent

db/event_manager.go:142–159  ·  view source on GitHub ↗

Adds async events to the channel for processing

(ctx context.Context, event Event)

Source from the content-addressed store, hash-verified

140
141// Adds async events to the channel for processing
142func (em *EventManager) raiseEvent(ctx context.Context, event Event) error {
143 if !event.Synchronous() {
144 // When asyncEventChannel is full, the raiseEvent method will block for (waitTime).
145 // Default value of (waitTime) is 5 ms.
146 timer := time.NewTimer(time.Duration(em.waitTime) * time.Millisecond)
147 defer timer.Stop()
148 select {
149 case em.asyncEventChannel <- event:
150 base.TracefCtx(ctx, base.KeyAll, "Event sent to channel %s", event.String())
151 case <-timer.C:
152 // Event queue channel is full - ignore event and log error
153 base.WarnfCtx(ctx, "Event queue full - discarding event: %s", base.UD(event.String()))
154 return errors.New("Event queue full")
155 }
156 }
157 // TODO: handling for synchronous events
158 return nil
159}
160
161// Raises a document change event based on the the document body and channel set. If the
162// event manager doesn't have a listener for this event, ignores.

Callers 2

Calls 6

TracefCtxFunction · 0.92
WarnfCtxFunction · 0.92
UDFunction · 0.92
SynchronousMethod · 0.65
StopMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected