Skip to content

Commit

Permalink
feature: WS-279 made it so that command receivers are explicitly add …
Browse files Browse the repository at this point in the history
…(instead of magically via providers)
  • Loading branch information
akeemphilbert committed Apr 4, 2024
1 parent 4d342c3 commit 3f99f60
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ For general help using WeOS, please refer to [the official WeOS documentation](h

## License

See the [LICENSE](./LICENSE) file for licensing information.
See the [LICENSE](./LICENSE) file for licensing information
6 changes: 1 addition & 5 deletions rest/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ const DELETE_COMMAND = "delete"

type CommandDispatcherParams struct {
fx.In
CommandConfigs []CommandConfig
Logger Log
Logger Log
}

type CommandDispatcherResult struct {
Expand All @@ -29,9 +28,6 @@ func NewCommandDispatcher(p CommandDispatcherParams) CommandDispatcherResult {
dispatcher := &DefaultCommandDispatcher{
handlers: make(map[string][]CommandHandler),
}
for _, config := range p.CommandConfigs {
dispatcher.AddSubscriber(config)
}
return CommandDispatcherResult{
Dispatcher: dispatcher,
}
Expand Down
9 changes: 6 additions & 3 deletions rest/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ func TestIntegrations(t *testing.T) {
os.Setenv("WEOS_PORT", "8681")
os.Setenv("WEOS_SPEC", "./fixtures/blog.yaml")
//use fx Module to start the server
Receivers := func() []rest.CommandConfig {
return []rest.CommandConfig{
Receivers := func(commandDispatcher rest.CommandDispatcher) {
handlers := []rest.CommandConfig{
{
Type: "CreateBlog",
Handler: func(ctx context.Context, command *rest.Command, logger rest.Log, options *rest.CommandOptions) (response rest.CommandResponse, err error) {
Expand All @@ -45,8 +45,11 @@ func TestIntegrations(t *testing.T) {
},
},
}
for _, handler := range handlers {
commandDispatcher.AddSubscriber(handler)
}
}
app := fxtest.New(t, fx.Provide(Receivers), rest.Core, fx.Invoke(func(techo *echo.Echo) {
app := fxtest.New(t, fx.Invoke(Receivers), rest.Core, fx.Invoke(func(techo *echo.Echo) {
e = techo
}))
defer app.RequireStop()
Expand Down

0 comments on commit 3f99f60

Please sign in to comment.