shoryuken-template 0.3.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/.rubocop.yml +60 -0
- data/CHANGELOG.md +74 -0
- data/CONTRIBUTING.md +98 -0
- data/INSTALLATION.md +361 -0
- data/LICENSE.txt +21 -0
- data/PUBLISHING.md +111 -0
- data/Procfile.example +13 -0
- data/QUICKSTART.md +156 -0
- data/README.md +393 -0
- data/RUBY_3.4_FEATURES.md +341 -0
- data/Rakefile +31 -0
- data/UPGRADE_GUIDE.md +293 -0
- data/examples/configuration_example.rb +47 -0
- data/examples/fifo_worker_example.rb +60 -0
- data/examples/heroku_setup.rb +59 -0
- data/examples/parallel_worker_example.rb +49 -0
- data/examples/standard_worker_example.rb +38 -0
- data/examples/worker_specific_config_example.rb +134 -0
- data/lib/shoryuken/template/configuration.rb +133 -0
- data/lib/shoryuken/template/error_handler.rb +118 -0
- data/lib/shoryuken/template/logger.rb +92 -0
- data/lib/shoryuken/template/version.rb +7 -0
- data/lib/shoryuken/template/workers/base_worker.rb +72 -0
- data/lib/shoryuken/template/workers/fifo_worker.rb +84 -0
- data/lib/shoryuken/template/workers/parallel_worker.rb +120 -0
- data/lib/shoryuken/template/workers/standard_worker.rb +44 -0
- data/lib/shoryuken/template.rb +16 -0
- data/shoryuken.yml.example +43 -0
- data/sig/shoryuken/template.rbs +6 -0
- metadata +192 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: a840c133e1ee880eaf5f787ddaf90d2032a2a8d84488cf03f4b3307c953a347c
|
|
4
|
+
data.tar.gz: '0358b4aa471be05f8dc68321781c8b0432049927ccc778a416aa71f232666363'
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 5e18c4ee65d08756d988a70e7ef36682f55417dabfe6429063d9eb53c52542cd4fe141f6a3ca6c7425b44c9d36e5a876ec1e59819a959fec275dd9d597ba21fb
|
|
7
|
+
data.tar.gz: ad1f56ed6ca4810a8c5e36a5f70a1643b363b7691b7bfbc189fde835aa7aedb6d4a25a4a3426b765d7b5f90b0f4faf22f42a1926adca056416b4c3a0f61d64c3
|
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
AllCops:
|
|
2
|
+
TargetRubyVersion: 3.4
|
|
3
|
+
NewCops: enable
|
|
4
|
+
SuggestExtensions: false
|
|
5
|
+
Exclude:
|
|
6
|
+
- 'vendor/**/*'
|
|
7
|
+
- 'bin/**/*'
|
|
8
|
+
- 'sig/**/*'
|
|
9
|
+
- 'node_modules/**/*'
|
|
10
|
+
|
|
11
|
+
require:
|
|
12
|
+
- rubocop-rake
|
|
13
|
+
- rubocop-minitest
|
|
14
|
+
|
|
15
|
+
Style/StringLiterals:
|
|
16
|
+
Enabled: true
|
|
17
|
+
EnforcedStyle: single_quotes
|
|
18
|
+
|
|
19
|
+
Style/StringLiteralsInInterpolation:
|
|
20
|
+
Enabled: true
|
|
21
|
+
EnforcedStyle: single_quotes
|
|
22
|
+
|
|
23
|
+
Layout/LineLength:
|
|
24
|
+
Max: 120
|
|
25
|
+
|
|
26
|
+
Metrics/MethodLength:
|
|
27
|
+
Max: 30
|
|
28
|
+
|
|
29
|
+
Metrics/BlockLength:
|
|
30
|
+
Exclude:
|
|
31
|
+
- 'test/**/*'
|
|
32
|
+
- 'spec/**/*'
|
|
33
|
+
- 'examples/**/*'
|
|
34
|
+
|
|
35
|
+
Metrics/ClassLength:
|
|
36
|
+
Max: 150
|
|
37
|
+
|
|
38
|
+
Style/Documentation:
|
|
39
|
+
Enabled: false
|
|
40
|
+
|
|
41
|
+
Layout/EmptyLinesAroundAttributeAccessor:
|
|
42
|
+
Enabled: true
|
|
43
|
+
|
|
44
|
+
Layout/SpaceAroundMethodCallOperator:
|
|
45
|
+
Enabled: true
|
|
46
|
+
|
|
47
|
+
Lint/RaiseException:
|
|
48
|
+
Enabled: true
|
|
49
|
+
|
|
50
|
+
Lint/StructNewOverride:
|
|
51
|
+
Enabled: true
|
|
52
|
+
|
|
53
|
+
Style/HashEachMethods:
|
|
54
|
+
Enabled: true
|
|
55
|
+
|
|
56
|
+
Style/HashTransformKeys:
|
|
57
|
+
Enabled: true
|
|
58
|
+
|
|
59
|
+
Style/HashTransformValues:
|
|
60
|
+
Enabled: true
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
## [Unreleased]
|
|
2
|
+
|
|
3
|
+
## [0.3.0] - 2026-01-16
|
|
4
|
+
|
|
5
|
+
### Atualizado
|
|
6
|
+
|
|
7
|
+
- 📦 **Ruby**: Versão mínima atualizada de 3.3.0 para **3.4.2**
|
|
8
|
+
- 📦 **Shoryuken**: Dependência corrigida para ">= 6.0", "< 8.0" (compatível com versões atuais)
|
|
9
|
+
- ⚡ **Performance**: Aproveita as melhorias de performance do Ruby 3.4
|
|
10
|
+
- 🔧 **RuboCop**: Target atualizado para Ruby 3.4
|
|
11
|
+
|
|
12
|
+
### Melhorias do Ruby 3.4
|
|
13
|
+
|
|
14
|
+
Ruby 3.4 traz diversas melhorias de performance e novos recursos:
|
|
15
|
+
- 🚀 **YJIT aprimorado**: ~20% mais rápido em média
|
|
16
|
+
- 💾 **Garbage Collector otimizado**: Menor uso de memória
|
|
17
|
+
- ⚡ **Prism Parser**: Novo parser padrão, mais rápido
|
|
18
|
+
- 🔒 **Fiber Scheduler melhorado**: Melhor concorrência
|
|
19
|
+
- 📊 **Improved Pattern Matching**: Sintaxe ainda mais poderosa
|
|
20
|
+
|
|
21
|
+
## [0.2.0] - 2026-01-16
|
|
22
|
+
|
|
23
|
+
### Atualizado
|
|
24
|
+
|
|
25
|
+
- 📦 **Ruby**: Versão mínima atualizada de 3.1.0 para 3.3.0
|
|
26
|
+
- 📦 **Shoryuken**: Atualizado de ~> 6.0 para ~> 7.0
|
|
27
|
+
- 📦 **Concurrent-ruby**: Atualizado de ~> 1.2 para ~> 1.3
|
|
28
|
+
- 📦 **Gems de desenvolvimento**: Todas atualizadas para versões mais recentes
|
|
29
|
+
- 💎 **Sintaxe moderna do Ruby 3.3**:
|
|
30
|
+
- Uso de numbered parameters (`_1`)
|
|
31
|
+
- Hash shorthand syntax (`key:` em vez de `key: key`)
|
|
32
|
+
- Keyword arguments melhorados (`**context`)
|
|
33
|
+
- Pattern matching com `case/in`
|
|
34
|
+
- Uso de `dig` para navegação segura em hashes
|
|
35
|
+
|
|
36
|
+
### Adicionado
|
|
37
|
+
|
|
38
|
+
- 🔒 Thread-safety melhorada com Mutex na configuração
|
|
39
|
+
- 📝 Licença MIT explícita
|
|
40
|
+
- 📚 Badges no README
|
|
41
|
+
- 🧪 Suporte a rubocop-rake e rubocop-minitest
|
|
42
|
+
|
|
43
|
+
### Melhorado
|
|
44
|
+
|
|
45
|
+
- ⚡ Performance: Shutdown de pools de threads otimizado
|
|
46
|
+
- 🧹 Code cleanup: Métodos privados extraídos para melhor manutenção
|
|
47
|
+
- 🔍 Type safety: Melhor validação de parâmetros
|
|
48
|
+
|
|
49
|
+
## [0.1.0] - 2026-01-16
|
|
50
|
+
|
|
51
|
+
### Adicionado
|
|
52
|
+
|
|
53
|
+
- 🎉 Release inicial da gem Shoryuken Template
|
|
54
|
+
- ✨ Worker Padrão (StandardWorker) para processamento simples de mensagens
|
|
55
|
+
- ✨ Worker Paralelo (ParallelWorker) para processamento em batch com threads
|
|
56
|
+
- ✨ Worker FIFO (FifoWorker) para processamento sequencial
|
|
57
|
+
- ⚙️ Sistema de configuração flexível com suporte a variáveis de ambiente
|
|
58
|
+
- ⚙️ Configuração de pool de threads e timeout específica por worker
|
|
59
|
+
- 📝 Sistema de logging estruturado em formato JSON
|
|
60
|
+
- 🔄 Tratamento de erros robusto com retry automático e backoff exponencial
|
|
61
|
+
- ⏱️ Timeout configurável por thread (global ou por worker)
|
|
62
|
+
- 🧵 Pool de threads configurável usando concurrent-ruby (global ou por worker)
|
|
63
|
+
- 🚀 Otimizações específicas para deploy no Heroku
|
|
64
|
+
- 📚 Documentação completa com exemplos de uso
|
|
65
|
+
- 🧪 Exemplos práticos de cada tipo de worker
|
|
66
|
+
- 🔧 Arquivos de configuração exemplo (shoryuken.yml, Procfile)
|
|
67
|
+
|
|
68
|
+
### Funcionalidades
|
|
69
|
+
|
|
70
|
+
- Graceful shutdown com limpeza de todos os pools de threads
|
|
71
|
+
- Suporte a error handlers customizados
|
|
72
|
+
- Logging contextualizado por worker e mensagem
|
|
73
|
+
- Validação de configurações (global e por worker)
|
|
74
|
+
- Pools de threads dedicados por worker quando necessário
|
data/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
# Contribuindo para Shoryuken Template
|
|
2
|
+
|
|
3
|
+
Obrigado por considerar contribuir para o Shoryuken Template! 🎉
|
|
4
|
+
|
|
5
|
+
## Como Contribuir
|
|
6
|
+
|
|
7
|
+
### Reportando Bugs
|
|
8
|
+
|
|
9
|
+
Se você encontrou um bug, por favor abra uma issue incluindo:
|
|
10
|
+
|
|
11
|
+
- Descrição clara do problema
|
|
12
|
+
- Passos para reproduzir
|
|
13
|
+
- Comportamento esperado vs atual
|
|
14
|
+
- Versão da gem e Ruby
|
|
15
|
+
- Stack trace (se aplicável)
|
|
16
|
+
|
|
17
|
+
### Sugerindo Melhorias
|
|
18
|
+
|
|
19
|
+
Para sugestões de novas funcionalidades ou melhorias:
|
|
20
|
+
|
|
21
|
+
- Abra uma issue descrevendo a melhoria
|
|
22
|
+
- Explique o caso de uso
|
|
23
|
+
- Se possível, mostre exemplos de uso
|
|
24
|
+
|
|
25
|
+
### Pull Requests
|
|
26
|
+
|
|
27
|
+
1. Fork o repositório
|
|
28
|
+
2. Crie uma branch para sua feature (`git checkout -b feature/minha-feature`)
|
|
29
|
+
3. Faça suas alterações
|
|
30
|
+
4. Adicione testes para novas funcionalidades
|
|
31
|
+
5. Execute os testes: `bundle exec rake test`
|
|
32
|
+
6. Execute o linter: `bundle exec rubocop`
|
|
33
|
+
7. Commit suas mudanças (`git commit -am 'Adiciona minha feature'`)
|
|
34
|
+
8. Push para a branch (`git push origin feature/minha-feature`)
|
|
35
|
+
9. Abra um Pull Request
|
|
36
|
+
|
|
37
|
+
## Diretrizes de Código
|
|
38
|
+
|
|
39
|
+
### Style Guide
|
|
40
|
+
|
|
41
|
+
- Seguimos o [Ruby Style Guide](https://rubystyle.guide/)
|
|
42
|
+
- Use RuboCop para verificar o estilo: `bundle exec rubocop`
|
|
43
|
+
- Mantenha métodos pequenos e focados
|
|
44
|
+
- Documente código complexo
|
|
45
|
+
|
|
46
|
+
### Testes
|
|
47
|
+
|
|
48
|
+
- Adicione testes para todas as novas funcionalidades
|
|
49
|
+
- Mantenha cobertura de testes alta
|
|
50
|
+
- Use nomes descritivos para testes
|
|
51
|
+
- Execute `bundle exec rake test` antes de commitar
|
|
52
|
+
|
|
53
|
+
### Commits
|
|
54
|
+
|
|
55
|
+
- Use mensagens de commit descritivas
|
|
56
|
+
- Prefira múltiplos commits pequenos a um commit grande
|
|
57
|
+
- Formato sugerido:
|
|
58
|
+
```
|
|
59
|
+
[tipo] Resumo breve
|
|
60
|
+
|
|
61
|
+
Descrição detalhada do que foi mudado e por quê.
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Tipos: `feat`, `fix`, `docs`, `style`, `refactor`, `test`, `chore`
|
|
65
|
+
|
|
66
|
+
## Configurando o Ambiente de Desenvolvimento
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
# Clone o repositório
|
|
70
|
+
git clone https://github.com/sousmile/shoryuken-template.git
|
|
71
|
+
cd shoryuken-template
|
|
72
|
+
|
|
73
|
+
# Instale as dependências
|
|
74
|
+
bundle install
|
|
75
|
+
|
|
76
|
+
# Execute os testes
|
|
77
|
+
bundle exec rake test
|
|
78
|
+
|
|
79
|
+
# Execute o linter
|
|
80
|
+
bundle exec rubocop
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Processo de Review
|
|
84
|
+
|
|
85
|
+
1. Todos os PRs serão revisados por um mantenedor
|
|
86
|
+
2. Mudanças podem ser solicitadas
|
|
87
|
+
3. Uma vez aprovado, o PR será merged
|
|
88
|
+
4. Releases seguem [Semantic Versioning](https://semver.org/)
|
|
89
|
+
|
|
90
|
+
## Código de Conduta
|
|
91
|
+
|
|
92
|
+
Este projeto segue um código de conduta. Ao participar, você concorda em manter um ambiente respeitoso e acolhedor para todos.
|
|
93
|
+
|
|
94
|
+
## Dúvidas?
|
|
95
|
+
|
|
96
|
+
Sinta-se livre para abrir uma issue ou entrar em contato através de andrade.rmn@gmail.com
|
|
97
|
+
|
|
98
|
+
Obrigado pela contribuição! 🚀
|
data/INSTALLATION.md
ADDED
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
# 📦 Guia de Instalação
|
|
2
|
+
|
|
3
|
+
Este guia mostra diferentes formas de instalar e usar a gem `shoryuken-template`.
|
|
4
|
+
|
|
5
|
+
## 🌐 Instalação via Git (Recomendado) ⭐
|
|
6
|
+
|
|
7
|
+
Esta é a forma recomendada atualmente:
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
# Gemfile - Usando uma versão específica (tag)
|
|
11
|
+
gem 'shoryuken-template',
|
|
12
|
+
git: 'https://github.com/sousmile/shoryuken-template.git',
|
|
13
|
+
tag: 'v0.3.0'
|
|
14
|
+
|
|
15
|
+
# OU usando sempre a última versão
|
|
16
|
+
gem 'shoryuken-template',
|
|
17
|
+
git: 'https://github.com/sousmile/shoryuken-template.git',
|
|
18
|
+
branch: 'master'
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
E execute:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
bundle install
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
**Vantagens:**
|
|
28
|
+
- ✅ Sempre atualizado
|
|
29
|
+
- ✅ Funciona no Heroku e qualquer servidor
|
|
30
|
+
- ✅ Não depende de publicação no RubyGems
|
|
31
|
+
|
|
32
|
+
## 🌐 Instalação via RubyGems (Em breve)
|
|
33
|
+
|
|
34
|
+
Quando a gem estiver publicada no RubyGems:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
gem install shoryuken-template
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Ou adicione ao seu `Gemfile`:
|
|
41
|
+
|
|
42
|
+
```ruby
|
|
43
|
+
gem 'shoryuken-template', '~> 0.3.0'
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
E execute:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
bundle install
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## 💻 Instalação Local (Desenvolvimento)
|
|
53
|
+
|
|
54
|
+
### Método 1: Usando Rake Task (Recomendado)
|
|
55
|
+
|
|
56
|
+
No diretório da gem:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
# Instala a gem localmente
|
|
60
|
+
rake install_local
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Isso vai:
|
|
64
|
+
1. ✅ Fazer build da gem
|
|
65
|
+
2. ✅ Instalar localmente
|
|
66
|
+
3. ✅ Limpar arquivos temporários
|
|
67
|
+
|
|
68
|
+
Agora você pode usar em qualquer projeto:
|
|
69
|
+
|
|
70
|
+
```ruby
|
|
71
|
+
# Gemfile do seu projeto
|
|
72
|
+
gem 'shoryuken-template'
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Método 2: Build e Install Manual
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
# 1. Build da gem
|
|
79
|
+
gem build shoryuken-template.gemspec
|
|
80
|
+
|
|
81
|
+
# 2. Install local
|
|
82
|
+
gem install shoryuken-template-0.2.0.gem --local
|
|
83
|
+
|
|
84
|
+
# 3. Cleanup (opcional)
|
|
85
|
+
rm shoryuken-template-0.2.0.gem
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
### Método 3: Usando Path no Gemfile
|
|
89
|
+
|
|
90
|
+
Se você está desenvolvendo a gem e quer testar mudanças em tempo real:
|
|
91
|
+
|
|
92
|
+
```ruby
|
|
93
|
+
# Gemfile do seu projeto
|
|
94
|
+
gem 'shoryuken-template', path: '/caminho/para/shoryuken-template'
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Ou usando path relativo:
|
|
98
|
+
|
|
99
|
+
```ruby
|
|
100
|
+
gem 'shoryuken-template', path: '../shoryuken-template'
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
**Vantagens:**
|
|
104
|
+
- ✅ Mudanças na gem aparecem imediatamente
|
|
105
|
+
- ✅ Não precisa reinstalar a cada mudança
|
|
106
|
+
- ✅ Ideal para desenvolvimento
|
|
107
|
+
|
|
108
|
+
**Desvantagens:**
|
|
109
|
+
- ❌ Não funciona em produção
|
|
110
|
+
- ❌ Path deve existir em todas as máquinas
|
|
111
|
+
|
|
112
|
+
### Método 4: Usando Git no Gemfile
|
|
113
|
+
|
|
114
|
+
Se a gem está em um repositório Git:
|
|
115
|
+
|
|
116
|
+
```ruby
|
|
117
|
+
# Gemfile do seu projeto
|
|
118
|
+
gem 'shoryuken-template', git: 'https://github.com/sousmile/shoryuken-template.git'
|
|
119
|
+
|
|
120
|
+
# Ou uma branch específica
|
|
121
|
+
gem 'shoryuken-template', git: 'https://github.com/sousmile/shoryuken-template.git', branch: 'develop'
|
|
122
|
+
|
|
123
|
+
# Ou um commit específico
|
|
124
|
+
gem 'shoryuken-template', git: 'https://github.com/sousmile/shoryuken-template.git', ref: 'abc123'
|
|
125
|
+
|
|
126
|
+
# Ou uma tag específica
|
|
127
|
+
gem 'shoryuken-template', git: 'https://github.com/sousmile/shoryuken-template.git', tag: 'v0.2.0'
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## 🔍 Verificando a Instalação
|
|
131
|
+
|
|
132
|
+
Depois de instalar, verifique se está funcionando:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
# Verifica se a gem está instalada
|
|
136
|
+
gem list shoryuken-template
|
|
137
|
+
|
|
138
|
+
# Abre o console Ruby e testa
|
|
139
|
+
irb
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
```ruby
|
|
143
|
+
require 'shoryuken/template'
|
|
144
|
+
|
|
145
|
+
# Verifica a versão
|
|
146
|
+
Shoryuken::Template::VERSION
|
|
147
|
+
# => "0.2.0"
|
|
148
|
+
|
|
149
|
+
# Testa a configuração
|
|
150
|
+
Shoryuken::Template.configure do |config|
|
|
151
|
+
config.thread_pool_size = 10
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
puts "✅ Gem funcionando!"
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## 🚀 Uso em um Novo Projeto
|
|
158
|
+
|
|
159
|
+
### 1. Crie um novo projeto
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
mkdir meu-projeto-shoryuken
|
|
163
|
+
cd meu-projeto-shoryuken
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
### 2. Crie um Gemfile
|
|
167
|
+
|
|
168
|
+
```ruby
|
|
169
|
+
# Gemfile
|
|
170
|
+
source 'https://rubygems.org'
|
|
171
|
+
|
|
172
|
+
ruby '3.4.2'
|
|
173
|
+
|
|
174
|
+
gem 'shoryuken-template'
|
|
175
|
+
|
|
176
|
+
# Ou usando path local para desenvolvimento
|
|
177
|
+
# gem 'shoryuken-template', path: '../shoryuken-template'
|
|
178
|
+
|
|
179
|
+
# Ou usando Git
|
|
180
|
+
# gem 'shoryuken-template', git: 'https://github.com/sousmile/shoryuken-template.git'
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
### 3. Instale as dependências
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
bundle install
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### 4. Crie um worker
|
|
190
|
+
|
|
191
|
+
```ruby
|
|
192
|
+
# app/workers/my_worker.rb
|
|
193
|
+
require 'shoryuken/template'
|
|
194
|
+
|
|
195
|
+
class MyWorker
|
|
196
|
+
include Shoryuken::Template::Workers::StandardWorker
|
|
197
|
+
|
|
198
|
+
worker_options queue: 'my-queue'
|
|
199
|
+
|
|
200
|
+
def process_message(body)
|
|
201
|
+
log_info("Processando mensagem", body:)
|
|
202
|
+
# Sua lógica aqui
|
|
203
|
+
end
|
|
204
|
+
end
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### 5. Configure
|
|
208
|
+
|
|
209
|
+
```ruby
|
|
210
|
+
# config/initializers/shoryuken_template.rb
|
|
211
|
+
require 'shoryuken/template'
|
|
212
|
+
|
|
213
|
+
Shoryuken::Template.configure do |config|
|
|
214
|
+
config.thread_pool_size = 10
|
|
215
|
+
config.thread_timeout = 300
|
|
216
|
+
config.logger_level = :info
|
|
217
|
+
end
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
### 6. Execute
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
bundle exec shoryuken -r ./app/workers/my_worker.rb -q my-queue
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## 🐳 Instalação com Docker
|
|
227
|
+
|
|
228
|
+
### Dockerfile
|
|
229
|
+
|
|
230
|
+
```dockerfile
|
|
231
|
+
FROM ruby:3.4.2
|
|
232
|
+
|
|
233
|
+
WORKDIR /app
|
|
234
|
+
|
|
235
|
+
# Copia Gemfile
|
|
236
|
+
COPY Gemfile Gemfile.lock ./
|
|
237
|
+
|
|
238
|
+
# Instala dependências
|
|
239
|
+
RUN bundle install
|
|
240
|
+
|
|
241
|
+
# Copia código
|
|
242
|
+
COPY . .
|
|
243
|
+
|
|
244
|
+
CMD ["bundle", "exec", "shoryuken", "-R", "-C", "config/shoryuken.yml"]
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
### docker-compose.yml
|
|
248
|
+
|
|
249
|
+
```yaml
|
|
250
|
+
version: '3.8'
|
|
251
|
+
|
|
252
|
+
services:
|
|
253
|
+
worker:
|
|
254
|
+
build: .
|
|
255
|
+
environment:
|
|
256
|
+
- AWS_REGION=us-east-1
|
|
257
|
+
- AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}
|
|
258
|
+
- AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY}
|
|
259
|
+
- SHORYUKEN_THREAD_POOL_SIZE=10
|
|
260
|
+
volumes:
|
|
261
|
+
- .:/app
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
## 🔄 Atualizando a Gem
|
|
265
|
+
|
|
266
|
+
### Atualizar versão instalada localmente
|
|
267
|
+
|
|
268
|
+
```bash
|
|
269
|
+
# No diretório da gem
|
|
270
|
+
rake install_local
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### Atualizar em um projeto
|
|
274
|
+
|
|
275
|
+
```bash
|
|
276
|
+
# Se instalada via RubyGems
|
|
277
|
+
bundle update shoryuken-template
|
|
278
|
+
|
|
279
|
+
# Se usando path local, apenas salve as mudanças na gem
|
|
280
|
+
# Não precisa fazer nada, mudanças aparecem automaticamente
|
|
281
|
+
|
|
282
|
+
# Se usando Git
|
|
283
|
+
bundle update shoryuken-template
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
## 🗑️ Desinstalando
|
|
287
|
+
|
|
288
|
+
### Remover gem instalada localmente
|
|
289
|
+
|
|
290
|
+
```bash
|
|
291
|
+
gem uninstall shoryuken-template
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### Remover de um projeto
|
|
295
|
+
|
|
296
|
+
```ruby
|
|
297
|
+
# Remova do Gemfile
|
|
298
|
+
# gem 'shoryuken-template'
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
```bash
|
|
302
|
+
bundle install
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
## 🐛 Troubleshooting
|
|
306
|
+
|
|
307
|
+
### Erro: "cannot load such file -- shoryuken/template"
|
|
308
|
+
|
|
309
|
+
**Solução:**
|
|
310
|
+
```bash
|
|
311
|
+
# Verifique se a gem está instalada
|
|
312
|
+
gem list shoryuken-template
|
|
313
|
+
|
|
314
|
+
# Se não estiver, instale
|
|
315
|
+
bundle install
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
### Erro: "Ruby version >= 3.4.0 required"
|
|
319
|
+
|
|
320
|
+
**Solução:**
|
|
321
|
+
```bash
|
|
322
|
+
# Verifique sua versão do Ruby
|
|
323
|
+
ruby --version
|
|
324
|
+
|
|
325
|
+
# Atualize para 3.4.2
|
|
326
|
+
rbenv install 3.4.2
|
|
327
|
+
rbenv local 3.4.2
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
### Gem não atualiza com `bundle update`
|
|
331
|
+
|
|
332
|
+
**Solução:**
|
|
333
|
+
```bash
|
|
334
|
+
# Remove o Gemfile.lock e reinstala
|
|
335
|
+
rm Gemfile.lock
|
|
336
|
+
bundle install
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
### Path local não funciona
|
|
340
|
+
|
|
341
|
+
**Solução:**
|
|
342
|
+
```bash
|
|
343
|
+
# Verifique se o path está correto
|
|
344
|
+
ls ../shoryuken-template
|
|
345
|
+
|
|
346
|
+
# Use path absoluto se necessário
|
|
347
|
+
gem 'shoryuken-template', path: '/Users/seu-usuario/projetos/shoryuken-template'
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
## 📚 Recursos Adicionais
|
|
351
|
+
|
|
352
|
+
- [Bundler Documentation](https://bundler.io/)
|
|
353
|
+
- [RubyGems Guides](https://guides.rubygems.org/)
|
|
354
|
+
- [Shoryuken Documentation](https://github.com/ruby-shoryuken/shoryuken)
|
|
355
|
+
|
|
356
|
+
## 💬 Suporte
|
|
357
|
+
|
|
358
|
+
Problemas com instalação?
|
|
359
|
+
|
|
360
|
+
- 📝 [Abra uma issue](https://github.com/sousmile/shoryuken-template/issues)
|
|
361
|
+
- 📧 Email: andrade.rmn@gmail.com
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Ramon Andrade
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|