Skip to content
Merged
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
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ gemspec
gem 'minitest', '~> 5.16'
gem 'minitest-global_expectations'
gem 'pg'
gem 'pry'
gem 'rake', '~> 13.0'
gem 'rubocop', '~> 1.21'
gem 'rubocop-minitest'
Expand Down
40 changes: 40 additions & 0 deletions Readme.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,46 @@ irb(main):007> DB[:foo_outbox].first
metadata: nil}
```

### Using `outboxify`

```bash
% psql spgt_test
psql (16.4)
Type "help" for help.

spgt_test=# create table foo (id serial primary key, s text, i integer);
CREATE TABLE
spgt_test=# \d
List of relations
Schema | Name | Type | Owner
--------+------------+----------+----------
public | foo | table | bougyman
public | foo_id_seq | sequence | bougyman
(2 rows)

spgt_test=# \q
bougyman@framezotz ~/rubyists/sequel-pgt_outbox
% be ./exe/outboxify postgres:///spgt_test foo
bougyman@framezotz ~/rubyists/sequel-pgt_outbox
% psql spgt_test
psql (16.4)
Type "help" for help.

spgt_test=# \d foo
Table "public.foo"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+---------------------------------
id | integer | | not null | nextval('foo_id_seq'::regclass)
s | text | | |
i | integer | | |
Indexes:
"foo_pkey" PRIMARY KEY, btree (id)
Triggers:
pgt_outbox_foo_outbox AFTER INSERT OR DELETE OR UPDATE ON foo FOR EACH ROW EXECUTE FUNCTION pgt_outbox_foo_outbox()

spgt_test=#
```

## Development

After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
Expand Down
4 changes: 2 additions & 2 deletions ci/build_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ fi
service=$(basename "$owner_and_repo" .git)
owner=$(dirname "$owner_and_repo")

full_tag=$IMAGE_NAME:$tag-ruby$RUBY_VERSION-$UBUNTU_VERSION
full_tag=$IMAGE_NAME:$tag
# Pass any extra arguments to the build command ("$@" contains the rest of the arguments)
$runtime build --tag "$full_tag" "$@" \
--label org.opencontainers.image.created="$(date --utc --iso-8601=seconds)" \
Expand Down Expand Up @@ -237,7 +237,7 @@ fi
mapfile -t tags < <(echo "$tag" | awk -F'.' 'NF==3{print; print $1"."$2; print $1; next} NF==2{print; print $1; next} {print}')
for t in "${tags[@]}"
do
new_tag=$IMAGE_NAME:$t-ruby$RUBY_VERSION-$UBUNTU_VERSION
new_tag=$IMAGE_NAME:$t
registry_image_name="$REGISTRY/$owner/$new_tag"
if [ "$runtime" = "podman" ]
then
Expand Down
29 changes: 29 additions & 0 deletions exe/outboxify
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require 'sequel/pgt_outbox'
require 'optparse'

opts = OptionParser.new do |o|
o.banner = 'Usage: outboxify [options] <db uri> <table>'
end

db_uri = ARGV.shift
if db_uri.nil?
warn 'missing db uri'
puts opts
exit 1
end

DB = Sequel.connect db_uri
DB.extension :pgt_outbox

table = ARGV.shift
if table.nil?
warn 'missing table'
puts opts
exit 2
end

function = DB.pgt_outbox_setup(table)
DB.pgt_outbox_events(table, function)
Loading