Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add ui #1

Merged
merged 90 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
f2330d5
add basic sorting with pagination
bedrock-adam Feb 1, 2024
f75bbd6
update ui
bedrock-adam Feb 7, 2024
7d5f74c
don't track web/node_modules
bedrock-adam Feb 7, 2024
bc117b6
Merge remote-tracking branch 'origin' into feature/ui
bedrock-adam Feb 10, 2024
7578b78
add ransack (incomplete)
bedrock-adam Feb 13, 2024
fa3bb74
Merge remote-tracking branch 'origin' into feature/ui
bedrock-adam Feb 14, 2024
c70e31a
support bulk actions (WIP)
bedrock-adam Feb 24, 2024
0a2947d
update to work with messages
bedrock-adam Feb 24, 2024
8ce243d
support pagination
bedrock-adam Feb 24, 2024
d454a7e
add sorting (without messageable)
bedrock-adam Feb 24, 2024
1986e90
update seeds
bedrock-adam Feb 24, 2024
5eaff10
fix messageable sorting (incomplete)
bedrock-adam Feb 24, 2024
5edc089
fix show bugs
bedrock-adam Feb 24, 2024
49e4213
add mockups (missing buttons)
bedrock-adam Feb 25, 2024
1ae47e7
readd buttons
bedrock-adam Feb 25, 2024
9ada862
spike options
bedrock-adam Feb 25, 2024
4ac9845
commit show mockups
bedrock-adam Feb 25, 2024
b995b35
add mockup
bedrock-adam Feb 26, 2024
be73735
commit messages table markup
bedrock-adam Mar 2, 2024
f67403f
complete prototype
bedrock-adam Mar 2, 2024
84ee434
commit changes
bedrock-adam Mar 3, 2024
d8eb7fb
add working form
bedrock-adam Mar 6, 2024
739b6cd
make card-header responsive
bedrock-adam Mar 6, 2024
22fab44
add changes
bedrock-adam Mar 6, 2024
26ce748
commit html
bedrock-adam Mar 10, 2024
3acc022
Merge branch 'master' into feature/ui
bedrock-adam Mar 22, 2024
d15d53d
add messages/unpublished (wip)
bedrock-adam Mar 22, 2024
c09443b
commit changes (wip)
bedrock-adam Mar 22, 2024
b2612b1
fix nav links
bedrock-adam Mar 22, 2024
60e0275
add flash
bedrock-adam Mar 22, 2024
86566d4
somewhat functioning ui
bedrock-adam Mar 31, 2024
0f4137c
add home (incomplete)
bedrock-adam Mar 31, 2024
2dcbc3e
add homepage
bedrock-adam Mar 31, 2024
fab55a0
Merge branch 'master' into feature/ui
bedrock-adam Mar 31, 2024
f207225
Merge branch 'master' into feature/ui
bedrock-adam Apr 6, 2024
bf21828
remove unused files
bedrock-adam Apr 6, 2024
396758c
remove ransack
bedrock-adam Apr 6, 2024
5fbaa41
minimise changes
bedrock-adam Apr 6, 2024
a81d5a2
update rack
bedrock-adam Apr 6, 2024
1cb357b
Merge branch 'master' into feature/ui
bedrock-adam Apr 6, 2024
7e0f02d
fix broken UI
bedrock-adam Apr 7, 2024
53db2e3
Merge branch 'master' into feature/ui
bedrock-adam Apr 18, 2024
e0b26bb
Merge branch 'master' into feature/ui
bedrock-adam Apr 19, 2024
356785c
add parameter handling (incomplete)
bedrock-adam Apr 25, 2024
c073017
fix filtering
bedrock-adam Apr 25, 2024
cf1130a
fix per page bug
bedrock-adam Apr 25, 2024
a8b6afc
fix bugs
bedrock-adam Apr 27, 2024
3e7495a
fix more bugs
bedrock-adam Apr 27, 2024
b504b1c
Merge branch 'master' into feature/ui
bedrock-adam Apr 27, 2024
cd38664
make retry_all work
bedrock-adam Apr 27, 2024
f4e6727
Merge branch 'master' into feature/ui
bedrock-adam Apr 27, 2024
43498aa
add delete all support
bedrock-adam Apr 27, 2024
ad2be7a
fix home bugs
bedrock-adam Apr 27, 2024
7c9fae4
republished -> backlogged
bedrock-adam Apr 27, 2024
5186c3d
support handling TERM
bedrock-adam Apr 30, 2024
b5a6c9b
add per page and see more messages on home page
bedrock-adam May 1, 2024
1231783
progressively enhance per page
bedrock-adam May 1, 2024
f03ce8a
fix redirects after bulk action
bedrock-adam May 6, 2024
278721e
fix JS errors
bedrock-adam May 12, 2024
d0af101
fix JS
bedrock-adam May 12, 2024
67c46e6
fix accordian bug
bedrock-adam May 12, 2024
2c2806c
fix issues
bedrock-adam May 13, 2024
3237771
fix card header wrapping on mobile and js errors on empty
bedrock-adam May 13, 2024
6f3d102
support mounting in rails with outboxer_path
bedrock-adam May 18, 2024
107ff1b
update procfile
bedrock-adam May 18, 2024
06a54f8
fix mount bugs
bedrock-adam May 19, 2024
92cc1b8
update readme
bedrock-adam May 19, 2024
f29c39b
update UI
bedrock-adam May 19, 2024
a5e6191
update readme
bedrock-adam May 19, 2024
bd8e8b0
attempt to fix alert
bedrock-adam May 19, 2024
adbdd3f
fix session flash bug
bedrock-adam May 19, 2024
0fcfa5f
support offline mode
bedrock-adam May 19, 2024
3af05ca
fix dismissable
bedrock-adam May 19, 2024
3ec2a3e
update filter specs
bedrock-adam May 19, 2024
09d9968
fix republished spec
bedrock-adam May 19, 2024
d0a47d5
when no arguments specified
bedrock-adam May 19, 2024
b9d98c7
fix pagination spec
bedrock-adam May 19, 2024
f72954e
pass republish_all specs
bedrock-adam May 19, 2024
4f4e2c6
pass sort specs and build
bedrock-adam May 19, 2024
df5c521
fix UI
bedrock-adam May 19, 2024
9ef8a9f
fix bulk actions
bedrock-adam May 20, 2024
a1be63e
fix markup
bedrock-adam May 20, 2024
80c252d
add error page
bedrock-adam May 20, 2024
348cc30
remove custom errors
bedrock-adam May 20, 2024
5dedec2
fix html nesting
bedrock-adam May 20, 2024
2ed33f4
fix signal bugs
bedrock-adam May 20, 2024
23ea24e
update header
bedrock-adam May 20, 2024
a8e4a93
Update README.md
bedrock-adam May 20, 2024
dd1282d
fix auth session issue
bedrock-adam May 21, 2024
c589d5a
web UI working end to end
bedrock-adam May 21, 2024
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
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@
/pkg/
/spec/reports/
/tmp/
/tmp/
web/node_modules

