strum-pipeline 0.1.4 → 0.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5934d11a9020a020b55ae39e223df484555dcacbdb1d3c5b49aa89d49a93ae95
4
- data.tar.gz: 71e27af119c3f788ba668a7458a8aad88b132e9e249550174ccebc1c5c3ff6c1
3
+ metadata.gz: c25994d1a0501ecd92288169b12cd763065dcf263b0b61b21d572066c7fe65d6
4
+ data.tar.gz: 9b952ea27eb99f9f9f7da978411b5f461cb09be589052535a1232e91e4d19a66
5
5
  SHA512:
6
- metadata.gz: e70550e1118932b81da15c99da3505358f01da2bfc1c6aab74f3f2bfd49f7cd274b381adb09034ca7f9d2d3526235ea8210de822e104337057e2d411f3b720a5
7
- data.tar.gz: 91675d7db033165fbe449fa28ac53fd19bcf1423cd1df2b930049e5d8d37310f8b27745bc42ebe3f484cbc75629b5e401a50bd79a01796e45aa9281ab6a3a94b
6
+ metadata.gz: a50d89735a466b9f01f0cefc8b27dcfed99eb2a3025139abfb4949b96686b2514657638ae5fecd7df7bab0133a7e67f91cc91b3ed51013d9ae05f17ae46aab07
7
+ data.tar.gz: a973e1015cb8273980166649e974e5dd3b319e606c0df25d4bf7a26246c311f5689c9c86bf83117b3aba9df5ca9aa4c582ef78b9edf01c5e579e2e939c08875c
@@ -0,0 +1,17 @@
1
+ # [Choice] Ruby version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.1, 3.0, 2, 2.7, 2.6, 3-bullseye, 3.1-bullseye, 3.0-bullseye, 2-bullseye, 2.7-bullseye, 2.6-bullseye, 3-buster, 3.1-buster, 3.0-buster, 2-buster, 2.7-buster, 2.6-buster
2
+ ARG VARIANT=2-bullseye
3
+ FROM mcr.microsoft.com/vscode/devcontainers/ruby:0-${VARIANT}
4
+
5
+ # [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
6
+ ARG NODE_VERSION="none"
7
+ RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
8
+
9
+ # [Optional] Uncomment this section to install additional OS packages.
10
+ # RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
11
+ # && apt-get -y install --no-install-recommends <your-package-list-here>
12
+
13
+ # [Optional] Uncomment this line to install additional gems.
14
+ # RUN gem install <your-gem-names-here>
15
+
16
+ # [Optional] Uncomment this line to install global node packages.
17
+ # RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
@@ -0,0 +1,43 @@
1
+ # [Choice] Ruby version (use -bullseye variants on local arm64/Apple Silicon): 3, 3.1, 3.0, 2, 2.7, 2.6, 3-bullseye, 3.1-bullseye, 3.0-bullseye, 2-bullseye, 2.7-bullseye, 2.6-bullseye, 3-buster, 3.1-buster, 3.0-buster, 2-buster, 2.7-buster, 2.6-buster
2
+ ARG VARIANT=2-bullseye
3
+ FROM ruby:${VARIANT}
4
+
5
+ # Copy library scripts to execute
6
+ COPY library-scripts/*.sh library-scripts/*.env /tmp/library-scripts/
7
+
8
+ # [Option] Install zsh
9
+ ARG INSTALL_ZSH="true"
10
+ # [Option] Upgrade OS packages to their latest versions
11
+ ARG UPGRADE_PACKAGES="true"
12
+ # Install needed packages and setup non-root user. Use a separate RUN statement to add your own dependencies.
13
+ ARG USERNAME=vscode
14
+ ARG USER_UID=1000
15
+ ARG USER_GID=$USER_UID
16
+ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
17
+ # Remove imagemagick due to https://security-tracker.debian.org/tracker/CVE-2019-10131
18
+ && apt-get purge -y imagemagick imagemagick-6-common \
19
+ # Install common packages, non-root user, rvm, core build tools
20
+ && bash /tmp/library-scripts/common-debian.sh "${INSTALL_ZSH}" "${USERNAME}" "${USER_UID}" "${USER_GID}" "${UPGRADE_PACKAGES}" "true" "true" \
21
+ && bash /tmp/library-scripts/ruby-debian.sh "none" "${USERNAME}" "true" "true" \
22
+ && apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*
23
+
24
+ # [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
25
+ ARG NODE_VERSION="none"
26
+ ENV NVM_DIR=/usr/local/share/nvm
27
+ ENV NVM_SYMLINK_CURRENT=true \
28
+ PATH=${NVM_DIR}/current/bin:${PATH}
29
+ RUN bash /tmp/library-scripts/node-debian.sh "${NVM_DIR}" "${NODE_VERSION}" "${USERNAME}" \
30
+ && apt-get clean -y && rm -rf /var/lib/apt/lists/*
31
+
32
+ # Remove library scripts for final image
33
+ RUN rm -rf /tmp/library-scripts
34
+
35
+ # [Optional] Uncomment this section to install additional OS packages.
36
+ # RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
37
+ # && apt-get -y install --no-install-recommends <your-package-list-here>
38
+
39
+ # [Optional] Uncomment this line to install additional gems.
40
+ # RUN gem install <your-gem-names-here>
41
+
42
+ # [Optional] Uncomment this line to install global node packages.
43
+ # RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g <your-package-here>" 2>&1
@@ -0,0 +1,54 @@
1
+ // For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
2
+ // https://github.com/microsoft/vscode-dev-containers/tree/v0.224.3/containers/ruby
3
+ {
4
+ "name": "Ruby",
5
+ // "build": {
6
+ // "dockerfile": "Dockerfile",
7
+ // "args": {
8
+ // // Update 'VARIANT' to pick a Ruby version: 3, 3.1, 3.0, 2, 2.7, 2.6
9
+ // // Append -bullseye or -buster to pin to an OS version.
10
+ // // Use -bullseye variants on local on arm64/Apple Silicon.
11
+ // "VARIANT": "3.1",
12
+ // // Options
13
+ // "NODE_VERSION": "none"
14
+ // }
15
+ // },
16
+
17
+ "dockerComposeFile": ["docker-compose.yml"],
18
+ // "runServices": ["workspace", " redis", "rabbit"],
19
+ "service": "workspace",
20
+ "shutdownAction": "stopCompose",
21
+ "workspaceFolder": "/workspace",
22
+ "forwardPorts": [15672],
23
+
24
+ // Use this environment variable if you need to bind mount your local source code into a new container.
25
+ "remoteEnv": {
26
+ "LOCAL_WORKSPACE_FOLDER": "${localWorkspaceFolder}"
27
+ },
28
+
29
+
30
+ // Set *default* container specific settings.json values on container create.
31
+ "settings": {},
32
+
33
+ // Add the IDs of extensions you want installed when the container is created.
34
+ "extensions": [
35
+ "rebornix.Ruby"
36
+ ],
37
+
38
+ // Use 'forwardPorts' to make a list of ports inside the container available locally.
39
+ // "forwardPorts": [],
40
+
41
+ // Use 'postCreateCommand' to run commands after the container is created.
42
+ // "postCreateCommand": "ruby --version",
43
+
44
+ // Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
45
+ "remoteUser": "vscode",
46
+ "features": {
47
+ "git": "latest"
48
+ }
49
+ // ,
50
+ // "mounts": [
51
+ // "source=/home/sena/Projects/strum/strum-esb,target=/workspaces/strum-esb,type=bind"
52
+ // ]
53
+
54
+ }
@@ -0,0 +1,30 @@
1
+ version: "3.9"
2
+ services:
3
+ workspace:
4
+ # image: mcr.microsoft.com/vscode/devcontainers/ruby:0-${VARIANT}
5
+ build:
6
+ context: ..
7
+ dockerfile: .devcontainer/Dockerfile
8
+ args:
9
+ VARIANT: "3.1"
10
+ environment:
11
+ REDIS_HOST: redis
12
+ RABBIT_HOST: rabbit
13
+ REDIS_URL: redis://redis:6379
14
+ RABBITMQ_URL: amqp://guest:guest@rabbit:5672
15
+ # command: bash -c "bundle install && bundle exec rackup -o '0.0.0.0'"
16
+ command: sleep infinity
17
+ volumes:
18
+ # Update this to wherever you want VS Code to mount the folder of your project
19
+ - ..:/workspace:cached
20
+ - ../../strum-esb:/workspace/vendor/strum-esb
21
+ redis:
22
+ image: redis:alpine
23
+ rabbit:
24
+ image: rabbitmq:3.9.14-management-alpine
25
+ environment:
26
+ RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS: "-rabbit change_cluster_node_type ram"
27
+ # volumes:
28
+ # - master-node-storage:/var/lib/rabbitmq/mnesia/
29
+ ports:
30
+ - 15672:15672
data/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
  # Changelog
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [0.2.0] - 2022-03-27
6
+ ### Changed
7
+ - init step always start new pipeline
8
+ ### Fixed
9
+ - storage per thread
10
+
5
11
  ## [0.1.4] - 2021-01-11
6
12
  ### Changed
7
13
  - `strum-esb` dependency version to `~> 0.2` by [@valeriia.kolisnyk].
data/Gemfile CHANGED
@@ -5,9 +5,9 @@ source "https://rubygems.org"
5
5
  # Specify your gem's dependencies in strum-pipeline.gemspec
6
6
  gemspec
7
7
 
8
- gem "bundler", "~> 2.1.4"
8
+ gem "bundler", "~> 2"
9
9
  gem "rspec", "~> 3"
10
10
  gem "rubocop", "~> 0.90.0"
11
11
 
12
- gem "debase", "~> 0.2.4"
12
+ gem "debase", "~> 0.2.5.beta2"
13
13
  gem "ruby-debug-ide", "~> 0.7.0"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- strum-pipeline (0.1.4)
4
+ strum-pipeline (0.2.0)
5
5
  bunny (~> 2.15)
6
6
  connection_pool (~> 2.2)
7
7
  dry-configurable (~> 0.11)
@@ -10,7 +10,7 @@ PATH
10
10
  redis-objects (~> 1.5)
11
11
  singleton (~> 0.1)
12
12
  sneakers (~> 2.12)
13
- strum-esb (~> 0.2)
13
+ strum-esb (~> 0.3.1)
14
14
 
15
15
  GEM
16
16
  remote: https://rubygems.org/
@@ -20,12 +20,12 @@ GEM
20
20
  bunny (2.19.0)
21
21
  amq-protocol (~> 2.3, >= 2.3.1)
22
22
  sorted_set (~> 1, >= 1.0.2)
23
- concurrent-ruby (1.1.9)
23
+ concurrent-ruby (1.1.10)
24
24
  connection_pool (2.2.5)
25
- debase (0.2.4.1)
26
- debase-ruby_core_source (>= 0.10.2)
27
- debase-ruby_core_source (0.10.12)
28
- diff-lcs (1.4.4)
25
+ debase (0.2.5.beta2)
26
+ debase-ruby_core_source (>= 0.10.12)
27
+ debase-ruby_core_source (0.10.14)
28
+ diff-lcs (1.5.0)
29
29
  dry-configurable (0.12.1)
30
30
  concurrent-ruby (~> 1.0)
31
31
  dry-core (~> 0.5, >= 0.5.0)
@@ -33,30 +33,30 @@ GEM
33
33
  concurrent-ruby (~> 1.0)
34
34
  dry-inflector (0.2.1)
35
35
  json (2.6.1)
36
- parallel (1.20.1)
37
- parser (3.0.1.0)
36
+ parallel (1.22.1)
37
+ parser (3.1.1.0)
38
38
  ast (~> 2.4.1)
39
- rainbow (3.0.0)
39
+ rainbow (3.1.1)
40
40
  rake (12.3.3)
41
- rbtree (0.4.4)
42
- redis (4.5.1)
41
+ rbtree (0.4.5)
42
+ redis (4.6.0)
43
43
  redis-objects (1.5.1)
44
44
  redis (~> 4.2)
45
- regexp_parser (2.1.1)
45
+ regexp_parser (2.2.1)
46
46
  rexml (3.2.5)
47
- rspec (3.10.0)
48
- rspec-core (~> 3.10.0)
49
- rspec-expectations (~> 3.10.0)
50
- rspec-mocks (~> 3.10.0)
51
- rspec-core (3.10.1)
52
- rspec-support (~> 3.10.0)
53
- rspec-expectations (3.10.1)
47
+ rspec (3.11.0)
48
+ rspec-core (~> 3.11.0)
49
+ rspec-expectations (~> 3.11.0)
50
+ rspec-mocks (~> 3.11.0)
51
+ rspec-core (3.11.0)
52
+ rspec-support (~> 3.11.0)
53
+ rspec-expectations (3.11.0)
54
54
  diff-lcs (>= 1.2.0, < 2.0)
55
- rspec-support (~> 3.10.0)
56
- rspec-mocks (3.10.2)
55
+ rspec-support (~> 3.11.0)
56
+ rspec-mocks (3.11.0)
57
57
  diff-lcs (>= 1.2.0, < 2.0)
58
- rspec-support (~> 3.10.0)
59
- rspec-support (3.10.2)
58
+ rspec-support (~> 3.11.0)
59
+ rspec-support (3.11.0)
60
60
  rubocop (0.90.0)
61
61
  parallel (~> 1.10)
62
62
  parser (>= 2.7.1.1)
@@ -68,7 +68,7 @@ GEM
68
68
  unicode-display_width (>= 1.4.0, < 2.0)
69
69
  rubocop-ast (0.8.0)
70
70
  parser (>= 2.7.1.5)
71
- ruby-debug-ide (0.7.2)
71
+ ruby-debug-ide (0.7.3)
72
72
  rake (>= 0.8.1)
73
73
  ruby-progressbar (1.11.0)
74
74
  serverengine (2.1.1)
@@ -85,25 +85,26 @@ GEM
85
85
  sorted_set (1.0.3)
86
86
  rbtree
87
87
  set (~> 1.0)
88
- strum-esb (0.2.0)
88
+ strum-esb (0.3.1)
89
89
  bunny (~> 2.15)
90
90
  connection_pool (~> 2.2.2)
91
91
  dry-configurable (~> 0.12.1)
92
+ dry-inflector (~> 0.2.1)
92
93
  json (~> 2.3)
93
94
  sneakers (~> 2.12)
94
- thor (1.1.0)
95
- unicode-display_width (1.7.0)
95
+ thor (1.2.1)
96
+ unicode-display_width (1.8.0)
96
97
 
97
98
  PLATFORMS
98
99
  ruby
99
100
 
100
101
  DEPENDENCIES
101
- bundler (~> 2.1.4)
102
- debase (~> 0.2.4)
102
+ bundler (~> 2)
103
+ debase (~> 0.2.5.beta2)
103
104
  rspec (~> 3)
104
105
  rubocop (~> 0.90.0)
105
106
  ruby-debug-ide (~> 0.7.0)
106
107
  strum-pipeline!
107
108
 
108
109
  BUNDLED WITH
109
- 2.1.4
110
+ 2.3.3
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Strum
4
4
  module Pipeline
5
- VERSION = "0.1.4"
5
+ VERSION = "0.2.0"
6
6
  end
7
7
  end
@@ -34,14 +34,32 @@ module Strum
34
34
  base.class_eval do
35
35
  include Strum::Esb::Handler
36
36
 
37
- def after_headers_hook
37
+ attr_accessor :handler_bind
38
+
39
+ def after_headers_hook(bind)
40
+ @handler_bind = bind
41
+ setup_pipeline
42
+ end
43
+
44
+ def setup_pipeline
38
45
  Thread.current[:pipeline] ||= self.class.pipeline_name
39
- Thread.current[:pipeline_id] ||= SecureRandom.hex(10)
46
+ Thread.current[:pipeline_id] = SecureRandom.hex(10) if init_step?
47
+ end
48
+
49
+ def init_step?
50
+ if eval("action", handler_bind)
51
+ self.class.inits.include?(["action", eval("action", handler_bind), eval("resource", handler_bind)].join("-"))
52
+ elsif eval("event", handler_bind)
53
+ self.class.inits.include?(["event", eval("resource", handler_bind), eval("event", handler_bind), eval("state", handler_bind)].join("-"))
54
+ elsif eval("info", handler_bind)
55
+ self.class.inits.include?(["info", eval("info", handler_bind)].join("-"))
56
+ elsif eval("notice", handler_bind)
57
+ self.class.inits.include?(["notice", eval("resource", handler_bind), eval("notice", handler_bind)].join("-"))
58
+ end
40
59
  end
41
60
  end
42
61
 
43
62
  base.extend ClassMethods
44
- # Classes << base if base.is_a? Class
45
63
  end
46
64
 
47
65
  # class methods
@@ -50,22 +68,22 @@ module Strum
50
68
  Strum::Pipeline.config.ttl = interval
51
69
  end
52
70
 
71
+ def inits
72
+ @inits ||= []
73
+ end
74
+
53
75
  def init(message_type, message_binding, handler = nil)
54
- bind_to pipeline_name, message_type, message_binding, handler
76
+ bind_to(pipeline_name, message_type, message_binding, handler)
77
+ inits << handler_key(message_type, message_binding)
55
78
  end
56
79
 
57
80
  def step(message_type, message_binding, handler = nil)
58
- bindings ||= (queue_opts && queue_opts[:bindings]) || {}
59
- bindings[:pipeline] ||= {}
60
- bindings[:pipeline][:name] = pipeline_name
61
- bindings[:pipeline][message_type] ||= []
62
- bindings[:pipeline][message_type] << message_binding
63
- from_queue pipeline_name, bindings: bindings
64
- _, *msg = Strum::Esb::Functions.public_send("#{message_type}_explain", message_binding)
65
- @handlers ||= {}
66
- params = msg.map{ |param| param&.to_s.gsub(/[^a-zA-Z0-9]/, "_")&.downcase }
67
- handler_key = ([message_type] + params).join("-")
68
- @handlers[handler_key] = handler.to_s if handler
81
+ bind_to(pipeline_name, message_type, message_binding, handler) do |bindings|
82
+ bindings[:pipeline] ||= {}
83
+ bindings[:pipeline][:name] = pipeline_name
84
+ bindings[:pipeline][message_type] ||= []
85
+ bindings[:pipeline][message_type] << message_binding
86
+ end
69
87
  end
70
88
 
71
89
  def pipeline_name
@@ -80,7 +98,7 @@ module Strum
80
98
  end
81
99
 
82
100
  def storage
83
- @storage ||= Strum::Pipeline::Storage.new(pipeline_key, Strum::Pipeline.config.ttl)
101
+ Thread.current[:storage] ||= Strum::Pipeline::Storage.new(pipeline_key, Strum::Pipeline.config.ttl)
84
102
  end
85
103
 
86
104
  def pipeline_key
@@ -38,5 +38,5 @@ Gem::Specification.new do |spec|
38
38
  spec.add_dependency "singleton", "~> 0.1"
39
39
  spec.add_dependency "sneakers", "~> 2.12"
40
40
 
41
- spec.add_dependency "strum-esb", "~> 0.2"
41
+ spec.add_dependency "strum-esb", "~> 0.3.1"
42
42
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strum-pipeline
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Serhiy Nazarov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-11 00:00:00.000000000 Z
11
+ date: 2022-03-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bunny
@@ -128,14 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: '0.2'
131
+ version: 0.3.1
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: '0.2'
138
+ version: 0.3.1
139
139
  description:
140
140
  email:
141
141
  - sn@nazarov.com.ua
@@ -143,6 +143,10 @@ executables: []
143
143
  extensions: []
144
144
  extra_rdoc_files: []
145
145
  files:
146
+ - ".devcontainer/Dockerfile"
147
+ - ".devcontainer/base.Dockerfile"
148
+ - ".devcontainer/devcontainer.json"
149
+ - ".devcontainer/docker-compose.yml"
146
150
  - ".gitignore"
147
151
  - ".gitlab-ci.yml"
148
152
  - ".rspec"