Skip to content

Commit ec26c25

Browse files
[CHASM] Wire ChasmRegistry into shard.Context (temporalio#7419)
## What changed? - Wires up CHASM registry to shard context ## Why? - It's needed throughout history service ## How did you test it? ## Potential risks <!-- Assuming the worst case, what can be broken when deploying this change to production? --> ## Documentation <!-- Have you made sure this change doesn't falsify anything currently stated in `docs/`? If significant new behavior is added, have you described that in `docs/`? --> ## Is hotfix candidate? <!-- Is this PR a hotfix candidate or does it require a notification to be sent to the broader community? (Yes/No) -->
1 parent bca758f commit ec26c25

File tree

6 files changed

+52
-0
lines changed

6 files changed

+52
-0
lines changed

service/history/fx.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ package history
2626

2727
import (
2828
"go.temporal.io/server/api/historyservice/v1"
29+
"go.temporal.io/server/chasm"
2930
"go.temporal.io/server/common"
3031
"go.temporal.io/server/common/clock"
3132
"go.temporal.io/server/common/config"
@@ -70,6 +71,7 @@ import (
7071
var Module = fx.Options(
7172
resource.Module,
7273
fx.Provide(hsm.NewRegistry),
74+
fx.Provide(chasm.NewRegistry),
7375
workflow.Module,
7476
shard.Module,
7577
events.Module,

service/history/shard/context.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import (
3333
clockspb "go.temporal.io/server/api/clock/v1"
3434
"go.temporal.io/server/api/historyservice/v1"
3535
persistencespb "go.temporal.io/server/api/persistence/v1"
36+
"go.temporal.io/server/chasm"
3637
"go.temporal.io/server/common/archiver"
3738
"go.temporal.io/server/common/clock"
3839
"go.temporal.io/server/common/cluster"
@@ -123,6 +124,8 @@ type (
123124

124125
StateMachineRegistry() *hsm.Registry
125126
GetFinalizer() *finalizer.Finalizer
127+
128+
ChasmRegistry() *chasm.Registry
126129
}
127130

128131
// A ControllableContext is a Context plus other methods needed by

service/history/shard/context_factory.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
package shard
2626

2727
import (
28+
"go.temporal.io/server/chasm"
2829
"go.temporal.io/server/client"
2930
"go.temporal.io/server/common/archiver"
3031
"go.temporal.io/server/common/clock"
@@ -80,6 +81,7 @@ type (
8081
EventsCache events.Cache
8182

8283
StateMachineRegistry *hsm.Registry
84+
ChasmRegistry *chasm.Registry
8385
}
8486

8587
contextFactoryImpl struct {
@@ -121,6 +123,7 @@ func (c *contextFactoryImpl) CreateContext(
121123
c.TaskCategoryRegistry,
122124
c.EventsCache,
123125
c.StateMachineRegistry,
126+
c.ChasmRegistry,
124127
)
125128
if err != nil {
126129
return nil, err

service/history/shard/context_impl.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import (
4343
enumsspb "go.temporal.io/server/api/enums/v1"
4444
"go.temporal.io/server/api/historyservice/v1"
4545
persistencespb "go.temporal.io/server/api/persistence/v1"
46+
"go.temporal.io/server/chasm"
4647
"go.temporal.io/server/client"
4748
"go.temporal.io/server/common"
4849
"go.temporal.io/server/common/archiver"
@@ -169,6 +170,8 @@ type (
169170
acquireShardRetryPolicy backoff.RetryPolicy
170171

171172
stateMachineRegistry *hsm.Registry
173+
174+
chasmRegistry *chasm.Registry
172175
}
173176

174177
remoteClusterInfo struct {
@@ -2088,6 +2091,7 @@ func newContext(
20882091
taskCategoryRegistry tasks.TaskCategoryRegistry,
20892092
eventsCache events.Cache,
20902093
stateMachineRegistry *hsm.Registry,
2094+
chasmRegistry *chasm.Registry,
20912095
) (*ContextImpl, error) {
20922096
hostIdentity := hostInfoProvider.HostInfo().Identity()
20932097
sequenceID := atomic.AddInt64(&shardContextSequenceID, 1)
@@ -2136,6 +2140,7 @@ func newContext(
21362140
queueMetricEmitter: sync.Once{},
21372141
ioSemaphore: locks.NewPrioritySemaphore(ioConcurrency),
21382142
stateMachineRegistry: stateMachineRegistry,
2143+
chasmRegistry: chasmRegistry,
21392144
}
21402145
shardContext.taskKeyManager = newTaskKeyManager(
21412146
shardContext.taskCategoryRegistry,
@@ -2238,6 +2243,10 @@ func (s *ContextImpl) StateMachineRegistry() *hsm.Registry {
22382243
return s.stateMachineRegistry
22392244
}
22402245

2246+
func (s *ContextImpl) ChasmRegistry() *chasm.Registry {
2247+
return s.chasmRegistry
2248+
}
2249+
22412250
// newDetachedContext creates a detached context with the same deadline
22422251
// and values from the given context. Detached context won't be affected
22432252
// if the context it bases on is cancelled.

service/history/shard/context_mock.go

Lines changed: 29 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

service/history/shard/context_testutil.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import (
3131

3232
"go.temporal.io/server/api/historyservice/v1"
3333
persistencespb "go.temporal.io/server/api/persistence/v1"
34+
"go.temporal.io/server/chasm"
3435
"go.temporal.io/server/common/clock"
3536
"go.temporal.io/server/common/cluster"
3637
"go.temporal.io/server/common/future"
@@ -171,6 +172,7 @@ func newTestContext(t *resourcetest.Test, eventsCache events.Cache, config Conte
171172
timeSource: t.TimeSource,
172173
namespaceRegistry: registry,
173174
stateMachineRegistry: hsm.NewRegistry(),
175+
chasmRegistry: chasm.NewRegistry(),
174176
persistenceShardManager: t.GetShardManager(),
175177
clientBean: t.GetClientBean(),
176178
saProvider: t.GetSearchAttributesProvider(),
@@ -227,6 +229,10 @@ func (s *ContextTest) SetStateMachineRegistry(reg *hsm.Registry) {
227229
s.stateMachineRegistry = reg
228230
}
229231

232+
func (s *ContextTest) SetChasmRegistry(reg *chasm.Registry) {
233+
s.chasmRegistry = reg
234+
}
235+
230236
// StopForTest calls FinishStop(). In general only the controller
231237
// should call that, but integration tests need to do it also to clean up any
232238
// background acquireShard goroutines that may exist.

0 commit comments

Comments
 (0)