*.gem

vendor/bundle

.rspec_status
.DS_Store
.DS_Store
.env
8 changes: 8 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ source "https://rubygems.org"
gemspec

gem "pry-byebug", "~> 3.10"

gem "rake", "~> 13.0"
gem "rspec"
gem "rubocop", "~> 1.55"
Expand All @@ -20,3 +21,10 @@ gem 'foreman', '~> 0.87.2'
# group :test do
# gem 'database_cleaner', '~> 2.0', '>= 2.0.2'
# end

# web
gem 'rackup', '~> 2.1'
gem 'sinatra', '~> 4.0'
gem 'sinatra-contrib'
gem 'puma', '~> 6.4', '>= 6.4.2'
gem 'kaminari', '~> 1.2', '>= 1.2.2'
58 changes: 53 additions & 5 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ PATH
outboxer (0.1.11)
activerecord (~> 7.0)
kaminari (~> 1.2)
rack-flash3 (~> 1.0, >= 1.0.5)

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -47,11 +48,13 @@ GEM
database_cleaner-core (2.0.1)
diff-lcs (1.5.0)
docile (1.4.0)
dotenv (3.1.2)
drb (2.2.0)
ruby2_keywords
erubi (1.12.0)
factory_bot (6.4.6)
activesupport (>= 5.0.0)
ffi (1.16.3)
foreman (0.87.2)
i18n (1.14.1)
concurrent-ruby (~> 1.0)
Expand All @@ -69,32 +72,51 @@ GEM
kaminari-core (= 1.2.2)
kaminari-core (1.2.2)
language_server-protocol (3.17.0.3)
listen (3.9.0)
rb-fsevent (~> 0.10, >= 0.10.3)
rb-inotify (~> 0.9, >= 0.9.10)
loofah (2.22.0)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
method_source (1.0.0)
minitest (5.20.0)
multi_json (1.15.0)
mustermann (3.0.0)
ruby2_keywords (~> 0.0.1)
mutex_m (0.2.0)
mysql2 (0.5.6)
nokogiri (1.16.2-arm64-darwin)
nio4r (2.7.0)
nokogiri (1.16.0-arm64-darwin)
racc (~> 1.4)
nokogiri (1.16.2-x86_64-darwin)
nokogiri (1.16.0-x86_64-darwin)
racc (~> 1.4)
nokogiri (1.16.2-x86_64-linux)
nokogiri (1.16.0-x86_64-linux)
racc (~> 1.4)
parallel (1.23.0)
parser (3.2.2.3)
ast (~> 2.4.1)
racc
pg (1.5.6)
pg (1.5.3)
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
pry-byebug (3.10.1)
byebug (~> 11.0)
pry (>= 0.13, < 0.15)
puma (6.4.2)
nio4r (~> 2.0)
racc (1.7.1)
rack (3.0.8)
rack (3.0.10)
rack-flash3 (1.0.5)
rack
rack-protection (4.0.0)
base64 (>= 0.1.0)
rack (>= 3.0.0, < 4)
rack-session (2.0.0)
rack (>= 3.0.0)
rackup (2.1.0)
rack (>= 3)
webrick (~> 1.8)
rails-dom-testing (2.2.0)
activesupport (>= 5.0.0)
minitest
Expand All @@ -104,9 +126,14 @@ GEM
nokogiri (~> 1.14)
rainbow (3.1.1)
rake (13.0.6)
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
ffi (~> 1.0)
redis-client (0.19.1)
connection_pool
regexp_parser (2.8.1)
rerun (0.14.0)
listen (~> 3.0)
rexml (3.2.6)
rspec (3.12.0)
rspec-core (~> 3.12.0)
Expand Down Expand Up @@ -147,10 +174,24 @@ GEM
simplecov_json_formatter (~> 0.1)
simplecov-html (0.12.3)
simplecov_json_formatter (0.1.4)
sinatra (4.0.0)
mustermann (~> 3.0)
rack (>= 3.0.0, < 4)
rack-protection (= 4.0.0)
rack-session (>= 2.0.0, < 3)
tilt (~> 2.0)
sinatra-contrib (4.0.0)
multi_json (>= 0.0.2)
mustermann (~> 3.0)
rack-protection (= 4.0.0)
sinatra (= 4.0.0)
tilt (~> 2.0)
tilt (2.3.0)
timeout (0.4.1)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
unicode-display_width (2.4.2)
webrick (1.8.1)
yard (0.9.34)

