Skip to content

Commit 463cbf5

Browse files
authored
Add library registration for chasm callback (#8577)
## What changed? CHASM library registration for callbacks ## Why? pre-cursor to integration w/ mutable state ## How did you test it? - [ ] built - [ ] run locally and tested manually - [ ] covered by existing tests - [ ] added new unit test(s) - [ ] added new functional test(s) ## Potential risks None, not in running code yet.
1 parent f83d5e1 commit 463cbf5

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

chasm/lib/callback/fx.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package callback
2+
3+
import (
4+
"go.temporal.io/server/chasm"
5+
"go.uber.org/fx"
6+
)
7+
8+
func Register(
9+
registry *chasm.Registry,
10+
library *Library,
11+
) error {
12+
return registry.Register(library)
13+
}
14+
15+
var Module = fx.Module(
16+
"chasm.lib.callback",
17+
fx.Provide(ConfigProvider),
18+
fx.Provide(NewInvocationTaskExecutor),
19+
fx.Provide(NewBackoffTaskExecutor),
20+
fx.Provide(NewLibrary),
21+
fx.Invoke(Register),
22+
)

chasm/lib/callback/library.go

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package callback
2+
3+
import (
4+
"go.temporal.io/server/chasm"
5+
"google.golang.org/grpc"
6+
)
7+
8+
type (
9+
Library struct {
10+
chasm.UnimplementedLibrary
11+
12+
InvocationTaskExecutor *InvocationTaskExecutor
13+
BackoffTaskExecutor *BackoffTaskExecutor
14+
}
15+
)
16+
17+
func NewLibrary(
18+
InvocationTaskExecutor *InvocationTaskExecutor,
19+
BackoffTaskExecutor *BackoffTaskExecutor,
20+
) *Library {
21+
return &Library{
22+
InvocationTaskExecutor: InvocationTaskExecutor,
23+
BackoffTaskExecutor: BackoffTaskExecutor,
24+
}
25+
}
26+
27+
func (l *Library) Name() string {
28+
return "callback"
29+
}
30+
31+
func (l *Library) Components() []*chasm.RegistrableComponent {
32+
return []*chasm.RegistrableComponent{
33+
chasm.NewRegistrableComponent[*Callback]("callback"),
34+
}
35+
}
36+
37+
func (l *Library) Tasks() []*chasm.RegistrableTask {
38+
return []*chasm.RegistrableTask{
39+
chasm.NewRegistrableSideEffectTask(
40+
"invoke",
41+
l.InvocationTaskExecutor,
42+
l.InvocationTaskExecutor,
43+
),
44+
chasm.NewRegistrablePureTask(
45+
"backoff",
46+
l.BackoffTaskExecutor,
47+
l.BackoffTaskExecutor,
48+
),
49+
}
50+
}
51+
52+
func (l *Library) RegisterServices(server *grpc.Server) {
53+
}

0 commit comments

Comments
 (0)