Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ gem 'activeadmin'
gem 'activeadmin_addons'
gem 'devise'

# Взаимодействие с микросервисами
gem 'httparty'
gem 'bunny'

group :development, :test do
gem 'bundler-audit'
gem 'capybara'
Expand Down
17 changes: 17 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ GEM
uri (>= 0.13.1)
addressable (2.8.7)
public_suffix (>= 2.0.2, < 7.0)
amq-protocol (2.3.3)
arbre (1.7.0)
activesupport (>= 3.0.0)
ruby2_keywords (>= 0.0.2)
Expand All @@ -108,6 +109,9 @@ GEM
bundler-audit (0.9.2)
bundler (>= 1.2.0, < 3)
thor (~> 1.0)
bunny (2.23.0)
amq-protocol (~> 2.3, >= 2.3.1)
sorted_set (~> 1, >= 1.0.2)
byebug (11.1.3)
capybara (3.40.0)
addressable
Expand Down Expand Up @@ -182,6 +186,10 @@ GEM
has_scope (0.8.2)
actionpack (>= 5.2)
activesupport (>= 5.2)
httparty (0.22.0)
csv
mini_mime (>= 1.0.0)
multi_xml (>= 0.5.2)
i18n (1.14.5)
concurrent-ruby (~> 1.0)
inherited_resources (1.14.0)
Expand Down Expand Up @@ -226,6 +234,8 @@ GEM
mini_mime (1.1.5)
mini_portile2 (2.8.8)
minitest (5.25.1)
multi_xml (0.7.1)
bigdecimal (~> 3.1)
net-imap (0.5.6)
date
net-protocol
Expand Down Expand Up @@ -313,6 +323,7 @@ GEM
activerecord (>= 6.1.5)
activesupport (>= 6.1.5)
i18n
rbtree (0.4.6)
rdoc (6.7.0)
psych (>= 4.0.0)
redcarpet (3.6.0)
Expand Down Expand Up @@ -385,6 +396,7 @@ GEM
sprockets-rails
tilt
securerandom (0.3.1)
set (1.1.1)
sexp_processor (4.17.2)
shoulda-matchers (6.4.0)
activesupport (>= 5.2.0)
Expand All @@ -401,6 +413,9 @@ GEM
actionpack (>= 3.1)
railties (>= 3.1)
slim (>= 3.0, < 6.0, != 5.0.0)
sorted_set (1.0.3)
rbtree
set (~> 1.0)
sprockets (4.2.1)
concurrent-ruby (~> 1.0)
rack (>= 2.2.4, < 4)
Expand Down Expand Up @@ -449,6 +464,7 @@ DEPENDENCIES
activeadmin_addons
activerecord-import
bundler-audit
bunny
capybara
config
database_consistency
Expand All @@ -460,6 +476,7 @@ DEPENDENCIES
factory_bot_rails
fasterer
ffaker
httparty
parallel
pg
pry-byebug
Expand Down
17 changes: 17 additions & 0 deletions config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,20 @@ app:
archives_folder: <%= ENV.fetch('ARCHIVES_FOLDER') { 'db/data/' } %>
sql_dump_path: <%= ENV.fetch('SQL_DUMP_PATH') { 'db/data/development.sql' } %>
index_concurrent_processes: <%= ENV.fetch('INDEX_CONCURRENT_PROCESSES') { Parallel.processor_count } %>

rabbitmq:
hosts: <%= ENV.fetch('RABBITMQ_HOSTS', 'localhost').split(',') %>
port: <%= ENV.fetch('RABBITMQ_PORT', '5672') %>
vhost: <%= ENV.fetch('RABBITMQ_VHOST', '/') %>
user: <%= ENV.fetch('RABBITMQ_USER', 'guest') %>
password: <%= ENV.fetch('RABBITMQ_PASSWORD', 'guest') %>
heartbeat_interval: <%= ENV.fetch('RABBITMQ_HEARTBEAT_INTERVAL') { 60 } %>
exchange: <%= ENV.fetch('RABBITMQ_EXCHANGE', 'services') %>
exchange_type: <%= ENV.fetch('RABBITMQ_EXCHANGE_TYPE', 'topic') %>

sneakers:
workers: <%= ENV.fetch('SNEAKERS_WORKERS') { 1 } %>
threads: <%= ENV.fetch('SNEAKERS_THREADS') { 1 } %>
queue: <%= ENV.fetch('SNEAKERS_QUEUE') { 'like_in' } %>
health_check_lifetime: 60
amqp_stub: <%= ENV.fetch('SNEAKERS_AMQP_STUB') { false } %>
10 changes: 10 additions & 0 deletions lib/tasks/like.rake
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
desc 'Ставим like'
task like: :environment do
json_path = Rails.root.join('spec', 'fixtures', 'like.json').to_path
message = JSON.parse(File.read(json_path))
connection = Bunny.new(Settings.rabbitmq.to_hash).start
channel = connection.create_channel
exchange = channel.topic('services', durable: true)
exchange.publish(message.to_json, routing_key: Settings.sneakers.queue)
connection.close
end
11 changes: 11 additions & 0 deletions spec/fixtures/like.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"id": "d8560533-9d18-44e1-9fdd-4672c6a39e6c",
"from": "rake",
"action": "like",
"params": {
"id": "d8560533-9d18-44e1-9fdd-4672c6a39e6c",
"action": "like",
"folder": "f.fb2-440801-444899.zip",
"book": "440905"
}
}