context_impl.go ×11

Frontier kind: Code frontier

unlabeled · c_6e3123d62bf9

29 tests · 3538 LOC · 146 files · introduces 0 tests · 45 LOC · 2 files

Introduces — evidence that enters the hierarchy at this concept

Code
12 ranges45 lines · 2 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
518 ranges3538 lines · 146 files · Browse complete extent
All tests (intent)
29 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

2 files ranked by introduced lines: 45 introduced LOC across 12 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

go.temporal.io/server/service/history/shard/context_impl.go 43 introduced LOC · 11 ranges

Open complete file

1204 }
1205
1206 > func (s *ContextImpl) monitorQueueMetrics() { context_impl.go
1207 > timer := time.NewTimer(queueMetricUpdateInterval)
1208 > defer timer.Stop()
1209 >
1210 > done := s.lifecycleCtx.Done()
1211 > for {
1212 > select {
1213 case <-done:
1214 return
1652 case contextRequestAcquire:
1653 return nil // nothing to do, already acquiring
1654 > case contextRequestAcquired: context_impl.go
1655 > s.state = contextStateAcquired
1656 > if request.engine != nil {
1657 // engineFuture.Set should only be called inside stateLock when state is
1658 // Acquiring, so that other code (i.e. FinishStop) can know that after a state
1665 s.engineFuture.Set(request.engine, nil)
1666 }
1667 > if !s.engineFuture.Ready() { context_impl.go
1668 // we should either have an engine from a previous transition, or set one now
1669 s.contextTaggedLogger.Warn("transition to acquired but no engine set")
1671 }
1672
1673 > return nil context_impl.go
1674 case contextRequestLost:
1675 return nil // nothing to do, already acquiring
1720 // notifyQueueProcessor sends notification to all queue processors for triggering a load
1721 // NOTE: this method assumes engineFuture is already in a ready state.
1722 > func (s *ContextImpl) notifyQueueProcessor() { context_impl.go
1723 > // use a cancelled ctx so the method won't be blocked if engineFuture is not ready
1724 > cancelledCtx, cancel := context.WithCancel(context.Background())
1725 > cancel()
1726 >
1727 > // we will get the engine when the Future is ready
1728 > engine, err := s.engineFuture.Get(cancelledCtx)
1729 > if err != nil {
1730 s.contextTaggedLogger.Warn("tried to notify queue processor when engine is not ready")
1731 return
1732 }
1733
1734 > now := s.timeSource.Now() context_impl.go
1735 > fakeTasks := make(map[tasks.Category][]tasks.Task)
1736 > for _, category := range s.taskCategoryRegistry.GetCategories() {
1737 > fakeTasks[category] = []tasks.Task{tasks.NewFakeTask(definition.WorkflowKey{}, category, now)}
1738 > }
1739
1740 > engine.NotifyNewTasks(fakeTasks) context_impl.go
1741 }
1742
1743 > func (s *ContextImpl) updateHandoverNamespacePendingTaskID() { context_impl.go
1744 > s.wLock()
1745 >
1746 > if s.errorByState() != nil {
1747 // if not in acquired state, this function will be called again
1748 // later when shard is re-acquired.
1751 }
1752
1753 > maxReplicationTaskID := s.getMaxReplicationTaskID() context_impl.go
1754 > s.handoverTracker.ResolvePendingTaskIDs(maxReplicationTaskID)
1755 > s.wUnlock()
1756 >
1757 > s.notifyReplicationQueueProcessor(maxReplicationTaskID)
1758 }
1759
1999 // we know engineFuture must be ready here, and we can notify queue processor
2000 // to trigger a load as queue max level can be updated to a newer value
2001 > s.notifyQueueProcessor() context_impl.go
2002 > // This runs until the lifecycleCtx is cancelled, so we only need to start it once
2003 > s.queueMetricEmitter.Do(func() {
2004 > go s.monitorQueueMetrics()
2005 > })
2006
2007 > s.updateHandoverNamespacePendingTaskID() context_impl.go
2008 >
2009 > return nil
2010 }
2011
go.temporal.io/server/service/history/shard/handover_tracker.go 2 introduced LOC · 1 range

Open complete file

128 }
129
130 > func (t *defaultHandoverTracker) ResolvePendingTaskIDs(maxReplicationTaskID int64) { handover_tracker.go
131 > for _, handoverInfo := range t.handoverNamespaces {
132 if handoverInfo.MaxReplicationTaskID == PendingMaxReplicationTaskID {
133 handoverInfo.MaxReplicationTaskID = maxReplicationTaskID