Skip to content

Commit e0d9452

Browse files
committed
Add shared registry with nil libraries for tdbg
1 parent 9624cba commit e0d9452

7 files changed

Lines changed: 43 additions & 32 deletions

File tree

chasm/lib/activity/library.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func (l *componentOnlyLibrary) Components() []*chasm.RegistrableComponent {
7575
}
7676

7777
// NewNilLibrary creates a Library with all nil handlers. Useful for
78-
// registration-only contexts like tdbg where no task execution is needed.
78+
// decoding contexts like tdbg where no task execution is needed.
7979
func NewNilLibrary() chasm.Library {
8080
return &library{
8181
componentOnlyLibrary: *newComponentOnlyLibrary(nil, nil),

chasm/lib/all/all.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Package all provides the canonical list of all CHASM libraries for decoding contexts.
2+
// When adding a new library to CHASM, register its nil variant here.
3+
package all
4+
5+
import (
6+
"go.temporal.io/server/chasm"
7+
activitylib "go.temporal.io/server/chasm/lib/activity"
8+
callbacklib "go.temporal.io/server/chasm/lib/callback"
9+
chasmnexus "go.temporal.io/server/chasm/lib/nexusoperation"
10+
chasmscheduler "go.temporal.io/server/chasm/lib/scheduler"
11+
chasmworkflow "go.temporal.io/server/chasm/lib/workflow"
12+
)
13+
14+
// RegisterAll registers all CHASM libraries in their decoding (nil handler) mode into registry.
15+
// This is the canonical list of all CHASM libraries; update this when adding a new library.
16+
func RegisterAll(registry *chasm.Registry) error {
17+
libs := []chasm.Library{
18+
&chasm.CoreLibrary{},
19+
chasmworkflow.NewLibrary(chasmworkflow.NewRegistry()),
20+
activitylib.NewNilLibrary(),
21+
chasmscheduler.NewNilLibrary(),
22+
callbacklib.NewNilLibrary(),
23+
chasmnexus.NewNilLibrary(),
24+
}
25+
for _, lib := range libs {
26+
if err := registry.Register(lib); err != nil {
27+
return err
28+
}
29+
}
30+
return nil
31+
}

chasm/lib/callback/library.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type (
1515
)
1616

1717
// NewNilLibrary creates a Library with all nil handlers. Useful for
18-
// registration-only contexts like tdbg where no task execution is needed.
18+
// decoding contexts like tdbg where no task execution is needed.
1919
func NewNilLibrary() *Library {
2020
return &Library{}
2121
}

chasm/lib/nexusoperation/library.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ func newComponentOnlyLibrary(dc *dynamicconfig.Collection) *componentOnlyLibrary
4141
}
4242
}
4343

44+
// NewNilLibrary creates a Library with nil handlers and nil config.
45+
// Useful for decoding contexts like tdbg where no task execution is needed.
46+
func NewNilLibrary() *Library {
47+
return &Library{}
48+
}
49+
4450
func (l *componentOnlyLibrary) Name() string {
4551
return libraryName
4652
}

chasm/lib/scheduler/eventlog_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func TestEventLog_DropsEarliestWhenFull(t *testing.T) {
6969

7070
// TestEventLog_NoConfigFallsBackToDefaults checks that LogEvent applies the
7171
// default retention limits instead of panicking when no config is reachable via
72-
// the context, as in tdbg's registration-only setup.
72+
// the context, as in tdbg's decoding setup.
7373
func TestEventLog_NoConfigFallsBackToDefaults(t *testing.T) {
7474
ctx := &chasm.MockMutableContext{}
7575
eventLog := scheduler.NewEventLog(ctx)

chasm/lib/scheduler/library.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ type (
2424
)
2525

2626
// NewNilLibrary creates a Library with all nil handlers. Useful for
27-
// registration-only contexts like tdbg where no task execution is needed.
27+
// decoding contexts like tdbg where no task execution is needed.
2828
func NewNilLibrary() *Library {
2929
return &Library{}
3030
}

tools/tdbg/chasm_registry.go

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,14 @@ package tdbg
22

33
import (
44
"go.temporal.io/server/chasm"
5-
activitylib "go.temporal.io/server/chasm/lib/activity"
6-
callbacklib "go.temporal.io/server/chasm/lib/callback"
7-
chasmscheduler "go.temporal.io/server/chasm/lib/scheduler"
8-
chasmtests "go.temporal.io/server/chasm/lib/tests"
9-
chasmworkflow "go.temporal.io/server/chasm/lib/workflow"
5+
"go.temporal.io/server/chasm/lib/all"
106
"go.temporal.io/server/common/log"
117
)
128

139
func newChasmRegistry(logger log.Logger) (*chasm.Registry, error) {
1410
registry := chasm.NewRegistry(logger)
15-
16-
if err := registry.Register(&chasm.CoreLibrary{}); err != nil {
11+
if err := all.RegisterAll(registry); err != nil {
1712
return nil, err
1813
}
19-
20-
if err := registry.Register(chasmworkflow.NewLibrary(chasmworkflow.NewRegistry())); err != nil {
21-
return nil, err
22-
}
23-
24-
if err := registry.Register(activitylib.NewNilLibrary()); err != nil {
25-
return nil, err
26-
}
27-
28-
if err := registry.Register(chasmscheduler.NewNilLibrary()); err != nil {
29-
return nil, err
30-
}
31-
32-
if err := registry.Register(chasmtests.Library); err != nil {
33-
return nil, err
34-
}
35-
36-
if err := registry.Register(callbacklib.NewNilLibrary()); err != nil {
37-
return nil, err
38-
}
39-
4014
return registry, nil
4115
}

0 commit comments

Comments
 (0)