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
14 changes: 14 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
# The behavior of RuboCop can be controlled via the .rubocop.yml
# configuration file. It makes it possible to enable/disable
# certain cops (checks) and to alter their behavior if they accept
# any parameters. The file can be placed either in your home
# directory or in some project directory.
#
# RuboCop will start looking for the configuration file in the directory
# where the inspected file is and continue its way up to the root directory.
#
# See https://docs.rubocop.org/rubocop/configuration

inherit_from: .rubocop_todo.yml
inherit_mode:
merge:
- Exclude

AllCops:
NewCops: disable
Expand Down
57 changes: 0 additions & 57 deletions .rubocop_todo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ Metrics/AbcSize:
# AllowedMethods: refine
Metrics/BlockLength:
Exclude:
- '**/*.gemspec'
- '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'
Expand Down Expand Up @@ -51,63 +50,7 @@ Metrics/ParameterLists:
- 'lib/event_sourcery/postgres/event_store.rb'
- 'spec/support/event_helpers.rb'

# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: EnforcedStyleForLeadingUnderscores.
# SupportedStylesForLeadingUnderscores: disallowed, required, optional
Naming/MemoizedInstanceVariableName:
Exclude:
- 'lib/event_sourcery/postgres/reactor.rb'
- 'spec/event_sourcery/postgres/reactor_spec.rb'

# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
# AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to
Naming/MethodParameterName:
Exclude:
- 'spec/event_sourcery/postgres/reactor_spec.rb'

# Configuration parameters: EnforcedStyle, CheckMethodNames, CheckSymbols, AllowedIdentifiers, AllowedPatterns.
# SupportedStyles: snake_case, normalcase, non_integer
# AllowedIdentifiers: TLS1_1, TLS1_2, capture3, iso8601, rfc1123_date, rfc822, rfc2822, rfc3339, x86_64
Naming/VariableNumber:
Exclude:
- 'spec/event_sourcery/postgres/reactor_spec.rb'

# Configuration parameters: AllowedConstants.
Style/Documentation:
Exclude:
- 'spec/**/*'
- 'test/**/*'
- 'lib/event_sourcery/postgres.rb'
- 'lib/event_sourcery/postgres/config.rb'
- 'lib/event_sourcery/postgres/event_store.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'

# Configuration parameters: AllowedVariables.
Style/GlobalVars:
Exclude:
- 'spec/support/db_helpers.rb'

# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: AllowedReceivers.
# AllowedReceivers: Thread.current
Style/HashEachMethods:
Exclude:
- 'lib/event_sourcery/postgres/table_owner.rb'

# Configuration parameters: AllowedMethods.
# AllowedMethods: respond_to_missing?
Style/OptionalBooleanParameter:
Exclude:
- 'lib/event_sourcery/postgres/queue_with_interval_callback.rb'

# This cop supports unsafe autocorrection (--autocorrect-all).
# Configuration parameters: ConvertCodeThatCanStartToReturnNil, AllowedMethods, MaxChainLength.
# AllowedMethods: present?, blank?, presence, try, try!
Style/SafeNavigation:
Exclude:
- 'lib/event_sourcery/postgres/optimised_event_poll_waiter.rb'
- 'lib/event_sourcery/postgres/reactor.rb'
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,16 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

[Unreleased]: https://github.com/envato/event_sourcery-postgres/compare/v1.0.0...HEAD
[Unreleased]: https://github.com/envato/event_sourcery-postgres/compare/v1.0.1...HEAD

## [1.0.1] - 2026-01-17

### Changed

