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
69 changes: 0 additions & 69 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,6 @@
# Note that changes in the inspected code, or installation of new
# versions of RuboCop, may require this file to be generated again.

# Configuration parameters: AllowedMethods.
# AllowedMethods: enums
Lint/ConstantDefinitionInBlock:
Exclude:
- 'spec/event_sourcery/postgres/reactor_spec.rb'

# This cop supports unsafe autocorrection (--autocorrect-all).
Lint/NonDeterministicRequireOrder:
Exclude:
- 'spec/spec_helper.rb'

# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
Metrics/AbcSize:
Exclude:
Expand Down Expand Up @@ -50,7 +39,6 @@ Metrics/MethodLength:
- 'lib/event_sourcery/postgres/optimised_event_poll_waiter.rb'
- 'lib/event_sourcery/postgres/projector.rb'
- 'lib/event_sourcery/postgres/schema.rb'
- 'script/demonstrate_event_sequence_id_gaps.rb'

# Configuration parameters: CountComments, Max, CountAsOne.
Metrics/ModuleLength:
Expand Down Expand Up @@ -84,13 +72,6 @@ Naming/VariableNumber:
Exclude:
- 'spec/event_sourcery/postgres/reactor_spec.rb'

# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle, AllowModifiersOnSymbols, AllowModifiersOnAttrs, AllowModifiersOnAliasMethod.
# SupportedStyles: inline, group
Style/AccessModifierDeclarations:
Exclude:
- 'spec/support/db_helpers.rb'

# Configuration parameters: AllowedConstants.
Style/Documentation:
Exclude:
Expand All @@ -105,44 +86,6 @@ Style/Documentation:
- 'lib/event_sourcery/postgres/schema.rb'
- 'lib/event_sourcery/postgres/table_owner.rb'

# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle.
# SupportedStyles: always, always_true, never
Style/FrozenStringLiteralComment:
Exclude:
- '**/*.arb'
- 'Gemfile'
- 'Rakefile'
- 'bin/console'
- 'event_sourcery-postgres.gemspec'
- 'lib/event_sourcery/postgres.rb'
- 'lib/event_sourcery/postgres/config.rb'
- 'lib/event_sourcery/postgres/event_store.rb'
- 'lib/event_sourcery/postgres/optimised_event_poll_waiter.rb'
- 'lib/event_sourcery/postgres/projector.rb'
- 'lib/event_sourcery/postgres/queue_with_interval_callback.rb'
- 'lib/event_sourcery/postgres/reactor.rb'
- 'lib/event_sourcery/postgres/schema.rb'
- 'lib/event_sourcery/postgres/table_owner.rb'
- 'lib/event_sourcery/postgres/tracker.rb'
- 'lib/event_sourcery/postgres/version.rb'
- 'script/bench_reading_events.rb'
- 'script/bench_writing_events.rb'
- 'script/demonstrate_event_sequence_id_gaps.rb'
- 'spec/event_sourcery/postgres/config_spec.rb'
- 'spec/event_sourcery/postgres/event_store_spec.rb'
- 'spec/event_sourcery/postgres/optimised_event_poll_waiter_spec.rb'
- 'spec/event_sourcery/postgres/projector_spec.rb'
- 'spec/event_sourcery/postgres/reactor_spec.rb'
- 'spec/event_sourcery/postgres/table_owner_spec.rb'
- 'spec/event_sourcery/postgres/tracker_spec.rb'
- 'spec/event_sourcery/postgres_spec.rb'
- 'spec/spec_helper.rb'
- 'spec/support/db_helpers.rb'
- 'spec/support/event_helpers.rb'
- 'spec/support/logging.rb'
- 'spec/support/test_events.rb'

# Configuration parameters: AllowedVariables.
Style/GlobalVars:
Exclude:
Expand All @@ -155,13 +98,6 @@ Style/HashEachMethods:
Exclude:
- 'lib/event_sourcery/postgres/table_owner.rb'

# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyle, Autocorrect.
# SupportedStyles: module_function, extend_self, forbidden
Style/ModuleFunction:
Exclude:
- 'spec/support/db_helpers.rb'