PLATFORMS
Expand All @@ -161,17 +202,24 @@ PLATFORMS
DEPENDENCIES
activerecord (~> 7.1, >= 7.1.2)
database_cleaner (~> 2.0, >= 2.0.2)
dotenv (>= 3.1.2)
factory_bot (~> 6.4, >= 6.4.6)
foreman (~> 0.87.2)
kaminari (~> 1.2, >= 1.2.2)
mysql2 (~> 0.5.6)
outboxer!
pg (~> 1.5)
pry-byebug (~> 3.10)
puma (~> 6.4, >= 6.4.2)
rackup (~> 2.1)
rake (~> 13.0)
rerun (~> 0.14.0)
rspec
rubocop (~> 1.55)
sidekiq (~> 7.2)
simplecov (~> 0.22.0)
sinatra (~> 4.0)
sinatra-contrib
yard (~> 0.9.34)

BUNDLED WITH
Expand Down
5 changes: 3 additions & 2 deletions Procfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
sidekiq: bundle exec sidekiq -r ./config/sidekiq.rb
sidekiq_ui: rackup config.ru
# outboxer_message_backlogger: bundle exec ruby script/message/backlogger.rb
sidekiq: bundle exec sidekiq -C config/sidekiq.yml -r ./config/sidekiq.rb
outboxer_message_publisher: bin/outboxer_message_publisher
outboxer_app: bundle exec rerun "rackup -p 3000"
46 changes: 43 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ bin/rails g outboxer:schema
bin/rake db:migrate
```

### 3. backlog message when event created
### 3. after event created, backlog message

```ruby
class Event < ActiveRecord::Base
Expand All @@ -49,7 +49,7 @@ class Event < ActiveRecord::Base
end
```

### 4. define event created job
### 4. add event created job

```ruby
class EventCreatedJob
Expand All @@ -69,7 +69,7 @@ end
bin/rails g outboxer:message_publisher
```

### 6. update publish block to queue event created job
### 6. update publish block to perform event created job async

```ruby
Outboxer::Publisher.publish do |message|
Expand All @@ -86,6 +86,46 @@ end
bin/outboxer_message_publisher
```

### 7. manage messages

manage backlogged, queued, publishing and failed messages with the web ui

<img width="1257" alt="Screenshot 2024-05-20 at 8 47 57 pm" src="https://github.com/fast-programmer/outboxer/assets/394074/0446bc7e-9d5f-4fe1-b210-ff394bdacdd6">

#### rails

##### config/routes.rb

```ruby
require 'outboxer/web'

