tkxs-component-generator 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 +7 -0
- data/executable/tkxs-component-generator +6 -0
- data/lib/command_line/component_generator/commands/component.rb +59 -0
- data/lib/command_line/component_generator/interface.rb +7 -0
- data/lib/command_line/component_generator.rb +9 -0
- data/source/%component_name%.gemspec.tt +28 -0
- data/source/.circleci/config.yml +141 -0
- data/source/.gitignore +18 -0
- data/source/.rspec.tt +2 -0
- data/source/.rubocop.yml.tt +110 -0
- data/source/CHANGELOG.md +26 -0
- data/source/Dockerfile.tt +21 -0
- data/source/Guardfile.tt +26 -0
- data/source/README.md.tt +5 -0
- data/source/Rakefile.tt +35 -0
- data/source/VERSION +1 -0
- data/source/bin/release +9 -0
- data/source/bin/setup.tt +4 -0
- data/source/bin/start.tt +10 -0
- data/source/config/pgadmin_servers.json.tt +13 -0
- data/source/docker-compose.yml.tt +72 -0
- data/source/gems.rb.tt +6 -0
- data/source/lib/%component_name%/%entity_name%.rb.tt +14 -0
- data/source/lib/%component_name%/consumers/commands.rb.tt +11 -0
- data/source/lib/%component_name%/consumers/events.rb.tt +11 -0
- data/source/lib/%component_name%/handlers/commands.rb.tt +49 -0
- data/source/lib/%component_name%/handlers/events.rb.tt +21 -0
- data/source/lib/%component_name%/messages/commands/.empty_directory +0 -0
- data/source/lib/%component_name%/messages/events/.empty_directory +0 -0
- data/source/lib/%component_name%/projection.rb.tt +24 -0
- data/source/lib/%component_name%/start.rb.tt +10 -0
- data/source/lib/%component_name%/store.rb.tt +15 -0
- data/source/lib/%component_name%.rb.tt +17 -0
- data/source/secrets.env.example +4 -0
- data/source/spec/%component_name%/%component_name%_spec.rb.tt +5 -0
- data/source/spec/spec_helper.rb.tt +34 -0
- data/source/spec/support/.keep.tt +0 -0
- metadata +107 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 68ab994fc0ea224422b2282e7105da3954cdea553f0c640fb73a9500b129bb0e
|
4
|
+
data.tar.gz: 23f8dbe9691a8f1d59f666f31585ebed21c66e1ab819ef76ae7468f9ae105020
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ac3f45cc3a4c9493b4b2b6b36e4a889740a34376162675b7f37ea569ea7b30c87fc530059f40bf4103c340fe922dbf8b2777d2eecc02661b0d1ee916af11b645
|
7
|
+
data.tar.gz: e2a59ad8300a3e775816dd9e36b3e019ae057abff264ff867e1d01121f82a3ad7e429b16c95cc079e5d13865e21257966479862a602ceb6a2705f3c632862dca
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module CommandLine
|
2
|
+
module ComponentGenerator
|
3
|
+
module Commands
|
4
|
+
class Component < Thor::Group
|
5
|
+
include Thor::Actions
|
6
|
+
|
7
|
+
argument :name
|
8
|
+
|
9
|
+
def component_name
|
10
|
+
@component_name ||= name.end_with?('_component') ? name : "#{name}_component"
|
11
|
+
end
|
12
|
+
|
13
|
+
def component_root_dir_name
|
14
|
+
@component_dir_name ||= component_name.gsub('_','-')
|
15
|
+
end
|
16
|
+
|
17
|
+
def component_constant_name
|
18
|
+
@component_constant_name ||= Casing::Pascal.(component_name)
|
19
|
+
end
|
20
|
+
|
21
|
+
def entity_name
|
22
|
+
@entity_name ||= Casing::Underscore.(entity_constant_name)
|
23
|
+
end
|
24
|
+
|
25
|
+
def entity_stream_name
|
26
|
+
@entity_stream_name ||= Casing::Camel.(entity_name)
|
27
|
+
end
|
28
|
+
|
29
|
+
def entity_constant_name
|
30
|
+
@entity_constant_name ||= Casing::Pascal.(component_name.gsub('_component', ''))
|
31
|
+
end
|
32
|
+
|
33
|
+
def service_name
|
34
|
+
@service_name ||= entity_name.gsub('_', '-')
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.source_root
|
38
|
+
File.dirname(__FILE__) + '/../../../../source'
|
39
|
+
end
|
40
|
+
|
41
|
+
def initialize(args=[], options={}, config={})
|
42
|
+
super
|
43
|
+
self.destination_root = component_root_dir_name
|
44
|
+
end
|
45
|
+
|
46
|
+
def generate_component
|
47
|
+
directory('./')
|
48
|
+
end
|
49
|
+
|
50
|
+
def assign_executable_attribute
|
51
|
+
chmod 'bin/release', 0755
|
52
|
+
chmod 'bin/setup', 0755
|
53
|
+
chmod 'bin/start', 0755
|
54
|
+
chmod 'Rakefile', 0755
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = '<%= component_name %>'
|
6
|
+
spec.version = File.read('VERSION')
|
7
|
+
spec.summary = ' '
|
8
|
+
spec.description = ' '
|
9
|
+
|
10
|
+
spec.authors = ['email@domain.com']
|
11
|
+
spec.homepage = 'http://tkxs.com'
|
12
|
+
spec.licenses = ['TODO']
|
13
|
+
|
14
|
+
# Prevent pushing this gem to RubyGems.org, allow Gemfury
|
15
|
+
spec.metadata['allowed_push_host'] = 'http://gemfury.com'
|
16
|
+
|
17
|
+
spec.require_paths = ['lib']
|
18
|
+
spec.files = Dir.glob('{lib}/**/*')
|
19
|
+
spec.platform = Gem::Platform::RUBY
|
20
|
+
spec.required_ruby_version = '>= 2.6'
|
21
|
+
|
22
|
+
spec.add_runtime_dependency 'tkxs-components'
|
23
|
+
|
24
|
+
spec.add_development_dependency 'guard-rspec'
|
25
|
+
spec.add_development_dependency 'guard-rubocop'
|
26
|
+
spec.add_development_dependency 'pry'
|
27
|
+
spec.add_development_dependency 'simplecov'
|
28
|
+
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
version: 2.0
|
2
|
+
|
3
|
+
references:
|
4
|
+
image_ruby: &image_ruby
|
5
|
+
ruby:2.6
|
6
|
+
# image_postgres: &image_postgres
|
7
|
+
# postgres:11-alpine
|
8
|
+
|
9
|
+
cache_key_bundle: &cache_key_bundle
|
10
|
+
v1-bundle-{{ checksum "gems.rb" }}
|
11
|
+
cache_key_backup_bundle: &cache_key_backup_bundle
|
12
|
+
v1-bundle-
|
13
|
+
cache_path_bundle: &cache_path_bundle
|
14
|
+
/usr/local/bundle
|
15
|
+
restore_cache_bundle: &restore_cache_bundle
|
16
|
+
restore_cache:
|
17
|
+
keys:
|
18
|
+
- *cache_key_bundle
|
19
|
+
- *cache_key_backup_bundle
|
20
|
+
|
21
|
+
cache_key_git: &cache_key_git
|
22
|
+
v1-git-{{ .Environment.CIRCLE_SHA1 }}
|
23
|
+
cache_key_backup_git: &cache_key_backup_git
|
24
|
+
v1-git-
|
25
|
+
cache_path_git: &cache_path_git
|
26
|
+
/usr/src/app
|
27
|
+
restore_cache_git: &restore_cache_git
|
28
|
+
restore_cache:
|
29
|
+
keys:
|
30
|
+
- *cache_key_git
|
31
|
+
- *cache_key_backup_git
|
32
|
+
|
33
|
+
jobs:
|
34
|
+
checkout_code:
|
35
|
+
docker:
|
36
|
+
- image: *image_ruby
|
37
|
+
working_directory: /usr/src/app
|
38
|
+
steps:
|
39
|
+
- checkout
|
40
|
+
# - run:
|
41
|
+
# name: Decrypt secrets
|
42
|
+
# command: |
|
43
|
+
# echo $KEY > secrets.aes
|
44
|
+
# openssl enc \
|
45
|
+
# -in .circleci/secrets.encrypted \
|
46
|
+
# -out secrets.env \
|
47
|
+
# -d -aes256 \
|
48
|
+
# -pass file:secrets.aes
|
49
|
+
- save_cache:
|
50
|
+
key: *cache_key_git
|
51
|
+
paths:
|
52
|
+
- *cache_path_git
|
53
|
+
|
54
|
+
run_bundle:
|
55
|
+
docker:
|
56
|
+
- image: *image_ruby
|
57
|
+
working_directory: /usr/src/app
|
58
|
+
steps:
|
59
|
+
- *restore_cache_git
|
60
|
+
- *restore_cache_bundle
|
61
|
+
- run:
|
62
|
+
name: Bundle
|
63
|
+
command: |
|
64
|
+
export BUNDLER_VERSION=2.0.1
|
65
|
+
gem install bundler
|
66
|
+
bundle check || \
|
67
|
+
bundle install -j5 && \
|
68
|
+
bundle clean
|
69
|
+
rm -f gems.locked
|
70
|
+
- save_cache:
|
71
|
+
key: *cache_key_bundle
|
72
|
+
paths:
|
73
|
+
- *cache_path_bundle
|
74
|
+
|
75
|
+
setup_and_test:
|
76
|
+
docker:
|
77
|
+
- image: *image_ruby
|
78
|
+
environment:
|
79
|
+
# EVENT_STORE_DATABASE_URL: postgresql://message_store@localhost:5432/message_store
|
80
|
+
LOG_LEVEL: "error"
|
81
|
+
# - image: *image_postgres
|
82
|
+
working_directory: /usr/src/app
|
83
|
+
steps:
|
84
|
+
- *restore_cache_git
|
85
|
+
- *restore_cache_bundle
|
86
|
+
- run:
|
87
|
+
name: Code Climate Test Reporter
|
88
|
+
command: |
|
89
|
+
cc_download_url=https://codeclimate.com/downloads/test-reporter/
|
90
|
+
curl -L $cc_download_url/test-reporter-latest-linux-amd64 > ./cc
|
91
|
+
chmod +x ./cc
|
92
|
+
- run:
|
93
|
+
name: Apt
|
94
|
+
command: |
|
95
|
+
# apt-get update -y
|
96
|
+
# apt-get install -y --no-install-recommends \
|
97
|
+
# postgresql-client \
|
98
|
+
# libsybdb5
|
99
|
+
- run:
|
100
|
+
name: Setup
|
101
|
+
command: |
|
102
|
+
# export VIEW_DATA_DATABASE_URL=postgresql://postgres@localhost:5432/cache_db
|
103
|
+
# export EVENT_STORE_DATABASE_URL=postgresql://postgres@localhost:5432/message_store
|
104
|
+
|
105
|
+
# cd ./tkxs_components/
|
106
|
+
# cp -R ./db/config/. .
|
107
|
+
|
108
|
+
# export DATABASE=event_store
|
109
|
+
# rake db:create db:migrate-event-store
|
110
|
+
|
111
|
+
# export DATABASE=view_data
|
112
|
+
# rake db:create db:migrate-view-data-prerequisites
|
113
|
+
|
114
|
+
# export DATABASE_URL=postgresql://postgres@localhost:5432/cache_db
|
115
|
+
# cd ..
|
116
|
+
# rake db:migrate-all-components
|
117
|
+
- run:
|
118
|
+
name: Test
|
119
|
+
command: |
|
120
|
+
export BUNDLER_VERSION=2.0.1
|
121
|
+
# export EVENT_STORE_DATABASE_URL=postgresql://postgres@localhost:5432/message_store
|
122
|
+
# # notify code climate that a build is starting
|
123
|
+
./cc before-build
|
124
|
+
# run the specs
|
125
|
+
rake ci
|
126
|
+
# notify code climate build is finished
|
127
|
+
./cc after-build -t simplecov
|
128
|
+
- store_artifacts:
|
129
|
+
path: ./coverage
|
130
|
+
|
131
|
+
workflows:
|
132
|
+
version: 2
|
133
|
+
build_test:
|
134
|
+
jobs:
|
135
|
+
- checkout_code
|
136
|
+
- run_bundle:
|
137
|
+
requires:
|
138
|
+
- checkout_code
|
139
|
+
- setup_and_test:
|
140
|
+
requires:
|
141
|
+
- run_bundle
|
data/source/.gitignore
ADDED
data/source/.rspec.tt
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.6
|
3
|
+
Exclude:
|
4
|
+
- bin/**
|
5
|
+
- tmp/**
|
6
|
+
- ./**/db/schema.rb
|
7
|
+
|
8
|
+
Documentation:
|
9
|
+
# don't require classes to be documented
|
10
|
+
Enabled: false
|
11
|
+
|
12
|
+
Encoding:
|
13
|
+
# no need to always specify encoding
|
14
|
+
Enabled: false
|
15
|
+
|
16
|
+
Style/NumericPredicate:
|
17
|
+
# The following is a false positive for specs:
|
18
|
+
#
|
19
|
+
# "Use be.positive? instead of be > 0."
|
20
|
+
Exclude:
|
21
|
+
- 'spec/**/*'
|
22
|
+
|
23
|
+
Metrics/BlockLength:
|
24
|
+
# Certain DSL use blocks and can be lengthy
|
25
|
+
Exclude:
|
26
|
+
- 'spec/**/*'
|
27
|
+
- '*.gemspec'
|
28
|
+
- 'Guardfile'
|
29
|
+
|
30
|
+
AlignParameters:
|
31
|
+
# allow for multi-line methods to have normal indentation.
|
32
|
+
# for example:
|
33
|
+
#
|
34
|
+
# Person.where(
|
35
|
+
# first_name: 'tom',
|
36
|
+
# last_name: 'foolery'
|
37
|
+
# )
|
38
|
+
EnforcedStyle: with_fixed_indentation
|
39
|
+
|
40
|
+
# Disabling this is not desirable however a change in RuboCop v0.60.0 has made
|
41
|
+
# this cop overly restrictive. Watch for an update here:
|
42
|
+
# https://github.com/rubocop-hq/rubocop/issues/6410
|
43
|
+
Layout/AlignHash:
|
44
|
+
Enabled: false
|
45
|
+
|
46
|
+
Layout/AlignParameters:
|
47
|
+
# allow for end of if to be aligned with a variable.
|
48
|
+
# for example:
|
49
|
+
#
|
50
|
+
# foo = if a == b
|
51
|
+
# 'bar'
|
52
|
+
# else
|
53
|
+
# 'baz'
|
54
|
+
# end
|
55
|
+
EnforcedStyle: with_fixed_indentation
|
56
|
+
|
57
|
+
Layout/MultilineMethodCallIndentation:
|
58
|
+
# allow for multi-line method chaining to have normal indentation.
|
59
|
+
# for example:
|
60
|
+
#
|
61
|
+
# Person
|
62
|
+
# .where(first_name: 'tom')
|
63
|
+
# .not(last_name: 'foolery')
|
64
|
+
EnforcedStyle: indented
|
65
|
+
|
66
|
+
Style/RaiseArgs:
|
67
|
+
Enabled: false
|
68
|
+
|
69
|
+
ClassAndModuleChildren:
|
70
|
+
# ok to use compact style when modules are predefined.
|
71
|
+
# for example the following is fine so long as we're sure that
|
72
|
+
# module MDB has already been required/defined.
|
73
|
+
#
|
74
|
+
# class MDB::Person; end
|
75
|
+
Enabled: false
|
76
|
+
|
77
|
+
Style/FrozenStringLiteralComment:
|
78
|
+
Enabled: false
|
79
|
+
|
80
|
+
Style/ParallelAssignment:
|
81
|
+
Enabled: false
|
82
|
+
|
83
|
+
Metrics/AbcSize:
|
84
|
+
Enabled: true
|
85
|
+
|
86
|
+
Metrics/MethodLength:
|
87
|
+
Enabled: false
|
88
|
+
|
89
|
+
Style/PercentLiteralDelimiters:
|
90
|
+
PreferredDelimiters:
|
91
|
+
default: ()
|
92
|
+
"%i": ()
|
93
|
+
"%w": ()
|
94
|
+
|
95
|
+
Style/FormatString:
|
96
|
+
Enabled: false
|
97
|
+
|
98
|
+
Naming/FileName:
|
99
|
+
Exclude:
|
100
|
+
- 'Dangerfile'
|
101
|
+
Naming/UncommunicativeMethodParamName:
|
102
|
+
AllowedNames:
|
103
|
+
- 'pk'
|
104
|
+
- 'id'
|
105
|
+
Layout/EndAlignment:
|
106
|
+
EnforcedStyleAlignWith: variable
|
107
|
+
|
108
|
+
# https://github.com/bbatsov/rubocop/pull/5231
|
109
|
+
Layout/EmptyLinesAroundArguments:
|
110
|
+
Enabled: false
|
data/source/CHANGELOG.md
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
6
|
+
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
7
|
+
|
8
|
+
## [Unreleased](https://github.com/technekes/<%= component_root_dir_name %>/compare/v0.1.0...HEAD)
|
9
|
+
|
10
|
+
When submitting a new PR add your PR's details under the appropriate subsection below.
|
11
|
+
|
12
|
+
### Added
|
13
|
+
|
14
|
+
### Changed
|
15
|
+
|
16
|
+
### Deprecated
|
17
|
+
|
18
|
+
### Removed
|
19
|
+
|
20
|
+
### Fixed
|
21
|
+
|
22
|
+
### Security
|
23
|
+
|
24
|
+
### Changed
|
25
|
+
|
26
|
+
## 0.1.0 (2019-0x-xx)
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# base layer
|
2
|
+
FROM ruby:2.6-alpine AS base
|
3
|
+
|
4
|
+
RUN mkdir -p /usr/src/app
|
5
|
+
WORKDIR /usr/src/app
|
6
|
+
|
7
|
+
RUN \
|
8
|
+
apk add --update --no-cache \
|
9
|
+
bash \
|
10
|
+
build-base \
|
11
|
+
postgresql-client \
|
12
|
+
postgresql-dev
|
13
|
+
|
14
|
+
COPY gems* /usr/src/app/
|
15
|
+
|
16
|
+
# development and test layer with all dependencies
|
17
|
+
FROM base AS development
|
18
|
+
|
19
|
+
COPY . /usr/src/app
|
20
|
+
|
21
|
+
CMD ["bin/start"]
|
data/source/Guardfile.tt
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
options = {
|
2
|
+
cmd: 'rspec',
|
3
|
+
all_after_pass: true,
|
4
|
+
all_on_start: true,
|
5
|
+
spec_paths: './spec'
|
6
|
+
}
|
7
|
+
|
8
|
+
guard(:rspec, options) do
|
9
|
+
require 'guard/rspec/dsl'
|
10
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
11
|
+
|
12
|
+
# RSpec files
|
13
|
+
rspec = dsl.rspec
|
14
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
15
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
16
|
+
watch(rspec.spec_files)
|
17
|
+
|
18
|
+
# Ruby files
|
19
|
+
ruby = dsl.ruby
|
20
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
21
|
+
end
|
22
|
+
|
23
|
+
guard :rubocop, cli: ['--display-cop-names'] do
|
24
|
+
watch(%r{/.+\.rb$/})
|
25
|
+
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
|
26
|
+
end
|
data/source/README.md.tt
ADDED
@@ -0,0 +1,5 @@
|
|
1
|
+
# <%= component_name %>
|
2
|
+
|
3
|
+
This component was generated by the [TKXS component generator](https://github.com/technekes/command-line-component-generator).
|
4
|
+
|
5
|
+
For setup and usage instructions see: [TKXS component development](https://github.com/technekes/documentation/blob/master/development/ruby/component_development.md)
|
data/source/Rakefile.tt
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
7
|
+
spec.pattern = '*spec/**/*_spec.rb'
|
8
|
+
end
|
9
|
+
|
10
|
+
require 'rainbow/ext/string' unless String.respond_to?(:color)
|
11
|
+
require 'rubocop/rake_task'
|
12
|
+
|
13
|
+
RuboCop::RakeTask.new(:rubocop)
|
14
|
+
|
15
|
+
task default: %i(rubocop spec)
|
16
|
+
|
17
|
+
task ci: :default
|
18
|
+
|
19
|
+
# this should really be handled inside of `tkxs-components`
|
20
|
+
namespace :db do
|
21
|
+
task :'migrate-event-store' do
|
22
|
+
Dir.chdir(Gem::Specification.find_by_name('tkxs-components').gem_dir) do
|
23
|
+
require 'fileutils'
|
24
|
+
FileUtils.cp_r('db/config/.', '.')
|
25
|
+
|
26
|
+
require 'standalone_migrations'
|
27
|
+
StandaloneMigrations::Tasks.load_tasks
|
28
|
+
|
29
|
+
require 'tkxs/components/tasks'
|
30
|
+
TKXS::Components::Tasks.install
|
31
|
+
|
32
|
+
Rake::Task['db:migrate'].invoke
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/source/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.0
|
data/source/bin/release
ADDED
data/source/bin/setup.tt
ADDED
data/source/bin/start.tt
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$LOAD_PATH.unshift(File.expand_path('../lib', __dir__))
|
4
|
+
|
5
|
+
require 'component_host'
|
6
|
+
require '<%= component_name %>'
|
7
|
+
|
8
|
+
ComponentHost.start('<%= service_name %>-component') do |host|
|
9
|
+
host.register(<%= component_constant_name %>::Start)
|
10
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
version: '2.3'
|
2
|
+
|
3
|
+
services:
|
4
|
+
gem:
|
5
|
+
build:
|
6
|
+
context: .
|
7
|
+
dockerfile: Dockerfile
|
8
|
+
target: development
|
9
|
+
links:
|
10
|
+
- message-store-db-server
|
11
|
+
# - cache-db-server
|
12
|
+
volumes:
|
13
|
+
- .:/usr/src/app:delegated
|
14
|
+
- bundle:/usr/local/bundle:delegated
|
15
|
+
env_file: secrets.env
|
16
|
+
environment:
|
17
|
+
LOG_TAGS: "ignored,handle,write,-message_store,store,cache,snapshot,view_data,view_data_pg"
|
18
|
+
LOG_LEVEL: "warn"
|
19
|
+
|
20
|
+
message-store-db-server:
|
21
|
+
image: postgres:11-alpine
|
22
|
+
command: postgres -c 'max_connections=200'
|
23
|
+
ports:
|
24
|
+
- "54321:5432"
|
25
|
+
environment:
|
26
|
+
POSTGRES_DB: message_store
|
27
|
+
POSTGRES_USER: docker
|
28
|
+
POSTGRES_PASSWORD: docker
|
29
|
+
|
30
|
+
# cache-db-server:
|
31
|
+
# image: postgres:11-alpine
|
32
|
+
# command: postgres -c 'max_connections=200'
|
33
|
+
# ports:
|
34
|
+
# - "54322:5432"
|
35
|
+
# environment:
|
36
|
+
# POSTGRES_DB: cache_db
|
37
|
+
# POSTGRES_USER: docker
|
38
|
+
# POSTGRES_PASSWORD: docker
|
39
|
+
|
40
|
+
# rake:
|
41
|
+
# build:
|
42
|
+
# context: tkxs_components
|
43
|
+
# dockerfile: ../Dockerfile.migrate
|
44
|
+
# command: -T
|
45
|
+
# volumes:
|
46
|
+
# - ./tkxs_components/db:/usr/src/app/db:delegated
|
47
|
+
# - ./rakelib:/usr/src/app/rakelib:delegated
|
48
|
+
# links:
|
49
|
+
# - message-store-db-server
|
50
|
+
# - cache-db-server
|
51
|
+
# env_file:
|
52
|
+
# - ./secrets.env
|
53
|
+
|
54
|
+
pgadmin:
|
55
|
+
image: dpage/pgadmin4
|
56
|
+
volumes:
|
57
|
+
- pgadmin:/var/lib/pgadmin
|
58
|
+
- ./config/pgadmin_servers.json:/pgadmin4/servers.json
|
59
|
+
ports:
|
60
|
+
- "9090:80"
|
61
|
+
links:
|
62
|
+
- message-store-db-server
|
63
|
+
# - cache-db-server
|
64
|
+
environment:
|
65
|
+
PGADMIN_DEFAULT_EMAIL: docker
|
66
|
+
PGADMIN_DEFAULT_PASSWORD: docker
|
67
|
+
|
68
|
+
volumes:
|
69
|
+
bundle:
|
70
|
+
driver: local
|
71
|
+
pgadmin:
|
72
|
+
driver: local
|
data/source/gems.rb.tt
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# Entity user guide: http://docs.eventide-project.org/user-guide/entities.html
|
2
|
+
# Entity snapshotting user guide: http://docs.eventide-project.org/user-guide/entity-store/snapshotting.html
|
3
|
+
|
4
|
+
module <%= component_constant_name %>
|
5
|
+
class <%= entity_constant_name %>
|
6
|
+
include Schema::DataStructure
|
7
|
+
|
8
|
+
attribute :id, String
|
9
|
+
|
10
|
+
# TODO Implement attributes
|
11
|
+
# TODO Implement entity logic, predicates, mutations, calculations, etc
|
12
|
+
# Note: This class's methods should pertain only to its attributes
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# Handler user guide: http://docs.eventide-project.org/user-guide/handlers.html
|
2
|
+
# Message user guide: http://docs.eventide-project.org/user-guide/messages-and-message-data/
|
3
|
+
|
4
|
+
module <%= component_constant_name %>
|
5
|
+
module Handlers
|
6
|
+
class Commands
|
7
|
+
include Messaging::Handle
|
8
|
+
include Messaging::StreamName
|
9
|
+
include Log::Dependency
|
10
|
+
# TODO include Messages::Commands once commands are implemented
|
11
|
+
# include Messages::Commands
|
12
|
+
# TODO include Messages::Events once events are implemented
|
13
|
+
# include Messages::Events
|
14
|
+
|
15
|
+
dependency :write, Messaging::Postgres::Write
|
16
|
+
dependency :clock, Clock::UTC
|
17
|
+
dependency :store, Store
|
18
|
+
|
19
|
+
def configure
|
20
|
+
Messaging::Postgres::Write.configure(self)
|
21
|
+
Clock::UTC.configure(self)
|
22
|
+
Store.configure(self)
|
23
|
+
end
|
24
|
+
|
25
|
+
category :<%= entity_name %>
|
26
|
+
|
27
|
+
# TODO Implement command handler blocks"
|
28
|
+
# eg:
|
29
|
+
# handle DoSomething do |do_something|
|
30
|
+
# <%= entity_name %>_id = do_something.<%= entity_name %>_id
|
31
|
+
|
32
|
+
# <%= entity_name %>, version = store.fetch(<%= entity_name %>_id, include: :version)
|
33
|
+
|
34
|
+
# if <%= entity_name %>.something_happened?
|
35
|
+
# logger.info(tag: :ignored) { "Command ignored (Command: #{do_something.message_type}, <%= entity_constant_name %> ID: #{<%= entity_name %>_id})" }
|
36
|
+
# return
|
37
|
+
# end
|
38
|
+
|
39
|
+
# something_happened = SomethingHappened.follow(do_something)
|
40
|
+
|
41
|
+
# something_happened.processed_time = clock.iso8601
|
42
|
+
|
43
|
+
# stream_name = stream_name(<%= entity_name %>_id)
|
44
|
+
|
45
|
+
# write.(something_happened, stream_name, expected_version: version)
|
46
|
+
# end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# Handler user guide: http://docs.eventide-project.org/user-guide/handlers.html
|
2
|
+
# Message user guide: http://docs.eventide-project.org/user-guide/messages-and-message-data/
|
3
|
+
|
4
|
+
module <%= component_constant_name %>
|
5
|
+
module Handlers
|
6
|
+
class Events
|
7
|
+
include Messaging::Handle
|
8
|
+
include Messaging::StreamName
|
9
|
+
include Log::Dependency
|
10
|
+
# include Messages::Events once events are implemented
|
11
|
+
# include Messages::Events
|
12
|
+
|
13
|
+
# Note: Delete this file if not handling events
|
14
|
+
|
15
|
+
# TODO Implement event handler blocks
|
16
|
+
# eg:
|
17
|
+
# handle SomethingHappened do |something_happened|
|
18
|
+
# end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
File without changes
|
File without changes
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# Projection user guide: http://docs.eventide-project.org/user-guide/projection.html
|
2
|
+
# Message user guide: http://docs.eventide-project.org/user-guide/messages-and-message-data/
|
3
|
+
|
4
|
+
module <%= component_constant_name %>
|
5
|
+
class Projection
|
6
|
+
include EntityProjection
|
7
|
+
# TODO include Messages::Events once events are implemented"
|
8
|
+
# include Messages::Events
|
9
|
+
|
10
|
+
entity_name :<%= entity_name %>
|
11
|
+
|
12
|
+
# TODO Implement event projection blocks
|
13
|
+
# eg:
|
14
|
+
# apply SomethingHappened do |something_happened|
|
15
|
+
# SetAttributes.(<%= entity_name %>, something_happened, copy: [
|
16
|
+
# { :<%= entity_name %>_id => :id }
|
17
|
+
# ])
|
18
|
+
|
19
|
+
# something_happened_time = Clock.parse(something_happened.time)
|
20
|
+
|
21
|
+
# <%= entity_name %>.something_happened_time = something_happened_time
|
22
|
+
# end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Component initiator user guide: http://docs.eventide-project.org/user-guide/component-host.html#component-initiator
|
2
|
+
|
3
|
+
module <%= component_constant_name %>
|
4
|
+
module Start
|
5
|
+
def self.call
|
6
|
+
Consumers::Commands.start('<%= entity_stream_name %>:command')
|
7
|
+
Consumers::Events.start('<%= entity_stream_name %>')
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Entity store user guide: http://docs.eventide-project.org/user-guide/entity-store/
|
2
|
+
|
3
|
+
module <%= component_constant_name %>
|
4
|
+
class Store
|
5
|
+
include EntityStore
|
6
|
+
|
7
|
+
category :<%= entity_name %>
|
8
|
+
entity <%= entity_constant_name %>
|
9
|
+
projection Projection
|
10
|
+
reader MessageStore::Postgres::Read, batch_size: 1000
|
11
|
+
|
12
|
+
# Optional snapshotting
|
13
|
+
# snapshot EntitySnapshot::Postgres, interval: 1000
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'eventide/postgres'
|
2
|
+
|
3
|
+
# TODO Load command and event message files"
|
4
|
+
# require '<%= component_name %>/messages/commands/...'
|
5
|
+
# require '<%= component_name %>/messages/events/...'
|
6
|
+
|
7
|
+
require '<%= component_name %>/<%= entity_name %>'
|
8
|
+
require '<%= component_name %>/projection'
|
9
|
+
require '<%= component_name %>/store'
|
10
|
+
|
11
|
+
require '<%= component_name %>/handlers/commands'
|
12
|
+
require '<%= component_name %>/handlers/events'
|
13
|
+
|
14
|
+
require '<%= component_name %>/consumers/commands'
|
15
|
+
require '<%= component_name %>/consumers/events'
|
16
|
+
|
17
|
+
require '<%= component_name %>/start'
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
SimpleCov.start
|
3
|
+
|
4
|
+
require 'pry'
|
5
|
+
require 'ostruct'
|
6
|
+
|
7
|
+
require '<%= component_name %>'
|
8
|
+
|
9
|
+
Dir['./spec/support/**/*.rb'].each { |f| require f }
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.pattern = 'spec/**/*_spec.rb'
|
13
|
+
|
14
|
+
config.expect_with :rspec do |expectations|
|
15
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
16
|
+
end
|
17
|
+
|
18
|
+
config.mock_with :rspec do |mocks|
|
19
|
+
mocks.verify_partial_doubles = true
|
20
|
+
end
|
21
|
+
|
22
|
+
config.filter_run :focus
|
23
|
+
config.filter_run_excluding :disabled
|
24
|
+
config.run_all_when_everything_filtered = true
|
25
|
+
|
26
|
+
config.example_status_persistence_file_path = 'spec/examples.txt'
|
27
|
+
config.disable_monkey_patching!
|
28
|
+
config.warnings = true
|
29
|
+
config.default_formatter = 'doc' if config.files_to_run.one?
|
30
|
+
config.profile_examples = 5
|
31
|
+
|
32
|
+
config.order = :random
|
33
|
+
Kernel.srand config.seed
|
34
|
+
end
|
File without changes
|
metadata
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tkxs-component-generator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- TKXS
|
8
|
+
autorequire:
|
9
|
+
bindir: executable
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-09-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: evt-casing
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: thor
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
description: " "
|
42
|
+
email: opensource@eventide-project.org
|
43
|
+
executables:
|
44
|
+
- tkxs-component-generator
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- executable/tkxs-component-generator
|
49
|
+
- lib/command_line/component_generator.rb
|
50
|
+
- lib/command_line/component_generator/commands/component.rb
|
51
|
+
- lib/command_line/component_generator/interface.rb
|
52
|
+
- source/%component_name%.gemspec.tt
|
53
|
+
- source/.circleci/config.yml
|
54
|
+
- source/.gitignore
|
55
|
+
- source/.rspec.tt
|
56
|
+
- source/.rubocop.yml.tt
|
57
|
+
- source/CHANGELOG.md
|
58
|
+
- source/Dockerfile.tt
|
59
|
+
- source/Guardfile.tt
|
60
|
+
- source/README.md.tt
|
61
|
+
- source/Rakefile.tt
|
62
|
+
- source/VERSION
|
63
|
+
- source/bin/release
|
64
|
+
- source/bin/setup.tt
|
65
|
+
- source/bin/start.tt
|
66
|
+
- source/config/pgadmin_servers.json.tt
|
67
|
+
- source/docker-compose.yml.tt
|
68
|
+
- source/gems.rb.tt
|
69
|
+
- source/lib/%component_name%.rb.tt
|
70
|
+
- source/lib/%component_name%/%entity_name%.rb.tt
|
71
|
+
- source/lib/%component_name%/consumers/commands.rb.tt
|
72
|
+
- source/lib/%component_name%/consumers/events.rb.tt
|
73
|
+
- source/lib/%component_name%/handlers/commands.rb.tt
|
74
|
+
- source/lib/%component_name%/handlers/events.rb.tt
|
75
|
+
- source/lib/%component_name%/messages/commands/.empty_directory
|
76
|
+
- source/lib/%component_name%/messages/events/.empty_directory
|
77
|
+
- source/lib/%component_name%/projection.rb.tt
|
78
|
+
- source/lib/%component_name%/start.rb.tt
|
79
|
+
- source/lib/%component_name%/store.rb.tt
|
80
|
+
- source/secrets.env.example
|
81
|
+
- source/spec/%component_name%/%component_name%_spec.rb.tt
|
82
|
+
- source/spec/spec_helper.rb.tt
|
83
|
+
- source/spec/support/.keep.tt
|
84
|
+
homepage: https://github.com/technekes/command-line-component-generator
|
85
|
+
licenses:
|
86
|
+
- MIT
|
87
|
+
metadata: {}
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 2.4.0
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
requirements: []
|
103
|
+
rubygems_version: 3.0.3
|
104
|
+
signing_key:
|
105
|
+
specification_version: 4
|
106
|
+
summary: Command line Eventide component generator
|
107
|
+
test_files: []
|