Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
99 commits
Select commit Hold shift + click to select a range
2ab8a65
Skeleton implementation
sbellware Nov 2, 2016
a39d0be
Write message
sbellware Nov 4, 2016
06ee6b3
Reply
sbellware Nov 4, 2016
dcc9799
Using Get rather than Read in tests
sbellware Nov 4, 2016
6ed91e9
Test writing reply stream name
sbellware Nov 4, 2016
321fd94
Convenience interfaces operate in terms of stream_name rather than st…
sbellware Nov 4, 2016
dd45009
Expected version test
sbellware Nov 4, 2016
fe0b219
Write batch
sbellware Nov 4, 2016
043f3d0
Test for write batch with reply stream name
sbellware Nov 5, 2016
4dfafc2
Superfluous persistent reference is removed
sbellware Nov 5, 2016
c0181de
Test for reply checks that the reply stream name is cleared from the …
sbellware Nov 5, 2016
57befbf
Test for erroneous reply with a batch
sbellware Nov 5, 2016
329758e
Test for failure when replying without a reply stream name in the met…
sbellware Nov 5, 2016
a05ef31
Expected version error is in the ExpectedVersion namespace
sbellware Nov 5, 2016
27103f9
Write initial
sbellware Nov 5, 2016
9d4cd07
Tests for initial write of batch
sbellware Nov 5, 2016
d4cce18
Test stream names are clarified
sbellware Nov 5, 2016
61a2375
Superfluous namespace references are removed
sbellware Nov 6, 2016
74cdf98
Reply to batch error is tested in the root messaging library
sbellware Nov 6, 2016
d7f7cc9
Package version established as 0.1.0.0
sbellware Nov 6, 2016
98258c7
Interactive test of production and consumption
sbellware Nov 10, 2016
29c26c7
Interactive tests use local controls
sbellware Nov 10, 2016
cd26632
Partition is an instance actuator parameter rather than a class const…
sbellware Nov 18, 2016
08795a9
Package version is increased from 0.1.0.0 to 0.2.0.0
sbellware Nov 19, 2016
9f1000f
Partition write test
sbellware Nov 19, 2016
4c82011
Partition tests
sbellware Nov 19, 2016
5b75972
Test names are corrected
sbellware Nov 19, 2016
8f67376
Package version is increased fro 0.2.0.0 to 0.2.1.0
sbellware Nov 19, 2016
f9c77b4
Partition is removed
sbellware Nov 20, 2016
26d9d32
Package version is increased from 0.2.1.0 to 0.3.0.0
sbellware Nov 20, 2016
77dbeac
Tests are improved
sbellware Nov 20, 2016
1484697
Batch control
sbellware Nov 21, 2016
5df4ae7
Package version increased from 0.3.0.0 to 0.3.0.1
sbellware Nov 21, 2016
9c437a2
Changes to interactive tests in effort to target an issue with serial…
sbellware Nov 26, 2016
e145cdd
Merge branch 'serialization-bug'
sbellware Nov 26, 2016
5c8c155
Updated cycle read's cycle parameter names
sbellware Nov 26, 2016
a3ba213
Pretty printing is already activated
sbellware Nov 30, 2016
0951283
Write, rather than writer
sbellware Dec 14, 2016
677f23d
Initial, rather than write initial
sbellware Dec 14, 2016
9d198ea
Package version increased from 0.3.0.1 to 0.4.0.0
sbellware Dec 14, 2016
0df7643
Database name is event_source
sbellware Dec 14, 2016
309a80c
'Required Ruby version is 2.3.3'
sbellware Dec 19, 2016
e99a405
Gem renamed to use the evt prefix
sbellware Dec 20, 2016
cdcaa0c
Dependencies on rubygems.org
sbellware Dec 20, 2016
214a083
Package version increased from 0.4.0.0 to 0.4.0.1
sbellware Dec 20, 2016
a6f2088
Interactive test's producer also measures throughput
sbellware Dec 21, 2016
c2467c4
Interactive test's consumer also measures throughput
sbellware Dec 21, 2016
2f8c488
Measurements are done in their own script
sbellware Dec 21, 2016
e232855
Reader in measurement script uses default batch size
sbellware Dec 21, 2016
290f015
Coverage of ID assignment is increased
sbellware Jan 13, 2017
73042c1
Merge branch 'event-id'
sbellware Jan 13, 2017
450b59e
Maximum milliseconds, not delay milliseconds
ntl Jan 19, 2017
5b1f413
Stream control is removed
sbellware Feb 1, 2017
6bdeb38
Package version is updated from 0.4.0.1 to 0.5.0.0
sbellware Feb 1, 2017
22d5637
Category stream name and command category stream name are platform sp…
sbellware Feb 1, 2017
c3cba2e
Package version is increased from 0.5.0.0 to 0.5.1.0
sbellware Feb 1, 2017
d7003fd
Stream name generalizations are moved to specialization library
sbellware Feb 5, 2017
95bf3f4
Test coverage from generalization library is moved into tests for thi…
sbellware Feb 5, 2017
09be2be
Merge branch 'specialize-stream-name'
sbellware Feb 5, 2017
5b41f0e
Package version increased from 0.5.1.0 to 0.6.0.0
sbellware Feb 5, 2017
0ed6308
Reference of vestigial constant is removed
sbellware Feb 5, 2017
4d6759a
Category macro is moved to generalization
sbellware Feb 5, 2017
74e0701
Draft of overview documentation
sbellware May 19, 2017
8d0fa15
EventSource, EventData is renamed to MessageStore, MessageData
ntl May 26, 2017
8e33770
Required ruby version is increased from 2.3.3 to 2.4.0
ntl May 26, 2017
e965470
Gem depends on message-store-postgres
ntl May 26, 2017
f332444
Message store postgres settings file is moved
ntl May 26, 2017
a85c3e5
Usages of event instead of message are corrected
ntl May 26, 2017
ffb52b6
Vestigal stream_name.rb file is removed
ntl May 26, 2017
f97e3c7
Merge branch 'ntl-message-store-rework'
ntl May 26, 2017
984c31a
Symlink scripts are corrected
ntl May 26, 2017
49099f6
Messaging uses MessageStore
sbellware May 30, 2017
92263c7
MessageStore, rather than EventSource
sbellware May 30, 2017
94d158e
Message, rather than event
sbellware May 30, 2017
6ea7bd6
Merge branch 'message-store'
sbellware May 30, 2017
838bba5
Merge remote-tracking branch 'origin/master' into trial-merge
sbellware May 30, 2017
337d9e2
Merge branch 'trial-merge'
sbellware May 30, 2017
95daa13
Package description is corrected
sbellware May 30, 2017
e6cf2b0
Package version increased from 0.6.0.0 to 0.7.0.0
sbellware May 30, 2017
f125a5f
Gemspec is named for the library
sbellware May 31, 2017
fdde05e
Package version is increased from 0.7.0.0 to 0.7.0.1
sbellware May 31, 2017
5753ac0
Package version is increased from 0.7.0.1 to 0.7.0.2
sbellware Jun 1, 2017
7243923
Write configure method passes session to put configure method
ntl Jul 30, 2017
1c48ff1
Package version is increased from 0.7.0.2 to 0.7.0.3
ntl Jul 30, 2017
ff39f66
load_path.rb is updated with the latest version
sbellware Aug 14, 2018
cd099b6
Readme defers to documentation site
sbellware Sep 4, 2018
c8629d5
Library and verbose tags are removed
sbellware Nov 1, 2018
079172b
The messaging_postgres log tag is replaced with the messaging log tag
sbellware Nov 1, 2018
0b18299
Package version is increased from 0.7.0.3 to 0.7.0.4
sbellware Nov 1, 2018
e98435a
Package version is increased from 0.7.0.4 to 1.0.0.0
ntl Nov 4, 2018
f200b98
Test files are compatible with TestBench 2.0
ntl Oct 14, 2019
0dcf640
Automated test runner supplies exclude file pattern directly into CLI
ntl Oct 17, 2019
9043567
Parenthesis are added to assert_raises and refute_raises
ntl Oct 17, 2019
d963fa8
Package version is increased from 1.0.0.0 to 2.0.0.0
sbellware Dec 10, 2019
f2cfc35
All tests blocks have an assertion
ntl Jul 23, 2020
382fd4a
Merge branch 'all-tests-assert'
ntl Jul 23, 2020
b18021d
Merge 'messaging-postgres'
aaronjensen Jan 21, 2023
4bd4024
messaging and messaging-postgres are combined
aaronjensen Jan 21, 2023
36056bb
Gitignore is updated
aaronjensen Jan 21, 2023
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
.bundle/
Gemfile.lock
*.log
*.gem
gems
*sketch*
*notes.*
todo.md
fixtures
/test/interactive/stream_name.tmp
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# messaging

