event_sourcery-rails 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4c44446ad62fb825fb92ea6d5b2172a710b6a903de6c3c319559bdd570f44294
4
+ data.tar.gz: 59f59a84434b1e5a56b28a1b5d1013003c01038083fafa490ef882f78b433255
5
+ SHA512:
6
+ metadata.gz: ae8a0001888778819f8b9636644d6d1184e47fa8953901d99beb59f2d86c935e4114ad56e7b4055f2df93ae3e8a6c7ae949129be5149f7c631104480bd82e321
7
+ data.tar.gz: 9cb58b78bafec58bb05380f5723e6d270022fab2806b1f91b2667f4eba53733be44aa767ea78411e639ce9a201e2b9eabd9f153f615fd7f65e8846bc22166c50
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2019 Baylor Rae'
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # EventSourcery::Rails
2
+ Short description and motivation.
3
+
4
+ ## Usage
5
+ How to use my plugin.
6
+
7
+ ## Installation
8
+ Add the following line to your Gemfile.
9
+
10
+ ```ruby
11
+ gem 'event_sourcery'
12
+ gem 'event_sourcery-postgres'
13
+ gem 'event_sourcery-rails'
14
+ ```
15
+
16
+ Then run `bundle install`
17
+
18
+ Next, your need to run the generator:
19
+
20
+ ```bash
21
+ $ rails generate event_sourcery_rails:install
22
+ ```
23
+
24
+ At this point you will have an initializer to configure EventSourcery and a
25
+ rake file with the following tasks.
26
+
27
+ ```
28
+ rails event_sourcery:db:migrate # create the event sourcery schema
29
+ rails event_sourcery:processors:setup # create projector schemas
30
+ rails event_sourcery:processors:reset # drop and recreate projector schemas and data
31
+ rails event_sourcery:processors:run # start event stream processors
32
+ ```
33
+
34
+ Typically you'll have the following in your Procfile.
35
+
36
+ ```yaml
37
+ web: rails server
38
+ processors: rails event_sourcery:processors:run
39
+ ```
40
+
41
+ ## Contributing
42
+ Please submit issues and pull requests for bugs, features or ideas.
43
+
44
+ ## License
45
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,17 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'EventSourcery::Rails'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ require 'bundler/gem_tasks'
@@ -0,0 +1,15 @@
1
+ module EventSourceryRails
2
+ class InstallGenerator < ::Rails::Generators::Base
3
+ source_root File.expand_path('templates', __dir__)
4
+
5
+ def copy_initializer
6
+ @application_name = Rails.application.class.parent.name
7
+ template "initializer.rb", "config/initializers/event_sourcery.rb"
8
+ end
9
+
10
+ def copy_rake_tasks
11
+ @application_name = Rails.application.class.parent.name
12
+ template "event_sourcery.rake", "lib/tasks/event_sourcery.rake"
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,40 @@
1
+ def processors(db_connection, tracker)
2
+ []
3
+ end
4
+
5
+ namespace :event_sourcery do
6
+ namespace :db do
7
+ task migrate: :environment do
8
+ database = EventSourcery::Postgres.config.event_store_database
9
+ begin
10
+ EventSourcery::Postgres::Schema.create_event_store(db: database)
11
+ rescue StandardError => e
12
+ puts "Could not create event store: #{e.class.name} #{e.message}"
13
+ end
14
+ end
15
+ end
16
+
17
+ namespace :processors do
18
+ task setup: :environment do
19
+ processors(<%= @application_name %>.projections_database, <%= @application_name %>.tracker).each(&:setup)
20
+ end
21
+
22
+ task reset: :environment do
23
+ processors(<%= @application_name %>.projections_database, <%= @application_name %>.tracker).each(&:reset)
24
+ end
25
+
26
+ task run: :environment do
27
+ puts "Starting Event Stream Processors"
28
+
29
+ <%= @application_name %>.projections_database.disconnect
30
+
31
+ $stdout.sync = true
32
+
33
+ EventSourcery::EventProcessing::ESPRunner.new(
34
+ event_processors: processors(<%= @application_name %>.projections_database, <%= @application_name %>.tracker),
35
+ event_source: <%= @application_name %>.event_source
36
+ ).start!
37
+ end
38
+ end
39
+ end
40
+
@@ -0,0 +1,53 @@
1
+ module <%= @application_name %>
2
+ class Config
3
+ attr_accessor :database_url
4
+ end
5
+
6
+ def self.config
7
+ @config ||= Config.new
8
+ end
9
+
10
+ def self.configure
11
+ yield config
12
+ end
13
+
14
+ def self.event_store
15
+ EventSourcery::Postgres.config.event_store
16
+ end
17
+
18
+ def self.event_source
19
+ EventSourcery::Postgres.config.event_store
20
+ end
21
+
22
+ def self.tracker
23
+ EventSourcery::Postgres.config.event_tracker
24
+ end
25
+
26
+ def self.event_sink
27
+ EventSourcery::Postgres.config.event_sink
28
+ end
29
+
30
+ def self.projections_database
31
+ EventSourcery::Postgres.config.projections_database
32
+ end
33
+
34
+ def self.repository
35
+ @repository ||= EventSourcery::Repository.new(
36
+ event_source: event_source,
37
+ event_sink: event_sink
38
+ )
39
+ end
40
+ end
41
+
42
+ <%= @application_name %>.configure do |config|
43
+ config.database_url = YAML.load(Rails.root.join('config', 'database.yml').read)[Rails.env]
44
+ end
45
+
46
+ EventSourcery::Postgres.configure do |config|
47
+ database = Sequel.connect(<%= @application_name %>.config.database_url)
48
+
49
+ # NOTE: Often we choose to split our events and projections into separate
50
+ # databases. For the purposes of this example we'll use one.
51
+ config.event_store_database = database
52
+ config.projections_database = database
53
+ end
@@ -0,0 +1,9 @@
1
+ module EventSourcery
2
+ module Rails
3
+ class Railtie < ::Rails::Railtie
4
+ generators do
5
+ require 'event_sourcery/rails/generators/install_generator'
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ module EventSourcery
2
+ module Rails
3
+ VERSION = '0.1.0'
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ require "event_sourcery/rails/railtie"
2
+
3
+ module EventSourcery
4
+ module Rails
5
+ # Your code goes here...
6
+ end
7
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :event_sourcery_rails do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: event_sourcery-rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Baylor Rae'
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-02-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 5.2.2
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 5.2.2
27
+ - !ruby/object:Gem::Dependency
28
+ name: sqlite3
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.4'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.4'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.8'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.8'
55
+ - !ruby/object:Gem::Dependency
56
+ name: ammeter
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.1'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.1'
69
+ description: Event Sourcery with the conventions of Rails. Because combining two great
70
+ powers is always better than not.
71
+ email:
72
+ - baylor@thecodedeli.com
73
+ executables: []
74
+ extensions: []
75
+ extra_rdoc_files: []
76
+ files:
77
+ - MIT-LICENSE
78
+ - README.md
79
+ - Rakefile
80
+ - lib/event_sourcery/rails.rb
81
+ - lib/event_sourcery/rails/generators/install_generator.rb
82
+ - lib/event_sourcery/rails/generators/templates/event_sourcery.rake
83
+ - lib/event_sourcery/rails/generators/templates/initializer.rb
84
+ - lib/event_sourcery/rails/railtie.rb
85
+ - lib/event_sourcery/rails/version.rb
86
+ - lib/tasks/event_sourcery/rails_tasks.rake
87
+ homepage: https://github.com/baylorrae/event_sourcery-rails
88
+ licenses:
89
+ - MIT
90
+ metadata: {}
91
+ post_install_message:
92
+ rdoc_options: []
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: '0'
105
+ requirements: []
106
+ rubygems_version: 3.0.1
107
+ signing_key:
108
+ specification_version: 4
109
+ summary: Combining two great powers of the code, data and web.
110
+ test_files: []