├── .gitignore ├── CHANGES.md ├── Gemfile ├── MIT-License.txt ├── README.md ├── eventide-postgres.gemspec ├── init.rb ├── install-gems.sh ├── lib └── eventide │ └── postgres.rb ├── library-symlinks.sh ├── load_path.rb ├── remove-lib-symlinks.sh ├── symlink-lib.sh └── test.rb /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_store 2 | .bundle/ 3 | .ruby-version 4 | .ruby-gemset 5 | .rvmrc 6 | Gemfile.lock 7 | *.log 8 | *.gem 9 | gems 10 | gems_backup 11 | *scratch* 12 | *notes* 13 | loader.rb 14 | gems.txt 15 | -------------------------------------------------------------------------------- /CHANGES.md: -------------------------------------------------------------------------------- 1 | # Eventide Postgres Changes 2 | 3 | ### 2.0.1.0 4 | 5 | Wed Oct 12 2022 6 | 7 | Updates to the message_store and message_store-postgres libraries to support Message DB [v1.3.0](https://github.com/message-db/message-db/releases/tag/v1.3.0). 8 | 9 | The message_store-postgres library’s Get::Stream::Last class’s actuator supports an optional parameter named `type`. This is in addition to the `stream_name` parameter that has always been part of the Get::Stream::Last actuator’s signature. 10 | 11 | Libraries affected: 12 | 13 | - message-store (v2.3.2.0) 14 | - message-store-postgres (v2.4.4.0) 15 | 16 | ### 2.0.0.0 17 | 18 | December 2019 19 | 20 | WARNING: 21 | 22 | The Eventide v2 code is incompatible with a v1 message store database. Don't update the Eventide toolkit code until you're ready to update your message store database. 23 | 24 | ## Test Bench 25 | 26 | All tests in the v2 stack have been ported and updated to the new version of [Test Bench](https://github.com/test-bench/test-bench) released in October, 2019. 27 | 28 | ## Postgres Message Store 29 | 30 | - This library is deprecated. It's replaced with Message DB: [https://github.com/message-db/message-db](https://github.com/message-db/message-db) 31 | 32 | ## Message DB 33 | 34 | - Formerly, `postgres-message-store` (see above). 35 | - **Note: There are no changes to the `messages` table, and no data migration is necessary** 36 | - **An update tool is provided to make the structural upgrades to the database** 37 | - The executables named `evt-pg-*` are renamed to `mdb-*` 38 | - **[breaking change]** The `get_category_messages` server function supports pub/sub directly by receiving a `correlation` argument and composing the correlation metadata query condition directly in the server function ([http://docs.eventide-project.org/user-guide/message-store/server-functions.html#get-messages-from-a-stream](http://docs.eventide-project.org/user-guide/message-store/server-functions.html#get-messages-from-a-stream)) 39 | - **[breaking change]** The message_store database and its objects are contained in a Postgres schema named `message_store` 40 | - **[breaking change]** The `get_category_messages` server function supports consumer groups via the `consumer_group_member` and `consumer_group_size` parameters ([http://docs.eventide-project.org/user-guide/message-store/server-functions.html#get-messages-from-a-category](http://docs.eventide-project.org/user-guide/message-store/server-functions.html#get-messages-from-a-category)) 41 | - The retrieval server functions provide debugging output that is activated via the Postgres setting, `message_store.debug_get` ([http://docs.eventide-project.org/user-guide/message-store/server-functions.html#debugging-output](http://docs.eventide-project.org/user-guide/message-store/server-functions.html#debugging-output)) 42 | - The write server function provides debugging output that is activated via the Postgres setting, `message_store.debug_write` ([http://docs.eventide-project.org/user-guide/message-store/server-functions.html#debugging-output](http://docs.eventide-project.org/user-guide/message-store/server-functions.html#debugging-output)) 43 | - The `message_store.debug` Postgres setting activates both the retrieval and write debug output ([http://docs.eventide-project.org/user-guide/message-store/server-functions.html#debugging-output](http://docs.eventide-project.org/user-guide/message-store/server-functions.html#debugging-output)) 44 | - `id` stream parsing function ([http://docs.eventide-project.org/user-guide/message-store/server-functions.html#get-the-id-from-a-stream-name](http://docs.eventide-project.org/user-guide/message-store/server-functions.html#get-the-id-from-a-stream-name)) 45 | - `cardinal_id` stream parsing function ([http://docs.eventide-project.org/user-guide/message-store/server-functions.html#get-the-cardinal-id-from-a-stream-name](http://docs.eventide-project.org/user-guide/message-store/server-functions.html#get-the-cardinal-id-from-a-stream-name)) 46 | - `acquire_lock` function encapsulates the application of the advisory lock used by the `write_message` function ([http://docs.eventide-project.org/user-guide/message-store/server-functions.html#get-message-store-database-schema-version](http://docs.eventide-project.org/user-guide/message-store/server-functions.html#get-message-store-database-schema-version)) 47 | - Database management tool output is clarified 48 | - **[breaking change]** All server function parameter names are no longer named with underscore prefixes ([http://docs.eventide-project.org/user-guide/message-store/server-functions.html](http://docs.eventide-project.org/user-guide/message-store/server-functions.html)) 49 | - Indexes are no longer built with the `CONCURRENTLY` option ([http://docs.eventide-project.org/user-guide/message-store/anatomy.html#source-code](http://docs.eventide-project.org/user-guide/message-store/anatomy.html#source-code)) 50 | - **[breaking change]** The `messages_category_global_position_idx` is removed and replaced with the `messages_category` index, which now indexes correlation metadata 51 | - **[breaking change]** The `messages_stream_name_position_uniq_idx` is removed and replaced with the `messages_stream` index, which now indexes correlation metadata 52 | - **[breaking change]** The `messages_id_uniq_idx` is removed and replaced with the `messages_id` index 53 | - Message DB RubyGem: [https://github.com/message-db/ruby-gem](https://github.com/message-db/ruby-gem) 54 | - Message DB NPM Module: [https://github.com/message-db/npm-module](https://github.com/message-db/npm-module) 55 | - Improvements to interactive tests ([https://github.com/eventide-project/postgres-message-store/tree/master/test](https://github.com/eventide-project/postgres-message-store/tree/master/test)) 56 | 57 | ## Message Store Client 58 | 59 | - `MessageStore::Postgres::Get` receives the `correlation` argument and passes it to the message store database's retrieval functions ([http://docs.eventide-project.org/user-guide/retrieving/batch.html#retrieving-correlated-messages](http://docs.eventide-project.org/user-guide/retrieving/batch.html#retrieving-correlated-messages)) 60 | - `MessageStore::Postgres::Get` receives the `consumer_group_member` and `consumer_group_size` arguments and passes it to the message store database's retrieval functions ([http://docs.eventide-project.org/user-guide/retrieving/batch.html#consumer-groups](http://docs.eventide-project.org/user-guide/retrieving/batch.html#consumer-groups)) 61 | - Stream name utilities now support stream name with compound IDs ([http://docs.eventide-project.org/user-guide/stream-names/message-store-stream-name.html#stream-name](http://docs.eventide-project.org/user-guide/stream-names/message-store-stream-name.html#stream-name)) 62 | - Cardinal IDs are formalized as part of the stream name utilities ([http://docs.eventide-project.org/user-guide/stream-names/message-store-stream-name.html#stream-name](http://docs.eventide-project.org/user-guide/stream-names/message-store-stream-name.html#stream-name)) 63 | - Concrete `Get::Category` and `Get::Stream` classes can be constructed, configured, and used directly without using the abstract `Get` factory 64 | - Correlation is supported exclusively by the `Get::Category` implementation 65 | - Consumer groups are supported exclusively by the `Get::Category` implementation 66 | 67 | ## Messaging 68 | 69 | - Stream name composition and parsing supports all same features as the stream name composition and parsing in the message store library ([http://docs.eventide-project.org/user-guide/stream-names/messaging-stream-name.html](http://docs.eventide-project.org/user-guide/stream-names/messaging-stream-name.html)) 70 | 71 | ## Consumer 72 | 73 | - **[breaking change]** Entity stream names are no longer supported by consumers ([http://docs.eventide-project.org/user-guide/consumers.html](http://docs.eventide-project.org/user-guide/consumers.html)) 74 | - Correlation query conditions are no longer composed in the consumer and passed to the message store database server functions. The message store database composes the correlation query conditions within its server functions. 75 | - Consumer group query conditions are no longer composed in the consumer and passed to the message store database server functions. The message store database composes the correlation query conditions within its server functions. 76 | 77 | ## Documentation 78 | 79 | - [Message DB](http://docs.eventide-project.org/user-guide/message-db/) documentation is improved 80 | - The `MessageStore::Postgres::Get` module is documented ([http://docs.eventide-project.org/user-guide/retrieving/batch.html](http://docs.eventide-project.org/user-guide/retrieving/batch.html)) 81 | - Debugging output for the Postgres server functions is documented ([http://docs.eventide-project.org/user-guide/message-store/server-functions.html#debugging-output](http://docs.eventide-project.org/user-guide/message-store/server-functions.html#debugging-output)) 82 | - Stream name utilities documentation is updated and improved: [http://docs.eventide-project.org/user-guide/stream-names](http://docs.eventide-project.org/user-guide/stream-names/) 83 | - Consumer user guide is improved and is more consistent with `MessageStore::Postgres::Get` documentation: [http://docs.eventide-project.org/user-guide/consumers.html](http://docs.eventide-project.org/user-guide/consumers.html) 84 | - The settings file location override is documented ([http://docs.eventide-project.org/user-guide/session.html#overriding-the-setting-file-location](http://docs.eventide-project.org/user-guide/session.html#overriding-the-setting-file-location)) 85 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gemspec 4 | -------------------------------------------------------------------------------- /MIT-License.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016-present Scott Bellware 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![Message DB](http://docs.eventide-project.org/eventide-icon-100.png) 2 | 3 | # Eventide 4 | 5 | Pub/Sub, event sourcing, evented microservices, and message-based applications toolkit built for the [Message DB](https://github.com/message-db/message-db) back end. 6 | 7 | ## Features 8 | 9 | - Pub/Sub 10 | - Evented Services 11 | - Event Sourcing 12 | - Streams 13 | - Messaging 14 | - Parallel processing 15 | - Host server 16 | - Administration tools 17 | - Reports 18 | - and [more...](http://docs.eventide-project.org) 19 | 20 | ## Documentation 21 | 22 | See the [Eventide documentation site](http://docs.eventide-project.org) for more information, examples, and user guides. 23 | 24 | ## License 25 | 26 | The `eventide-postgres` library is released under the [MIT License](https://github.com/eventide-project/eventide-postgres/blob/master/MIT-License.txt). 27 | -------------------------------------------------------------------------------- /eventide-postgres.gemspec: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | Gem::Specification.new do |s| 3 | s.name = 'eventide-postgres' 4 | s.version = '2.0.1.0' 5 | s.summary = 'Event-Sourced Autonomous Services Toolkit' 6 | s.description = ' ' 7 | 8 | s.authors = ['The Eventide Project'] 9 | s.email = 'opensource@eventide-project.org' 10 | s.homepage = 'https://github.com/eventide-project/eventide-postgres' 11 | s.licenses = ['MIT'] 12 | 13 | s.require_paths = ['lib'] 14 | s.files = Dir.glob('{lib}/**/*') 15 | s.platform = Gem::Platform::RUBY 16 | s.required_ruby_version = '>= 2.3.3' 17 | 18 | s.add_runtime_dependency 'evt-entity_store' 19 | s.add_runtime_dependency 'evt-consumer-postgres' 20 | s.add_runtime_dependency 'evt-entity_snapshot-postgres' 21 | end 22 | -------------------------------------------------------------------------------- /init.rb: -------------------------------------------------------------------------------- 1 | require_relative './load_path' 2 | 3 | require 'eventide/postgres' 4 | -------------------------------------------------------------------------------- /install-gems.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -e 4 | 5 | if [ -z ${POSTURE+x} ]; then 6 | echo "(POSTURE is not set. Using \"operational\" by default.)" 7 | posture="operational" 8 | else 9 | posture=$POSTURE 10 | fi 11 | 12 | echo 13 | echo "Installing gems locally (posture: $posture)" 14 | echo '= = =' 15 | 16 | cmd="bundle install --standalone --path=./gems" 17 | 18 | if [ operational == "$posture" ]; then 19 | cmd="$cmd --without=development" 20 | fi 21 | 22 | echo $cmd 23 | ($cmd) 24 | 25 | echo '- - -' 26 | echo '(done)' 27 | echo 28 | -------------------------------------------------------------------------------- /lib/eventide/postgres.rb: -------------------------------------------------------------------------------- 1 | require 'entity_store' 2 | require 'consumer/postgres' 3 | require 'entity_snapshot/postgres' 4 | -------------------------------------------------------------------------------- /library-symlinks.sh: -------------------------------------------------------------------------------- 1 | set -e 2 | 3 | if [ -z ${LIBRARIES_HOME+x} ]; then 4 | echo "LIBRARIES_HOME must be set to the libraries directory path... exiting" 5 | exit 1 6 | fi 7 | 8 | if [ ! -d "$LIBRARIES_HOME" ]; then 9 | echo "$LIBRARIES_HOME does not exist... exiting" 10 | exit 1 11 | fi 12 | 13 | function make_directory { 14 | directory=$1 15 | 16 | lib_directory="$LIBRARIES_HOME/$directory" 17 | 18 | if [ ! -d "$lib_directory" ]; then 19 | echo "- making directory $lib_directory" 20 | mkdir -p "$lib_directory" 21 | fi 22 | } 23 | 24 | function remove_lib_symlinks { 25 | name=$1 26 | directory=$2 27 | 28 | dest="$LIBRARIES_HOME" 29 | if [ ! -z "$directory" ]; then 30 | dest="$dest/$directory" 31 | fi 32 | dest="$dest/$name" 33 | 34 | for entry in $dest*; do 35 | if [ -h "$entry" ]; then 36 | echo "- removing symlink: $entry" 37 | rm $entry 38 | fi 39 | done 40 | } 41 | 42 | function symlink_lib { 43 | name=$1 44 | directory=$2 45 | 46 | echo 47 | echo "Symlinking $name" 48 | echo "- - -" 49 | 50 | remove_lib_symlinks $name $directory 51 | 52 | src="$(pwd)/lib" 53 | dest="$LIBRARIES_HOME" 54 | if [ ! -z "$directory" ]; then 55 | src="$src/$directory" 56 | dest="$dest/$directory" 57 | 58 | make_directory $directory 59 | fi 60 | src="$src/$name" 61 | 62 | echo "- destination is $dest" 63 | 64 | full_name=$directory/$name 65 | 66 | for entry in $src*; do 67 | entry_basename=$(basename $entry) 68 | dest_item="$dest/$entry_basename" 69 | 70 | echo "- symlinking $entry_basename to $dest_item" 71 | 72 | cmd="ln -s $entry $dest_item" 73 | echo $cmd 74 | ($cmd) 75 | done 76 | 77 | echo "- - -" 78 | echo "($name done)" 79 | echo 80 | } 81 | -------------------------------------------------------------------------------- /load_path.rb: -------------------------------------------------------------------------------- 1 | bundler_standalone_loader = 'gems/bundler/setup' 2 | 3 | begin 4 | require_relative bundler_standalone_loader 5 | rescue LoadError 6 | warn "WARNING: Standalone bundle loader is not at #{bundler_standalone_loader}. Using Bundler to load gems." 7 | require "bundler/setup" 8 | Bundler.require 9 | end 10 | 11 | lib_dir = File.expand_path('lib', __dir__) 12 | $LOAD_PATH.unshift(lib_dir) unless $LOAD_PATH.include?(lib_dir) 13 | 14 | libraries_dir = ENV['LIBRARIES_HOME'] 15 | unless libraries_dir.nil? 16 | libraries_dir = File.expand_path(libraries_dir) 17 | $LOAD_PATH.unshift libraries_dir unless $LOAD_PATH.include?(libraries_dir) 18 | end 19 | -------------------------------------------------------------------------------- /remove-lib-symlinks.sh: -------------------------------------------------------------------------------- 1 | source ./library-symlinks.sh 2 | 3 | remove_lib_symlinks 'eventide' 'postgres' 4 | -------------------------------------------------------------------------------- /symlink-lib.sh: -------------------------------------------------------------------------------- 1 | source ./library-symlinks.sh 2 | 3 | symlink_lib 'eventide' 'postgres' 4 | -------------------------------------------------------------------------------- /test.rb: -------------------------------------------------------------------------------- 1 | load './init.rb' 2 | --------------------------------------------------------------------------------