Common primitives for platform-specific messaging implementations for Eventide.

This library provides generalizations that are used by platform-specific implementations that provide concrete functionality.
Eventide messaging for Postgres

## Documentation

See the [Eventide documentation site](http://docs.eventide-project.org) for more information, examples, and user guides.

## License

The `messaging` library is released under the [MIT License](https://github.com/eventide-project/messaging/blob/master/MIT-License.txt).
The `messaging` library is released under the [MIT License](https://github.com/eventide-project/messaging-postgres/blob/master/MIT-License.txt).
2 changes: 1 addition & 1 deletion init.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
require_relative './load_path'
require_relative 'load_path'

require 'messaging'
Empty file modified lib/messaging.rb
100755 → 100644
Empty file.
1 change: 0 additions & 1 deletion lib/messaging/controls.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@
require 'messaging/controls/message_data'
require 'messaging/controls/message'
require 'messaging/controls/batch'
require 'messaging/controls/write'
require 'messaging/controls/settings'
require 'messaging/controls/handler'
15 changes: 0 additions & 15 deletions lib/messaging/controls/write.rb

This file was deleted.

56 changes: 19 additions & 37 deletions lib/messaging/write.rb
Original file line number Diff line number Diff line change
@@ -1,48 +1,30 @@
module Messaging
module Write
class Error < RuntimeError; end

def self.included(cls)
cls.class_exec do
include Dependency
include Virtual
include Log::Dependency

dependency :message_writer
dependency :telemetry, ::Telemetry
class Write
include Dependency
include Virtual
include Log::Dependency

extend Build
extend Call
extend Configure

abstract :configure
class Error < RuntimeError; end

const_set :Substitute, Substitute
end
end
dependency :message_writer, MessageStore::Write
dependency :telemetry, ::Telemetry

module Build
def build(session: nil)
instance = new
instance.configure(session: session)
::Telemetry.configure instance
instance
end
def self.build(session: nil)
instance = new
MessageStore::Write.configure(instance, attr_name: :message_writer, session: session)
::Telemetry.configure(instance)
instance
end

module Configure
def configure(receiver, session: nil, attr_name: nil)
attr_name ||= :write
instance = build(session: session)
receiver.public_send "#{attr_name}=", instance
end
def self.configure(receiver, session: nil, attr_name: nil)
attr_name ||= :write
instance = build(session: session)
receiver.public_send "#{attr_name}=", instance
end

module Call
def call(message, stream_name, expected_version: nil, reply_stream_name: nil, session: nil)
instance = build(session: session)
instance.(message, stream_name, expected_version: expected_version, reply_stream_name: reply_stream_name)
end
def self.call(message, stream_name, expected_version: nil, reply_stream_name: nil, session: nil)
instance = build(session: session)
instance.(message, stream_name, expected_version: expected_version, reply_stream_name: reply_stream_name)
end

def call(message_or_batch, stream_name, expected_version: nil, reply_stream_name: nil)
Expand Down
7 changes: 2 additions & 5 deletions lib/messaging/write/substitute.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Messaging
module Write
class Write
module Substitute
def self.build
Substitute::Write.build.tap do |substitute_writer|
Expand All @@ -10,9 +10,7 @@ def self.build

Error = Class.new(RuntimeError)

class Write
include Messaging::Write

class Write < Messaging::Write
attr_accessor :sink

def raise_expected_version_error
Expand All @@ -32,7 +30,6 @@ def call(*args, **keyword_args)
end
alias :write :call

## Should never have had an exclamation mark - Scott, Tue Jan 17 2023
def raise_expected_version_error!
self.raise_expected_version_error = true
nil
Expand Down
5 changes: 4 additions & 1 deletion messaging.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Gem::Specification.new do |s|
s.name = 'evt-messaging'
s.version = '2.7.0.1'
s.summary = 'Common primitives for platform-specific messaging implementations for Eventide'
s.summary = 'Eventide messaging for Postgres'
s.description = ' '

s.authors = ['The Eventide Project']
Expand All @@ -15,6 +15,9 @@ Gem::Specification.new do |s|
s.platform = Gem::Platform::RUBY
s.required_ruby_version = '>= 2.4.0'

## Remove after message store is published w/ pg dependency
s.add_runtime_dependency 'pg'

s.add_runtime_dependency 'evt-message_store'
s.add_runtime_dependency 'evt-settings'

Expand Down
14 changes: 14 additions & 0 deletions settings/message_store_postgres.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"dbname": "message_store",
"host": "localhost",
"hostaddr": "127.0.0.1",
"port": 5432,
"user": "message_store",
"password": null,
"connect_timeout": null,
"options": null,
"sslmode": null,
"krbsrvname": null,
"gsslib": null,
"service": null
}
29 changes: 29 additions & 0 deletions test/automated/write/batch/no_id.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require_relative '../../automated_init'

context "Write" do
context "Batch" do
context "No Message IDs" do
stream_name = Controls::StreamName.example

batch, values = Controls::Batch.example(id: :none)

batch.each do |message|
assert(message.id.nil?)
end

position = Write.(batch, stream_name)

context "Individual Events are Written" do
2.times do |i|
read_message = MessageStore::Get.(stream_name, position: i, batch_size: 1).first

context "Assigns an ID" do
test "Event #{i + 1}" do
refute(read_message.id.nil?)
end
end
end
end
end
end
end
2 changes: 1 addition & 1 deletion test/automated/write/batch/reply.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

batch = [message_1, message_2]

write = Controls::Write.example
write = Write.new

test "Is an error" do
assert_raises(Messaging::Write::Error) do
Expand Down
3 changes: 3 additions & 0 deletions test/automated/write/batch/reply_is_an_error.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require_relative '../../automated_init'

comment "Tested in Messaging generalization library"
25 changes: 25 additions & 0 deletions test/automated/write/batch/write.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require_relative '../../automated_init'

context "Write" do
context "Batch" do
stream_name = Controls::StreamName.example

batch, values = Controls::Batch.example

last_written_position = Write.(batch, stream_name)

test "Last written position" do
assert(last_written_position == 1)
end

context "Individual Events are Written" do
2.times do |i|
read_message = MessageStore::Get.(stream_name, position: i, batch_size: 1).first

test "Event #{i + 1}" do
assert(read_message.data[:some_attribute] == values[i])
end
end
end
end
end
42 changes: 42 additions & 0 deletions test/automated/write/batch/write_initial.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
require_relative '../../automated_init'

context "Write" do
context "Batch" do
context "Writing the initial message to a stream that has not been created yet" do
stream_name = Controls::StreamName.example

batch, values = Controls::Batch.example

write = Write.build

write.initial(batch, stream_name)

context "Individual Events are Written" do
2.times do |i|
read_message = MessageStore::Get.(stream_name, position: i, batch_size: 1).first

test "Event #{i + 1}" do
assert(read_message.data[:some_attribute] == values[i])
end
end
end
end

context "Writing the initial message to a stream that already exists" do
stream_name = Controls::StreamName.example

batch = Controls::Batch::Messages.example

write = Write.build

message = Controls::Message.example
Write.(message, stream_name)

test "Is an error" do
assert_raises(MessageStore::ExpectedVersion::Error) do
write.initial(batch, stream_name)
end
end
end
end
end
24 changes: 24 additions & 0 deletions test/automated/write/batch/write_with_reply_stream.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
require_relative '../../automated_init'

context "Write" do
context "Batch" do
context "With Reply Stream" do
stream_name = Controls::StreamName.example
reply_stream_name = Controls::StreamName.example

batch, values = Controls::Batch.example

Write.(batch, stream_name, reply_stream_name: reply_stream_name)

context "Individual Events are Written" do
2.times do |i|
read_message = MessageStore::Get.(stream_name, position: i, batch_size: 1).first

test "Event #{i + 1}" do
assert(read_message.data[:some_attribute] == values[i])
end
end
end
end
end
end
29 changes: 29 additions & 0 deletions test/automated/write/expected_version.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
require_relative '../automated_init'

context "Write" do
context "Single Message" do
stream_name = Controls::StreamName.example(category: 'testWrongVersion')

message_1 = Controls::Message.example

Write.(message_1, stream_name)

message_2 = Controls::Message.example

context "Right Version" do
test "Succeeds" do
refute_raises(MessageStore::ExpectedVersion::Error) do
Write.(message_2, stream_name, expected_version: 0)
end
end
end

context "Wrong Version" do
test "Fails" do
assert_raises(MessageStore::ExpectedVersion::Error) do
Write.(message_2, stream_name, expected_version: 11)
end
end
end
end
end
21 changes: 21 additions & 0 deletions test/automated/write/message/no_id.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require_relative '../../automated_init'

context "Write" do
context "Message" do
context "No ID" do
stream_name = Controls::StreamName.example

message = Controls::Message.example(id: :none)

assert(message.id.nil?)

position = Write.(message, stream_name)

read_message = MessageStore::Get.(stream_name, position: position, batch_size: 1).first

test "Assigns an ID" do
refute(read_message.id.nil?)
end
end
end
end
26 changes: 26 additions & 0 deletions test/automated/write/message/reply.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
require_relative '../../automated_init'

context "Write" do
context "Reply" do
context "Message" do
message = Controls::Message.example

reply_stream_name = Controls::StreamName.example
message.metadata.reply_stream_name = reply_stream_name

write = Write.build

position = write.reply(message)

read_message = MessageStore::Get.(reply_stream_name, position: position, batch_size: 1).first

test "Writes the message to the reply stream" do
assert(read_message.data == message.to_h)
end

test "Clears the reply stream from the metadata" do
assert(read_message.metadata[:reply_stream_name].nil?)
end
end
end
end
Loading