synapse-core 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +13 -0
- data/README.md +161 -0
- data/lib/synapse/version.rb +1 -1
- metadata +98 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 37191bd42b83dadc67f125bb450d2a888c60bd54
|
4
|
+
data.tar.gz: 423dac148c45c4986ec04adfe5f6913279facba0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c7f8fa6c6923b98d232fe2bc1a29dcc2b7f5646b80a4a39e499607ec8e497d82c5165578012399b75579383ba047d5fe2a072917ce5753d990fc726cf8f835e
|
7
|
+
data.tar.gz: 280dedea673fd4b0288542572855b6bc1ddec9adbb334d1dd8cd3c2cc883a584a32f09a7792aaf7443c478cebdb197c7830af734291e665907a0455f83b7de50
|
data/LICENSE
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
Copyright 2013 Ian Unruh
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
|
+
limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
![Synapse logo](http://i.imgur.com/BIwv418.png)
|
2
|
+
|
3
|
+
Synapse is a CQRS and event sourcing framework for Ruby 1.9.3 and later.
|
4
|
+
|
5
|
+
[![Code Climate](https://codeclimate.com/github/ianunruh/synapse.png)](https://codeclimate.com/github/ianunruh/synapse)
|
6
|
+
[![Coverage Status](https://coveralls.io/repos/ianunruh/synapse/badge.png?branch=master)](https://coveralls.io/r/ianunruh/synapse)
|
7
|
+
[![Build Status](https://travis-ci.org/ianunruh/synapse.png?branch=master)](https://travis-ci.org/ianunruh/synapse)
|
8
|
+
[![Gem Version](https://badge.fury.io/rb/synapse-core.png)](http://badge.fury.io/rb/synapse-core)
|
9
|
+
|
10
|
+
Synapse is partially an idiomatic port of [AxonFramework](http://axonframework.org) and [Lokad.CQRS](http://lokad.github.io/lokad-cqrs)
|
11
|
+
|
12
|
+
**Warning:** Synapse is still under development; public API can change at any time.
|
13
|
+
|
14
|
+
## Resources
|
15
|
+
|
16
|
+
Have questions? Come to `#synapse-cqrs` on `irc.freenode.net`. I'm usually around.
|
17
|
+
|
18
|
+
+ [CQRS Guide](http://cqrsguide.com/guide)
|
19
|
+
+ [CQRS is too complicated](http://codeofrob.com/entries/cqrs-is-too-complicated.html)
|
20
|
+
+ [AxonFramework reference guide](http://www.axonframework.org/docs/2.0/)
|
21
|
+
|
22
|
+
## Quickstart
|
23
|
+
|
24
|
+
You know the drill, add it to your `Gemfile`:
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
gem 'synapse-core'
|
28
|
+
gem 'synapse-mongo'
|
29
|
+
|
30
|
+
# Or if you're feeling edgy
|
31
|
+
gem 'synapse-core', :github => 'ianunruh/synapse', :branch => :master
|
32
|
+
gem 'synapse-mongo', :github => 'ianunruh/synapse-mongo', :branch => :master
|
33
|
+
```
|
34
|
+
|
35
|
+
You can define your commands and events using plain old Ruby objects.
|
36
|
+
|
37
|
+
```ruby
|
38
|
+
class CreateInventoryItem
|
39
|
+
attr_reader :id, :description
|
40
|
+
|
41
|
+
def initialize(id, description)
|
42
|
+
@id = id
|
43
|
+
@description = description
|
44
|
+
end
|
45
|
+
end
|
46
|
+
```
|
47
|
+
|
48
|
+
Define the aggregate -- In this case, an event-sourced aggregate.
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
class InventoryItem
|
52
|
+
include Synapse::EventSourcing::AggregateRoot
|
53
|
+
|
54
|
+
def initialize(id, description)
|
55
|
+
apply InventoryItemCreated.new id, description
|
56
|
+
end
|
57
|
+
|
58
|
+
def check_in(quantity)
|
59
|
+
apply StockCheckedIn.new id, quantity
|
60
|
+
end
|
61
|
+
|
62
|
+
map_event InventoryItemCreated do |event|
|
63
|
+
@id = event.id
|
64
|
+
end
|
65
|
+
|
66
|
+
map_event StockCheckedIn do |event|
|
67
|
+
@stock = @stock + event.quantity
|
68
|
+
end
|
69
|
+
end
|
70
|
+
```
|
71
|
+
|
72
|
+
Define the command handler
|
73
|
+
|
74
|
+
```ruby
|
75
|
+
class InventoryItemCommandHandler
|
76
|
+
include Synapse::Command::MappingCommandHandler
|
77
|
+
|
78
|
+
attr_accessor :repository
|
79
|
+
|
80
|
+
map_command CreateInventoryItem do |command|
|
81
|
+
item = InventoryItem.new command.id, command.description
|
82
|
+
@repository.add item
|
83
|
+
end
|
84
|
+
|
85
|
+
map_command CheckInStock do |command|
|
86
|
+
item = @repository.load command.id
|
87
|
+
item.check_in command.quantity
|
88
|
+
end
|
89
|
+
end
|
90
|
+
```
|
91
|
+
|
92
|
+
Wire everything up
|
93
|
+
|
94
|
+
```ruby
|
95
|
+
Synapse.build_with_defaults do
|
96
|
+
mongo_event_store do
|
97
|
+
use_client Mongo::MongoClient.new
|
98
|
+
end
|
99
|
+
|
100
|
+
es_repository :item_repository do
|
101
|
+
use_aggregate_type InventoryItem
|
102
|
+
end
|
103
|
+
|
104
|
+
# Register your command handler so it can be subscribed to the command bus and get its own
|
105
|
+
# dependencies injected upon creation
|
106
|
+
factory :item_command_handler, :tag => :command_handler do
|
107
|
+
handler = InventoryItemCommandHandler.new
|
108
|
+
handler.repository = resolve :item_repository
|
109
|
+
|
110
|
+
handler
|
111
|
+
end
|
112
|
+
end
|
113
|
+
```
|
114
|
+
|
115
|
+
aaaaaand you're done!
|
116
|
+
|
117
|
+
```ruby
|
118
|
+
class InventoryItemController < ApplicationController
|
119
|
+
depends_on :gateway
|
120
|
+
|
121
|
+
def create
|
122
|
+
# ...
|
123
|
+
|
124
|
+
command = CreateInventoryItem.new sku, description
|
125
|
+
gateway.send command
|
126
|
+
end
|
127
|
+
end
|
128
|
+
```
|
129
|
+
|
130
|
+
## Features
|
131
|
+
|
132
|
+
- Event sourced aggregates
|
133
|
+
- DSL for specifying event handlers and aggregate members
|
134
|
+
- Event store backed by MongoDB
|
135
|
+
- Aggregate snapshot support
|
136
|
+
- Conflict resolution with optimistic locking
|
137
|
+
- Non-event sourced aggregates
|
138
|
+
- Supports persistence using ActiveRecord, MongoMapper, DataMapper, Mongoid, etc.
|
139
|
+
- DSL for easy mapping of event and command handlers
|
140
|
+
- Command validation (using ActiveModel)
|
141
|
+
- Simple object serialization
|
142
|
+
- Ox, Oj and Marshal
|
143
|
+
- Attribute-based serialization to JSON/XML
|
144
|
+
- Deprecated events can be loaded and upcast into new formats
|
145
|
+
- Process manager framework (also known as Saga management)
|
146
|
+
|
147
|
+
## Compatibility
|
148
|
+
|
149
|
+
Synapse is tested and developed on several different runtimes, including:
|
150
|
+
|
151
|
+
- MRI 1.9.3
|
152
|
+
- MRI 2.0.0
|
153
|
+
- JRuby 1.7.3
|
154
|
+
- Rubinius 2.0.0-rc1 (rbx-head)
|
155
|
+
|
156
|
+
## Coming soon
|
157
|
+
- Event store using Sequel
|
158
|
+
- Distributed command and event buses (partitioning)
|
159
|
+
- Aggregates as command handlers
|
160
|
+
- Event replay and projection framework
|
161
|
+
- Event scheduling
|
data/lib/synapse/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: synapse-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ian Unruh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 0.1.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 0.1.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: ref
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,6 +86,8 @@ executables: []
|
|
86
86
|
extensions: []
|
87
87
|
extra_rdoc_files: []
|
88
88
|
files:
|
89
|
+
- LICENSE
|
90
|
+
- README.md
|
89
91
|
- lib/synapse/auditing/audit_logger.rb
|
90
92
|
- lib/synapse/auditing/command_metadata_provider.rb
|
91
93
|
- lib/synapse/auditing/correlation_data_provider.rb
|
@@ -369,5 +371,96 @@ rubygems_version: 2.0.3
|
|
369
371
|
signing_key:
|
370
372
|
specification_version: 4
|
371
373
|
summary: A versatile CQRS and event sourcing framework
|
372
|
-
test_files:
|
374
|
+
test_files:
|
375
|
+
- test/auditing/data_provider_test.rb
|
376
|
+
- test/auditing/dispatch_interceptor_test.rb
|
377
|
+
- test/auditing/unit_listener_test.rb
|
378
|
+
- test/command/async_command_bus_test.rb
|
379
|
+
- test/command/duplication_test.rb
|
380
|
+
- test/command/gateway/interval_retry_scheduler_test.rb
|
381
|
+
- test/command/gateway/retrying_callback_test.rb
|
382
|
+
- test/command/gateway_test.rb
|
383
|
+
- test/command/interceptor_chain_test.rb
|
384
|
+
- test/command/mapping_test.rb
|
385
|
+
- test/command/message_test.rb
|
386
|
+
- test/command/serialization_test.rb
|
387
|
+
- test/command/simple_command_bus_test.rb
|
388
|
+
- test/command/validation_test.rb
|
389
|
+
- test/common/concurrency/identifier_lock_manager_test.rb
|
390
|
+
- test/common/duplication_test.rb
|
391
|
+
- test/configuration/component/command_bus/async_command_bus_test.rb
|
392
|
+
- test/configuration/component/command_bus/simple_command_bus_test.rb
|
393
|
+
- test/configuration/component/event_bus/simple_event_bus_test.rb
|
394
|
+
- test/configuration/component/event_sourcing/repository_test.rb
|
395
|
+
- test/configuration/component/process_manager/container_resource_injector_test.rb
|
396
|
+
- test/configuration/component/process_manager/mapping_process_manager_test.rb
|
397
|
+
- test/configuration/component/repository/simple_repository_test.rb
|
398
|
+
- test/configuration/component/serialization/converter_factory_test.rb
|
399
|
+
- test/configuration/component/serialization/serializer_test.rb
|
400
|
+
- test/configuration/component/uow/unit_factory_test.rb
|
401
|
+
- test/configuration/component/upcasting/upcaster_chain_test.rb
|
402
|
+
- test/configuration/container_builder_test.rb
|
403
|
+
- test/configuration/container_test.rb
|
404
|
+
- test/configuration/definition_builder_test.rb
|
405
|
+
- test/configuration/definition_test.rb
|
406
|
+
- test/configuration/dependent_test.rb
|
407
|
+
- test/configuration/ext_test.rb
|
408
|
+
- test/configuration/fixtures/dependent.rb
|
409
|
+
- test/domain/aggregate_root_test.rb
|
410
|
+
- test/domain/fixtures.rb
|
411
|
+
- test/domain/message_test.rb
|
412
|
+
- test/domain/stream_test.rb
|
413
|
+
- test/event_bus/mapping_test.rb
|
414
|
+
- test/event_bus/publisher_test.rb
|
415
|
+
- test/event_sourcing/aggregate_factory_test.rb
|
416
|
+
- test/event_sourcing/aggregate_root_test.rb
|
417
|
+
- test/event_sourcing/caching_test.rb
|
418
|
+
- test/event_sourcing/entity_test.rb
|
419
|
+
- test/event_sourcing/fixtures.rb
|
420
|
+
- test/event_sourcing/repository_test.rb
|
421
|
+
- test/event_sourcing/snapshot/aggregate_taker_test.rb
|
422
|
+
- test/event_sourcing/snapshot/interval_policy_test.rb
|
423
|
+
- test/event_store/in_memory_test.rb
|
424
|
+
- test/process_manager/container_resource_injector_test.rb
|
425
|
+
- test/process_manager/correlation_set_test.rb
|
426
|
+
- test/process_manager/in_memory_test.rb
|
427
|
+
- test/process_manager/mapping/fixtures.rb
|
428
|
+
- test/process_manager/mapping/process_manager_test.rb
|
429
|
+
- test/process_manager/mapping/process_test.rb
|
430
|
+
- test/process_manager/process_factory_test.rb
|
431
|
+
- test/process_manager/process_test.rb
|
432
|
+
- test/process_manager/simple_process_manager_test.rb
|
433
|
+
- test/repository/locking_test.rb
|
434
|
+
- test/repository/optimistic_test.rb
|
435
|
+
- test/repository/pessimistic_test.rb
|
436
|
+
- test/repository/simple_repository_test.rb
|
437
|
+
- test/serialization/converter/chain_test.rb
|
438
|
+
- test/serialization/converter/factory_test.rb
|
439
|
+
- test/serialization/converter/identity_test.rb
|
440
|
+
- test/serialization/converter/json_test.rb
|
441
|
+
- test/serialization/converter/ox_test.rb
|
442
|
+
- test/serialization/fixtures.rb
|
443
|
+
- test/serialization/lazy_object_test.rb
|
444
|
+
- test/serialization/message/metadata_test.rb
|
445
|
+
- test/serialization/message/serialization_aware_message_test.rb
|
446
|
+
- test/serialization/message/serialized_message_builder_test.rb
|
447
|
+
- test/serialization/message/serialized_message_test.rb
|
448
|
+
- test/serialization/message/serializer_test.rb
|
449
|
+
- test/serialization/revision_resolver_test.rb
|
450
|
+
- test/serialization/serialized_object_test.rb
|
451
|
+
- test/serialization/serialized_type_test.rb
|
452
|
+
- test/serialization/serializer/attribute_test.rb
|
453
|
+
- test/serialization/serializer/marshal_test.rb
|
454
|
+
- test/serialization/serializer/oj_test.rb
|
455
|
+
- test/serialization/serializer/ox_test.rb
|
456
|
+
- test/serialization/serializer_test.rb
|
457
|
+
- test/test_ext.rb
|
458
|
+
- test/test_helper.rb
|
459
|
+
- test/uow/factory_test.rb
|
460
|
+
- test/uow/outer_commit_listener_test.rb
|
461
|
+
- test/uow/provider_test.rb
|
462
|
+
- test/uow/uow_test.rb
|
463
|
+
- test/upcasting/chain_test.rb
|
464
|
+
- test/upcasting/data_test.rb
|
465
|
+
- test/upcasting/fixtures.rb
|
373
466
|
has_rdoc:
|