- Resolve issues as identified by RuboCop ([#85]).

[1.0.0]: https://github.com/envato/event_sourcery-postgres/compare/v1.0.0...v1.0.1
[#85]: https://github.com/envato/event_sourcery-postgres/pull/85

## [1.0.0] - 2025-12-28

Expand Down
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

## Development Status

EventSourcery is currently being used in production by multiple apps but we
haven't finalized the API yet and things are still moving rapidly. Until we
release a 1.0 things may change without first being deprecated.
EventSourcery::Postgres is in production use at [Envato](http://envato.com).

## Installation

Expand Down
2 changes: 1 addition & 1 deletion event_sourcery-postgres.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
'allowed_push_host' => 'https://rubygems.org',
'bug_tracker_uri' => "#{spec.homepage}/issues",
'changelog_uri' => "#{spec.homepage}/blob/HEAD/CHANGELOG.md",
'documentation_uri' => "https://www.rubydoc.info/gems/event_sourcery-postgres/#{spec.version}",
'documentation_uri' => "https://www.rubydoc.info/gems/#{spec.name}/#{spec.version}",
'source_code_uri' => "#{spec.homepage}/tree/v#{spec.version}"
}

Expand Down
1 change: 1 addition & 0 deletions lib/event_sourcery/postgres.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
require 'event_sourcery/postgres/tracker'

module EventSourcery
# PostgreSQL adapter for EventSourcery providing event store and projection capabilities.
module Postgres
def self.configure
yield config
Expand Down
1 change: 1 addition & 0 deletions lib/event_sourcery/postgres/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

module EventSourcery
module Postgres
# Configuration settings for the PostgreSQL event store and projections.
class Config
attr_accessor :lock_table_to_guarantee_linear_sequence_id_growth,
:write_events_function_name,
Expand Down
1 change: 1 addition & 0 deletions lib/event_sourcery/postgres/event_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

module EventSourcery
module Postgres
# PostgreSQL implementation of an event store for persisting and retrieving domain events.
class EventStore
include EventSourcery::EventStore::EachByRange

Expand Down
2 changes: 1 addition & 1 deletion lib/event_sourcery/postgres/optimised_event_poll_waiter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def start_async(after_listen: nil)
after_listen_callback = if after_listen
proc do
after_listen.call
@after_listen.call if @after_listen
@after_listen&.call
end
else
@after_listen
Expand Down
2 changes: 2 additions & 0 deletions lib/event_sourcery/postgres/projector.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

module EventSourcery
module Postgres
# Mixin providing projection capabilities for processing events into read models.
module Projector
def self.included(base)
base.include(EventProcessing::EventStreamProcessor)
Expand All @@ -17,6 +18,7 @@ class << self
end
end

# Instance methods for projector event processing and tracking.
module InstanceMethods
def initialize(tracker: EventSourcery::Postgres.config.event_tracker,
db_connection: EventSourcery::Postgres.config.projections_database,
Expand Down
3 changes: 2 additions & 1 deletion lib/event_sourcery/postgres/queue_with_interval_callback.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

module EventSourcery
module Postgres
# Queue that invokes a callback at regular intervals when no items are available.
class QueueWithIntervalCallback < ::Queue
attr_accessor :callback

Expand All @@ -16,7 +17,7 @@ def initialize(
super()
end

def pop(non_block_without_callback = false)
def pop(non_block_without_callback = false) # rubocop:disable Style/OptionalBooleanParameter
return super if non_block_without_callback

pop_with_interval_callback
Expand Down
7 changes: 5 additions & 2 deletions lib/event_sourcery/postgres/reactor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

module EventSourcery
module Postgres
# Mixin providing reactor capabilities for processing events and emitting new events in response.
module Reactor
UndeclaredEventEmissionError = Class.new(StandardError)

Expand All @@ -12,6 +13,7 @@ def self.included(base)
base.include(InstanceMethods)
end

# Class methods for declaring and querying emitted event types.
module ClassMethods
# Assign the types of events this reactor can emit.
#
Expand All @@ -22,7 +24,7 @@ def emits_events(*event_types)

# @return [Array] an array of the types of events this reactor can emit
def emit_events
@emits_event_types ||= []
@emits_event_types ||= [] # rubocop:disable Naming/MemoizedInstanceVariableName
end

# This will tell you if this reactor emits any type of event.
Expand All @@ -41,6 +43,7 @@ def emits_event?(event_type)
end
end

# Instance methods for reactor initialisation and event emission.
module InstanceMethods
def initialize(tracker: EventSourcery::Postgres.config.event_tracker,
db_connection: EventSourcery::Postgres.config.projections_database,
Expand Down Expand Up @@ -75,7 +78,7 @@ def emit_event(event_or_hash, &block)
end

def invoke_action_and_emit_event(event, action)
action.call(event.body) if action
action&.call(event.body)
event_sink.sink(event)
end
end
Expand Down
1 change: 1 addition & 0 deletions lib/event_sourcery/postgres/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

module EventSourcery
module Postgres
# Schema management for creating event store and projector tables in PostgreSQL.
module Schema
module_function

Expand Down
6 changes: 4 additions & 2 deletions lib/event_sourcery/postgres/table_owner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

module EventSourcery
module Postgres
# Mixin providing table management capabilities for projectors and reactors.
module TableOwner
DefaultTableError = Class.new(StandardError)
NoSuchTableError = Class.new(StandardError)
Expand All @@ -10,6 +11,7 @@ def self.prepended(base)
base.extend(ClassMethods)
end

# Class methods for defining and managing database tables.
module ClassMethods
# Hash of the tables and their corresponding blocks.
#
Expand Down Expand Up @@ -38,7 +40,7 @@ def setup

# Reset by dropping each table.
def reset
self.class.tables.keys.each do |table_name|
self.class.tables.each_key do |table_name|
prefixed_name = table_name_prefixed(table_name)
@db_connection.drop_table(prefixed_name, cascade: true) if @db_connection.table_exists?(prefixed_name)
end
Expand All @@ -49,7 +51,7 @@ def reset
# This will truncate all the tables and reset the tracker back to 0,
# done as a transaction.
def truncate
self.class.tables.each do |table_name, _|
self.class.tables.each_key do |table_name|
@db_connection.transaction do
prefixed_name = table_name_prefixed(table_name)
@db_connection[prefixed_name].truncate
Expand Down
2 changes: 1 addition & 1 deletion lib/event_sourcery/postgres/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module EventSourcery
module Postgres
VERSION = '1.0.0'
VERSION = '1.0.1'
end
end
Loading