MCPcopy Index your code
hub / github.com/rilldata/rill / Subscribe

Method Subscribe

runtime/controller.go:464–489  ·  view source on GitHub ↗

Subscribe registers a callback that will receive resource update events. The same callback function will not be invoked concurrently. The callback function is invoked under a lock and must not call the controller.

(ctx context.Context, fn SubscribeCallback)

Source from the content-addressed store, hash-verified

462// The same callback function will not be invoked concurrently.
463// The callback function is invoked under a lock and must not call the controller.
464func (c *Controller) Subscribe(ctx context.Context, fn SubscribeCallback) error {
465 if err := c.checkRunning(); err != nil {
466 return err
467 }
468
469 c.mu.Lock()
470 id := c.nextSubscriberID
471 c.nextSubscriberID++
472 c.subscribers[id] = fn
473 c.mu.Unlock()
474
475 defer func() {
476 c.mu.Lock()
477 delete(c.subscribers, id)
478 c.mu.Unlock()
479 }()
480
481 for {
482 select {
483 case <-c.closedCh:
484 return ErrControllerClosed
485 case <-ctx.Done():
486 return ctx.Err()
487 }
488 }
489}
490
491// Create creates a resource and enqueues it for reconciliation.
492// If a resource with the same name is currently being deleted, the deletion will be cancelled.

Callers

nothing calls this directly

Calls 5

checkRunningMethod · 0.95
DoneMethod · 0.80
ErrMethod · 0.65
LockMethod · 0.45
UnlockMethod · 0.45

Tested by

no test coverage detected