# Configuration parameters: AllowedMethods.
# AllowedMethods: respond_to_missing?
Style/OptionalBooleanParameter:
Expand All @@ -175,8 +111,3 @@ Style/SafeNavigation:
Exclude:
- 'lib/event_sourcery/postgres/optimised_event_poll_waiter.rb'
- 'lib/event_sourcery/postgres/reactor.rb'

# This cop supports unsafe autocorrection (--autocorrect-all).
Style/SlicingWithRange:
Exclude:
- 'spec/event_sourcery/postgres/reactor_spec.rb'
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

### Changed

- Resolve issues as identified by RuboCop ([#78], [#82]).
- Resolve issues as identified by RuboCop ([#78], [#82], [#83]).
- Minor fixups in gem metadata ([#79]).
- Remove support for older Ruby versions: Ruby 2.6 or greater is now required ([#80]).

Expand All @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
[#79]: https://github.com/envato/event_sourcery-postgres/pull/79
[#80]: https://github.com/envato/event_sourcery-postgres/pull/80
[#82]: https://github.com/envato/event_sourcery-postgres/pull/82
[#83]: https://github.com/envato/event_sourcery-postgres/pull/83

## [0.9.1] - 2022-01-20

Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source 'https://rubygems.org'

ruby '>= 2.2.0'
Expand Down
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
require 'rubocop/rake_task'
Expand Down
1 change: 1 addition & 0 deletions bin/console
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

require 'bundler/setup'
require 'event_sourcery/postgres'
Expand Down
2 changes: 2 additions & 0 deletions event_sourcery-postgres.gemspec
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'event_sourcery/postgres/version'
Expand Down
2 changes: 2 additions & 0 deletions lib/event_sourcery/postgres.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'sequel'

Sequel.default_timezone = :utc
Expand Down
2 changes: 2 additions & 0 deletions lib/event_sourcery/postgres/config.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module EventSourcery
module Postgres
class Config
Expand Down
2 changes: 2 additions & 0 deletions lib/event_sourcery/postgres/event_store.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module EventSourcery
module Postgres
class EventStore
Expand Down
2 changes: 2 additions & 0 deletions lib/event_sourcery/postgres/optimised_event_poll_waiter.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module EventSourcery
module Postgres
# Optimise poll interval with Postgres listen/notify
Expand Down
2 changes: 2 additions & 0 deletions lib/event_sourcery/postgres/projector.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module EventSourcery
module Postgres
module Projector
Expand Down
2 changes: 2 additions & 0 deletions lib/event_sourcery/postgres/queue_with_interval_callback.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module EventSourcery
module Postgres
class QueueWithIntervalCallback < ::Queue
Expand Down
2 changes: 2 additions & 0 deletions lib/event_sourcery/postgres/reactor.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module EventSourcery
module Postgres
module Reactor
Expand Down
2 changes: 2 additions & 0 deletions lib/event_sourcery/postgres/schema.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module EventSourcery
module Postgres
module Schema
Expand Down
2 changes: 2 additions & 0 deletions lib/event_sourcery/postgres/table_owner.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module EventSourcery
module Postgres
module TableOwner
Expand Down
2 changes: 2 additions & 0 deletions lib/event_sourcery/postgres/tracker.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module EventSourcery
module Postgres
# This will set up a persisted event id tracker for processors.
Expand Down
4 changes: 3 additions & 1 deletion lib/event_sourcery/postgres/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# frozen_string_literal: true

module EventSourcery
module Postgres
VERSION = '0.9.1'.freeze
VERSION = '0.9.1'
end
end
2 changes: 2 additions & 0 deletions script/bench_reading_events.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Usage:
#
# ❯ bundle exec ruby script/bench_reading_events.rb
Expand Down
2 changes: 2 additions & 0 deletions script/bench_writing_events.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Usage:
#
# ❯ bundle exec ruby script/bench_writing_events.rb
Expand Down
2 changes: 2 additions & 0 deletions script/demonstrate_event_sequence_id_gaps.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# Demonstrates that sequence IDs may not be inserted linearly with concurrent
# writers.
#
Expand Down
2 changes: 2 additions & 0 deletions spec/event_sourcery/postgres/config_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec.describe EventSourcery::Postgres::Config do
subject(:config) { described_class.new }

Expand Down
2 changes: 2 additions & 0 deletions spec/event_sourcery/postgres/event_store_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'timeout'

RSpec.describe EventSourcery::Postgres::EventStore do
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec.describe EventSourcery::Postgres::OptimisedEventPollWaiter do
let(:after_listen) { proc {} }
subject(:waiter) { described_class.new(db_connection: db_connection, after_listen: after_listen) }
Expand Down
2 changes: 2 additions & 0 deletions spec/event_sourcery/postgres/projector_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec.describe EventSourcery::Postgres::Projector do
let(:projector_class) do
Class.new do
Expand Down
12 changes: 7 additions & 5 deletions spec/event_sourcery/postgres/reactor_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
RSpec.describe EventSourcery::Postgres::Reactor do
TermsConfirmationEmailSent = Class.new(EventSourcery::Event)
ItemViewed = Class.new(EventSourcery::Event)
EchoEvent = Class.new(EventSourcery::Event)
# frozen_string_literal: true

TermsConfirmationEmailSent = Class.new(EventSourcery::Event)
ItemViewed = Class.new(EventSourcery::Event)
EchoEvent = Class.new(EventSourcery::Event)

RSpec.describe EventSourcery::Postgres::Reactor do
let(:reactor_class) do
Class.new do
include EventSourcery::Postgres::Reactor
Expand Down Expand Up @@ -202,7 +204,7 @@ def event_count
end

def latest_events(n = 1)
event_source.get_next_from(0, limit: 100)[-n..-1]
event_source.get_next_from(0, limit: 100)[-n..]
end

context "when the event emitted doesn't take actions" do
Expand Down
2 changes: 2 additions & 0 deletions spec/event_sourcery/postgres/table_owner_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec.describe EventSourcery::Postgres::TableOwner do
let(:table_owner_class) do
Class.new do
Expand Down
2 changes: 2 additions & 0 deletions spec/event_sourcery/postgres/tracker_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec.describe EventSourcery::Postgres::Tracker do
subject(:postgres_tracker) { described_class.new(db_connection, table_name: table_name) }
let(:table_name) { :tracker }
Expand Down
2 changes: 2 additions & 0 deletions spec/event_sourcery/postgres_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

RSpec.describe EventSourcery::Postgres do
it 'has a version number' do
expect(EventSourcery::Postgres::VERSION).not_to be nil
Expand Down
4 changes: 3 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

# This file was generated by the `rspec --init` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# The generated `.rspec` file contains `--require spec_helper` which will cause
Expand Down Expand Up @@ -98,4 +100,4 @@
require 'event_sourcery/postgres'
require 'event_sourcery/rspec/event_store_shared_examples'

Dir.glob(File.join(__dir__, 'support/**/*.rb')) { |f| require f }
Dir.glob(File.join(__dir__, 'support/**/*.rb')).sort.each { |f| require f }
8 changes: 5 additions & 3 deletions spec/support/db_helpers.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
# frozen_string_literal: true

module DBHelpers
extend self
module_function

def db_connection
$db_connection ||= new_db_connection
end

module_function def new_db_connection
def new_db_connection
Sequel.connect("#{postgres_url}event_sourcery_test").extension(:pg_json)
end

module_function def postgres_url
def postgres_url
ENV.fetch('POSTGRESQL_URL', 'postgres://127.0.0.1:5432/')
end

Expand Down
2 changes: 2 additions & 0 deletions spec/support/event_helpers.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module EventHelpers
def new_event(aggregate_id: SecureRandom.uuid, type: 'test_event', body: {}, id: nil, version: 1, created_at: nil,
uuid: SecureRandom.uuid)
Expand Down
2 changes: 2 additions & 0 deletions spec/support/logging.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# frozen_string_literal: true

# quiet logging
EventSourcery.config.logger.level = Logger::FATAL
2 changes: 2 additions & 0 deletions spec/support/test_events.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

ItemAdded = Class.new(EventSourcery::Event)
ItemRemoved = Class.new(EventSourcery::Event)
TermsAccepted = Class.new(EventSourcery::Event)