strum-pipeline 0.1.4 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5934d11a9020a020b55ae39e223df484555dcacbdb1d3c5b49aa89d49a93ae95
4
- data.tar.gz: 71e27af119c3f788ba668a7458a8aad88b132e9e249550174ccebc1c5c3ff6c1
3
+ metadata.gz: e892a52a297b185245dfabe8c717dcbeaedc01fddc9ef15940b0d9cce9a8c466
4
+ data.tar.gz: 59c8c2dd248bbd629bd4edb4b179a965bc08ece2aa0342d4bf179498ebcf20a6
5
5
  SHA512:
6
- metadata.gz: e70550e1118932b81da15c99da3505358f01da2bfc1c6aab74f3f2bfd49f7cd274b381adb09034ca7f9d2d3526235ea8210de822e104337057e2d411f3b720a5
7
- data.tar.gz: 91675d7db033165fbe449fa28ac53fd19bcf1423cd1df2b930049e5d8d37310f8b27745bc42ebe3f484cbc75629b5e401a50bd79a01796e45aa9281ab6a3a94b
6
+ metadata.gz: 1b24214f5ff1d39ea96e6071ecd80891c605055c6168f787e79844b8672bc4c5cefabd6ff9965155b2f77e695bb9e94f7faeb26cb5e77facd9969bcb9e2489fa
7
+ data.tar.gz: 58803567d51e7fb44c5da6c4b2dd7c630f83ea9d027ed3add32a748041706bd3956ecc791652c50bc5e4a884502130c9f23fc34a4a0979b383ebdf8c4807046d
@@ -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,16 @@
2
2
  # Changelog
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ ## [0.2.1] - 2023-01-11
6
+ ### Changed
7
+ - `strum-esb` dependency version to `~> 0.4` by [@valeriia.kolisnyk].
8
+
9
+ ## [0.2.0] - 2022-03-27
10
+ ### Changed
11
+ - init step always start new pipeline
12
+ ### Fixed
13
+ - storage per thread
14
+
5
15
  ## [0.1.4] - 2021-01-11
6
16
  ### Changed
7
17
  - `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.1)
5
5
  bunny (~> 2.15)
6
6
  connection_pool (~> 2.2)
7
7
  dry-configurable (~> 0.11)
@@ -10,53 +10,57 @@ 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.4)
14
14
 
15
15
  GEM
16
16
  remote: https://rubygems.org/
17
17
  specs:
18
18
  amq-protocol (2.3.2)
19
19
  ast (2.4.2)
20
- bunny (2.19.0)
20
+ bunny (2.20.3)
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.2.2)
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 (3.2.0)
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)
32
- dry-core (0.7.1)
32
+ dry-core (0.9.1)
33
33
  concurrent-ruby (~> 1.0)
34
+ zeitwerk (~> 2.6)
34
35
  dry-inflector (0.2.1)
35
- json (2.6.1)
36
- parallel (1.20.1)
37
- parser (3.0.1.0)
36
+ json (2.6.3)
37
+ parallel (1.23.0)
38
+ parser (3.2.2.0)
38
39
  ast (~> 2.4.1)
39
- rainbow (3.0.0)
40
+ rainbow (3.1.1)
40
41
  rake (12.3.3)
41
- rbtree (0.4.4)
42
- redis (4.5.1)
43
- redis-objects (1.5.1)
44
- redis (~> 4.2)
45
- regexp_parser (2.1.1)
42
+ rbtree (0.4.6)
43
+ redis (5.0.6)
44
+ redis-client (>= 0.9.0)
45
+ redis-client (0.14.1)
46
+ connection_pool
47
+ redis-objects (1.7.0)
48
+ redis
49
+ regexp_parser (2.8.0)
46
50
  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)
51
+ rspec (3.12.0)
52
+ rspec-core (~> 3.12.0)
53
+ rspec-expectations (~> 3.12.0)
54
+ rspec-mocks (~> 3.12.0)
55
+ rspec-core (3.12.2)
56
+ rspec-support (~> 3.12.0)
57
+ rspec-expectations (3.12.3)
54
58
  diff-lcs (>= 1.2.0, < 2.0)
55
- rspec-support (~> 3.10.0)
56
- rspec-mocks (3.10.2)
59
+ rspec-support (~> 3.12.0)
60
+ rspec-mocks (3.12.5)
57
61
  diff-lcs (>= 1.2.0, < 2.0)
58
- rspec-support (~> 3.10.0)
59
- rspec-support (3.10.2)
62
+ rspec-support (~> 3.12.0)
63
+ rspec-support (3.12.0)
60
64
  rubocop (0.90.0)
61
65
  parallel (~> 1.10)
62
66
  parser (>= 2.7.1.1)
@@ -68,12 +72,12 @@ GEM
68
72
  unicode-display_width (>= 1.4.0, < 2.0)
69
73
  rubocop-ast (0.8.0)
70
74
  parser (>= 2.7.1.5)
71
- ruby-debug-ide (0.7.2)
75
+ ruby-debug-ide (0.7.3)
72
76
  rake (>= 0.8.1)
73
- ruby-progressbar (1.11.0)
77
+ ruby-progressbar (1.13.0)
74
78
  serverengine (2.1.1)
75
79
  sigdump (~> 0.2.2)
76
- set (1.0.2)
80
+ set (1.0.3)
77
81
  sigdump (0.2.4)
78
82
  singleton (0.1.1)
79
83
  sneakers (2.12.0)
@@ -85,25 +89,27 @@ GEM
85
89
  sorted_set (1.0.3)
86
90
  rbtree
87
91
  set (~> 1.0)
88
- strum-esb (0.2.0)
92
+ strum-esb (0.4.1)
89
93
  bunny (~> 2.15)
90
94
  connection_pool (~> 2.2.2)
91
95
  dry-configurable (~> 0.12.1)
96
+ dry-inflector (~> 0.2.1)
92
97
  json (~> 2.3)
93
98
  sneakers (~> 2.12)
94
- thor (1.1.0)
95
- unicode-display_width (1.7.0)
99
+ thor (1.2.1)
100
+ unicode-display_width (1.8.0)
101
+ zeitwerk (2.6.7)
96
102
 
97
103
  PLATFORMS
98
104
  ruby
99
105
 
100
106
  DEPENDENCIES
101
- bundler (~> 2.1.4)
102
- debase (~> 0.2.4)
107
+ bundler (~> 2)
108
+ debase (~> 0.2.5.beta2)
103
109
  rspec (~> 3)
104
110
  rubocop (~> 0.90.0)
105
111
  ruby-debug-ide (~> 0.7.0)
106
112
  strum-pipeline!
107
113
 
108
114
  BUNDLED WITH
109
- 2.1.4
115
+ 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.1"
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.4"
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.1
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: 2023-04-20 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.4'
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.4'
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"