diff --git a/rails_event_store-rspec/README.md b/rails_event_store-rspec/README.md index 217fe6b64f..955fbd6755 100644 --- a/rails_event_store-rspec/README.md +++ b/rails_event_store-rspec/README.md @@ -86,7 +86,7 @@ In a simplest form it would read all streams backward up to a page limit (100 ev ```ruby event_store = RailsEventStore::Client.new -event_store.publish_event(OrderPlaced.new(data: { order_id: 42 })) +event_store.publish(OrderPlaced.new(data: { order_id: 42 })) expect(event_store).to have_published(an_event(OrderPlaced)) ``` @@ -95,7 +95,7 @@ Expectation can be narrowed to the specific stream. ```ruby event_store = RailsEventStore::Client.new -event_store.publish_event(OrderPlaced.new(data: { order_id: 42 }), stream_name: "Order$42") +event_store.publish(OrderPlaced.new(data: { order_id: 42 }), stream_name: "Order$42") expect(event_store).to have_published(an_event(OrderPlaced)).in_stream("Order$42") ``` diff --git a/railseventstore.org/source/docs/correlation_causation.html.md b/railseventstore.org/source/docs/correlation_causation.html.md index 82f0775e1a..62e5396bb1 100644 --- a/railseventstore.org/source/docs/correlation_causation.html.md +++ b/railseventstore.org/source/docs/correlation_causation.html.md @@ -22,7 +22,7 @@ class MyEventHandler new_event = MyEvent.new(data: {foo: 'bar'}) new_event.correlate_with(previous_event) - event_store.publish_event(new_event) + event_store.publish(new_event) end end @@ -75,7 +75,7 @@ class MyEventHandler correlation_id: previous_event.correlation_id || previous_event.event_id, causation_id: previous_event.event_id ) do - event_store.publish_events([ + event_store.publish([ MyEvent.new(data: {foo: 'bar'}), AnotherEvent.new(data: {baz: 'bax'}), ]) diff --git a/railseventstore.org/source/docs/exceptions.html.md.erb b/railseventstore.org/source/docs/exceptions.html.md.erb index 893bca626b..ecb70f96a3 100644 --- a/railseventstore.org/source/docs/exceptions.html.md.erb +++ b/railseventstore.org/source/docs/exceptions.html.md.erb @@ -7,10 +7,10 @@ When using Rails Event Store you have to be prepared for following errors: Occurs when other writer has written to the same stream as we intended to and last stream version has changed: ```ruby -client.publish_event(OrderPlaced.new, stream_name: 'Order$1', expected_version: 0) +client.publish(OrderPlaced.new, stream_name: 'Order$1', expected_version: 0) expect do - client.publish_event(OrderCompleted.new, stream_name: 'Order$1', expected_version: 0) + client.publish(OrderCompleted.new, stream_name: 'Order$1', expected_version: 0) end.to raise_error(WrongExpectedEventVersion) ``` @@ -22,10 +22,10 @@ Occurs when you're writing same event more than once. ```ruby order_placed = OrderPlaced.new -client.publish_event(order_placed, stream_name: 'Order$1', expected_version: 0) +client.publish(order_placed, stream_name: 'Order$1', expected_version: 0) expect do - client.publish_event(order_placed, stream_name: 'Order$1', expected_version: 1) + client.publish(order_placed, stream_name: 'Order$1', expected_version: 1) end.to raise_error(WrongExpectedEventVersion) ``` @@ -39,7 +39,7 @@ If you want to have an event present in multiple streams, you have to link it wi ### RubyEventStore::InvalidExpectedVersion <% if version_above('0.30.0') %> -Occurs when invalid `exception_version` is passed in `append`, `link`, `publish_event` or `publish_events`. +Occurs when invalid `exception_version` is passed in `append_to_stream`, `link_to_stream` or `publish`. <% else %> Occurs when invalid `exception_version` is passed in `append_to_stream`, `link_to_stream`, `publish_event` or `publish_events`. <% end %> diff --git a/railseventstore.org/source/docs/expected_version.html.md b/railseventstore.org/source/docs/expected_version.html.md index 3b58d8632d..96370d799e 100644 --- a/railseventstore.org/source/docs/expected_version.html.md +++ b/railseventstore.org/source/docs/expected_version.html.md @@ -5,7 +5,7 @@ There are 3 values that you can use for providing `expected_version` when publis ## :any ```ruby -event_store.publish_event( +event_store.publish( event, stream_name: "Order-1", expected_version: :any, @@ -32,7 +32,7 @@ event_store.publish_event( You start by publishing the first event in a stream with `expected_version` being `-1` (or `:none`). That means you expect no events in the stream right now. ```ruby -event_store.publish_event( +event_store.publish( event0, stream_name: "Order-1", expected_version: -1, # or :none which is a synonym @@ -43,7 +43,7 @@ event_store.publish_event( The first published event is at position `0`. When you publish a second event you provide `expected_version: 0`. ```ruby -event_store.publish_events( +event_store.publish( [event1, event2], stream_name: "Order-1", expected_version: 0, @@ -53,7 +53,7 @@ event_store.publish_events( We published the second and third events. Their positions are `1` and `2`. That's why when you publish the next event you need to provide `expected_version: 2`. ```ruby -event_store.publish_event( +event_store.publish( event3, stream_name: "Order-1", expected_version: 2, @@ -81,7 +81,7 @@ This mode effectively acts as optimistic locking. ## :auto ```ruby -event_store.publish_event( +event_store.publish( event, stream_name: "Order-1", expected_version: :auto, @@ -95,7 +95,7 @@ There is a potential for a race condition between reading the `expected_version` ```ruby application_lock("Order-1") do # do something with Order 1... - event_store.publish_event( + event_store.publish( event, stream_name: "Order-1", expected_version: :auto, diff --git a/railseventstore.org/source/docs/link.html.md.erb b/railseventstore.org/source/docs/link.html.md.erb index 3cea64f006..f64c5153d0 100644 --- a/railseventstore.org/source/docs/link.html.md.erb +++ b/railseventstore.org/source/docs/link.html.md.erb @@ -13,7 +13,7 @@ class Order end def place - event_store.publish_event( + event_store.publish( OrderPlaced.new(data: { id: @id }), stream_name: stream_name ) diff --git a/railseventstore.org/source/docs/mapping_serialization.html.md b/railseventstore.org/source/docs/mapping_serialization.html.md index c071fd21ea..57174d0d22 100644 --- a/railseventstore.org/source/docs/mapping_serialization.html.md +++ b/railseventstore.org/source/docs/mapping_serialization.html.md @@ -113,7 +113,7 @@ end event_store = Rails.configuration.event_store -event_store.publish_event(OrderPlaced.new(data: { +event_store.publish(OrderPlaced.new(data: { 'event_id' => SecureRandom.uuid, 'order_id' => 1, 'order_amount' => BigDecimal.new('120.55'), diff --git a/railseventstore.org/source/docs/projection.html.md b/railseventstore.org/source/docs/projection.html.md index d2a7c9d8cd..2e370814d4 100644 --- a/railseventstore.org/source/docs/projection.html.md +++ b/railseventstore.org/source/docs/projection.html.md @@ -5,9 +5,9 @@ You can create a projection abstract based on single stream. ```ruby stream_name = "Customer$1" -client.publish_event(MoneyDeposited.new(data: { amount: 10 }), stream_name: stream_name) -client.publish_event(custom_event = MoneyDeposited.new(data: { amount: 20 }), stream_name: stream_name) -client.publish_event(MoneyWithdrawn.new(data: { amount: 5 }), stream_name: stream_name) +client.publish(MoneyDeposited.new(data: { amount: 10 }), stream_name: stream_name) +client.publish(custom_event = MoneyDeposited.new(data: { amount: 20 }), stream_name: stream_name) +client.publish(MoneyWithdrawn.new(data: { amount: 5 }), stream_name: stream_name) account_balance = RailsEventStore::Projection. from_stream(stream_name). @@ -38,10 +38,10 @@ account_cashflow.run(client) # => {total: 35} ## Projection based on multiple streams ```ruby -client.publish_event(MoneyDeposited.new(data: { amount: 15 }), stream_name: "Customer$1") -client.publish_event(MoneyDeposited.new(data: { amount: 25 }), stream_name: "Customer$2") -client.publish_event(custom_event = MoneyWithdrawn.new(data: { amount: 10 }), stream_name: "Customer$3") -client.publish_event(MoneyWithdrawn.new(data: { amount: 20 }), stream_name: "Customer$3") +client.publish(MoneyDeposited.new(data: { amount: 15 }), stream_name: "Customer$1") +client.publish(MoneyDeposited.new(data: { amount: 25 }), stream_name: "Customer$2") +client.publish(custom_event = MoneyWithdrawn.new(data: { amount: 10 }), stream_name: "Customer$3") +client.publish(MoneyWithdrawn.new(data: { amount: 20 }), stream_name: "Customer$3") account_balance = RailsEventStore::Projection. from_stream("Customer$1", "Customer$3"). @@ -61,10 +61,10 @@ account_balance.run(client, [:head, custom_event.event_id]) # => {total: -5} ## Projection based on all streams ```ruby -client.publish_event(MoneyDeposited.new(data: { amount: 10 }), stream_name: "Customer$1") -client.publish_event(MoneyDeposited.new(data: { amount: 10 }), stream_name: "Customer$2") -client.publish_event(custom_event = MoneyDeposited.new(data: { amount: 10 }), stream_name: "Customer$3") -client.publish_event(MoneyWithdrawn.new(data: { amount: 20 }), stream_name: "Customer$4") +client.publish(MoneyDeposited.new(data: { amount: 10 }), stream_name: "Customer$1") +client.publish(MoneyDeposited.new(data: { amount: 10 }), stream_name: "Customer$2") +client.publish(custom_event = MoneyDeposited.new(data: { amount: 10 }), stream_name: "Customer$3") +client.publish(MoneyWithdrawn.new(data: { amount: 20 }), stream_name: "Customer$4") account_balance = RailsEventStore::Projection. from_all_streams. diff --git a/railseventstore.org/source/docs/protobuf.html.md.erb b/railseventstore.org/source/docs/protobuf.html.md.erb index 5b7a439641..03621edfd5 100644 --- a/railseventstore.org/source/docs/protobuf.html.md.erb +++ b/railseventstore.org/source/docs/protobuf.html.md.erb @@ -79,7 +79,7 @@ event = RubyEventStore::Proto.new( customer_id: 123, ) ) -event_store.publish_event(event, stream_name: "Order-K3THNX9") +event_store.publish(event, stream_name: "Order-K3THNX9") ``` ## Retrieving diff --git a/railseventstore.org/source/docs/publish.html.md.erb b/railseventstore.org/source/docs/publish.html.md.erb index 553d7e1680..367e343ec9 100644 --- a/railseventstore.org/source/docs/publish.html.md.erb +++ b/railseventstore.org/source/docs/publish.html.md.erb @@ -15,7 +15,7 @@ OrderPlaced = Class.new(RailsEventStore::Event) ## Publishing an event -Then you can use `publish_event` or `publish_events` method. +Then you can use `publish` method. ```ruby stream_name = "order_1" @@ -26,7 +26,7 @@ event = OrderPlaced.new(data: { }) #publishing an event for a specific stream -event_store.publish_event(event, stream_name: stream_name) +event_store.publish(event, stream_name: stream_name) ``` ## Publishing an event with optimistic locking @@ -40,7 +40,7 @@ event = OrderPlaced.new(data: { festival_id: "b2d506fd-409d-4ec7-b02f-c6d2295c7edd" }) -event_store.publish_event( +event_store.publish( event, stream_name: "order_1", expected_version: 3 # the position of the last @@ -64,7 +64,7 @@ For more information about when should you use which one, read [expected_version Providing `stream_name` is optional (but recommended). ```ruby -event_store.publish_event(event) +event_store.publish(event) ``` <% if version_above('0.29.0') %> diff --git a/railseventstore.org/source/docs/pubsub.html.md b/railseventstore.org/source/docs/pubsub.html.md index 53c1e3b2f5..b39a8f7370 100644 --- a/railseventstore.org/source/docs/pubsub.html.md +++ b/railseventstore.org/source/docs/pubsub.html.md @@ -32,7 +32,7 @@ class CancelOrdersService order_id: order_id, ) order.cancel! - event_store.publish_event( + event_store.publish( OrderCancelled.new(data: { order_id: order.id, customer_id: order.customer_id, diff --git a/railseventstore.org/source/docs/request_metadata.html.md.erb b/railseventstore.org/source/docs/request_metadata.html.md.erb index 877d5c6c11..6b2ff2fa48 100644 --- a/railseventstore.org/source/docs/request_metadata.html.md.erb +++ b/railseventstore.org/source/docs/request_metadata.html.md.erb @@ -23,7 +23,7 @@ event.metadata # empty, unless you provided your own data called 'metadata'. If you publish an event, the special field called `metadata` will get filled in with request details: ```ruby -event_store.publish_event(MyEvent.new(data: {foo: 'bar'})) +event_store.publish(MyEvent.new(data: {foo: 'bar'})) <% if version_above('0.29.0') %> my_event = event_store.read_all_streams_backward(count: 1).first diff --git a/railseventstore.org/source/docs/rspec.html.md.erb b/railseventstore.org/source/docs/rspec.html.md.erb index d42b20515d..c5ca8fc5a5 100644 --- a/railseventstore.org/source/docs/rspec.html.md.erb +++ b/railseventstore.org/source/docs/rspec.html.md.erb @@ -84,7 +84,7 @@ In a simplest form it would read all streams backward up to a page limit (100 ev ```ruby event_store = RailsEventStore::Client.new -event_store.publish_event(OrderPlaced.new(data: { order_id: 42 })) +event_store.publish(OrderPlaced.new(data: { order_id: 42 })) expect(event_store).to have_published(an_event(OrderPlaced)) ``` @@ -93,7 +93,7 @@ Expectation can be narrowed to the specific stream. ```ruby event_store = RailsEventStore::Client.new -event_store.publish_event(OrderPlaced.new(data: { order_id: 42 }), stream_name: "Order$42") +event_store.publish(OrderPlaced.new(data: { order_id: 42 }), stream_name: "Order$42") expect(event_store).to have_published(an_event(OrderPlaced)).in_stream("Order$42") ``` diff --git a/railseventstore.org/source/docs/subscribe.html.md.erb b/railseventstore.org/source/docs/subscribe.html.md.erb index 8d480ffa2d..fe329f31a8 100644 --- a/railseventstore.org/source/docs/subscribe.html.md.erb +++ b/railseventstore.org/source/docs/subscribe.html.md.erb @@ -115,10 +115,10 @@ event_store.subscribe(handler, to: [OrderPlaced]) ``` ```ruby -event_store.publish_event(OrderPlaced.new) +event_store.publish(OrderPlaced.new) # handler is called -event_store.publish_event(OrderPlaced.new) +event_store.publish(OrderPlaced.new) # handler is called again ``` @@ -146,10 +146,10 @@ event_store.subscribe(SyncHandler, to: [OrderPlaced]) ``` ```ruby -event_store.publish_event(OrderPlaced.new(data: {customer_id: 2})) +event_store.publish(OrderPlaced.new(data: {customer_id: 2})) # SyncHandler.new.call is invoked (instance A) -event_store.publish_event(OrderPlaced.new(data: {customer_id: 3})) +event_store.publish(OrderPlaced.new(data: {customer_id: 3})) # SyncHandler.new.call is invoked (instance B) ``` @@ -160,7 +160,7 @@ Those handlers are executed immediately after events are stored in the DB. ```ruby ActiveRecord::Base.transction do order = Order.new(...).save! - event_store.publish_event( + event_store.publish( OrderPlaced.new(data:{order_id: order.id}), stream_name: "Order-#{order.id}" ) @@ -329,7 +329,7 @@ Those async handlers are scheduled immediately after events are stored in the DB ```ruby ActiveRecord::Base.transction do order = Order.new(...).save! - event_store.publish_event( + event_store.publish( OrderPlaced.new(data:{order_id: order.id}), stream_name: "Order-#{order.id}" ) @@ -378,7 +378,7 @@ event_store.subscribe(SendOrderEmail, to: [OrderPlaced]) ```ruby ActiveRecord::Base.transction do order = Order.new(...).save! - event_store.publish_event( + event_store.publish( OrderPlaced.new(data:{order_id: order.id}), stream_name: "Order-#{order.id}" ) diff --git a/railseventstore.org/source/docs/without_rails.html.md b/railseventstore.org/source/docs/without_rails.html.md index 72380549f0..bcbe3d2450 100644 --- a/railseventstore.org/source/docs/without_rails.html.md +++ b/railseventstore.org/source/docs/without_rails.html.md @@ -38,7 +38,7 @@ event_store = RubyEventStore::Client.new( repository: RailsEventStoreActiveRecord::EventRepository.new ) -event_store.publish_event(OrderPlaced.new(data: { +event_store.publish(OrderPlaced.new(data: { order_id: 1, customer_id: 47271, amount: BigDecimal.new("20.00"),