Rails.application.routes.draw do
mount Outboxer::Web, at: '/outboxer'
end
```

#### rack

##### config.ru

```ruby
require 'outboxer/web'

map '/outboxer' do
run Outboxer::Web
end
```

### 8. monitor message publisher

understanding how much memory and cpu is required by the message publisher

<img width="310" alt="Screenshot 2024-05-20 at 10 41 57 pm" src="https://github.com/fast-programmer/outboxer/assets/394074/1222ad47-15e3-44d1-bb45-6abc6b3e4325">

```bash
run bin/outboxer_message_publishermon
```

## Motivation

Outboxer was created to help Rails teams migrate to eventually consistent event driven architecture quickly, using existing tools and infrastructure.
Expand Down
6 changes: 1 addition & 5 deletions app/jobs/event/created_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ class CreatedJob
include Sidekiq::Job

def perform(args)
Sidekiq.logger.info "Event::CreatedJob#perform args: #{args.inspect} started"

sleep 1.5

Sidekiq.logger.info "Event::CreatedJob#perform args: #{args.inspect} finished"
Sidekiq.logger.info "Event::CreatedJob#perform args: #{args.inspect}"
end
end
end
8 changes: 6 additions & 2 deletions bin/outboxer_message_publisher
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,13 @@ logger = Outboxer::Logger.new($stdout, level: Logger::INFO)
db_config = Outboxer::Database.config(environment: environment)
Outboxer::Database.connect(config: db_config, logger: logger)

Signal.trap('INT') { Outboxer::Message.stop_publishing }
['INT', 'TERM'].each do |signal|
Signal.trap(signal) do
Outboxer::Message.stop_publishing
end
end

Outboxer::Message.publish(threads: 100, queue: 100, poll: 1, logger: logger) do |message|
Outboxer::Message.publish(threads: 5, queue: 1000, poll: 1, logger: logger) do |message|
case message[:messageable_type]
when 'Event'
Event::CreatedJob.perform_async({ 'id' => message[:messageable_id] })
Expand Down
2 changes: 1 addition & 1 deletion bin/outboxer_message_publishermon
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ loop do

pids = outboxer_message_publisher_pids.sort

puts "Outboxer Report"
puts "Outboxer Message Publisher Monitor"
puts Time.now.utc
puts "\n---- Overview ----"
puts format("%-15s: %-10s", "Backlogged", total_backlogged)
Expand Down
17 changes: 14 additions & 3 deletions config.ru
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
require 'bundler/setup'

require 'dotenv/load'

require 'securerandom'
require 'sinatra'
require 'sidekiq'
require 'sidekiq/web'
require 'outboxer/web'

require 'securerandom'
use Rack::Session::Cookie, secret: ENV['SESSION_SECRET'], same_site: true, max_age: 86400

use Rack::Session::Cookie, secret: SecureRandom.hex(32), same_site: true, max_age: 86400
map '/outboxer' do
run Outboxer::Web
end

run Sidekiq::Web
map '/sidekiq' do
run Sidekiq::Web
end
4 changes: 2 additions & 2 deletions config/database.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ development:
username: outboxer_developer
password: outboxer_password
database: outboxer_development
pool: <%= ENV.fetch('DATABASE_POOL') { 5 } %>
pool: <%= ENV.fetch('DATABASE_POOL') { 26 } %>

test:
adapter: <%= ENV.fetch('DATABASE_ADAPTER') { 'postgresql' } %>
Expand All @@ -16,4 +16,4 @@ test:
username: outboxer_developer
password: outboxer_password
database: outboxer_test
pool: <%= ENV.fetch('DATABASE_POOL') { 5 } %>
pool: <%= ENV.fetch('DATABASE_POOL') { 26 } %>
9 changes: 4 additions & 5 deletions config/sidekiq.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
require 'active_record'
require 'sidekiq'

# require_relative '../app/models/event'
require_relative '../app/jobs/event_created_job'
require_relative '../app/jobs/event/created_job'

environment = ENV['RAILS_ENV'] || 'development'

Expand All @@ -20,6 +19,6 @@
config.redis = { url: redis_url }
end

# Sidekiq.configure_client do |config|
# config.redis = { url: redis_url }
# end
Sidekiq.configure_client do |config|
config.redis = { url: redis_url }
end
5 changes: 5 additions & 0 deletions config/sidekiq.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
:concurrency: 10
:queues:
- default
:redis:
:url: "redis://localhost:6379/0"
Loading
Loading