Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nexus_cqrs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Public
nexus_cqrs
Commits
8bfadfd0
Commit
8bfadfd0
authored
3 years ago
by
Dean Lovett
Browse files
Options
Downloads
Patches
Plain Diff
feat: added mechanism for reregistering the handlers
parent
aac3a7d4
No related branches found
Branches containing commit
Tags
0.2.0
Tags containing commit
No related merge requests found
Pipeline
#18987
failed
3 years ago
Stage: release
Stage: test
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/nexus_cqrs/command_bus.rb
+5
-2
5 additions, 2 deletions
lib/nexus_cqrs/command_bus.rb
lib/nexus_cqrs/command_executor.rb
+14
-5
14 additions, 5 deletions
lib/nexus_cqrs/command_executor.rb
with
19 additions
and
7 deletions
lib/nexus_cqrs/command_bus.rb
+
5
−
2
View file @
8bfadfd0
...
...
@@ -7,8 +7,7 @@ module NexusCqrs
MultipleHandlers
=
Class
.
new
(
StandardError
)
def
initialize
(
middleware:
nil
)
@handlers
=
ThreadSafe
::
Cache
.
new
@handlers
=
ThreadSafe
::
Cache
.
new
@middleware
=
middleware
||
Middleware
::
Builder
.
new
end
...
...
@@ -29,6 +28,10 @@ module NexusCqrs
handlers
end
def
clear_handlers
@handlers
=
ThreadSafe
::
Cache
.
new
end
attr_reader
:handlers
private
...
...
This diff is collapsed.
Click to expand it.
lib/nexus_cqrs/command_executor.rb
+
14
−
5
View file @
8bfadfd0
module
NexusCqrs
class
CommandExecutor
# @param [NexusCqrs::CommandBus] command_bus
def
initialize
(
command_bus
)
@bus
=
command_bus
register_commands
end
# @param [NexusCqrs::BaseCommand] command
def
execute
(
command
)
@bus
.
call
(
command
)
end
# @param [NexusCqrs::BaseCommandHandler] handler
def
register_command
(
klass
,
handler
)
@bus
.
register
(
klass
,
handler
)
end
private
def
reregister_handlers
return
if
@register_handlers
.
nil?
def
register_command
s
# TODO, Register Commands/Queries
@bus
.
clear_handler
s
@register_handlers
.
call
(
self
)
end
def
configure_handlers
(
&
block
)
@register_handlers
=
block
@register_handlers
.
call
(
self
)
end
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment