File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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.
7979func NewNilLibrary () chasm.Library {
8080 return & library {
8181 componentOnlyLibrary : * newComponentOnlyLibrary (nil , nil ),
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff line change 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.
1919func NewNilLibrary () * Library {
2020 return & Library {}
2121}
Original file line number Diff line number Diff 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+
4450func (l * componentOnlyLibrary ) Name () string {
4551 return libraryName
4652}
Original file line number Diff line number Diff 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.
7373func TestEventLog_NoConfigFallsBackToDefaults (t * testing.T ) {
7474 ctx := & chasm.MockMutableContext {}
7575 eventLog := scheduler .NewEventLog (ctx )
Original file line number Diff line number Diff line change 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.
2828func NewNilLibrary () * Library {
2929 return & Library {}
3030}
Original file line number Diff line number Diff line change @@ -2,40 +2,14 @@ package tdbg
22
33import (
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
139func 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}
You can’t perform that action at this time.
0 commit comments