Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • Jan 30 14:49
    slashdotdash edited #169
  • Jan 30 14:48
    Freyskeyd commented #249
  • Jan 30 14:48
    Freyskeyd closed #249
  • Jan 30 10:28
    slashdotdash commented #249
  • Jan 30 09:08
    Freyskeyd commented #249
  • Jan 29 11:37
    Freyskeyd commented #187
  • Jan 29 11:34
    Freyskeyd synchronize #249
  • Jan 29 10:50
    Freyskeyd synchronize #249
  • Jan 29 10:16
    slashdotdash closed #231
  • Jan 29 10:16
    slashdotdash commented #231
  • Jan 29 09:48
    Freyskeyd commented #231
  • Jan 29 09:10
    Freyskeyd synchronize #249
  • Jan 28 15:49
    Freyskeyd edited #249
  • Jan 28 15:32
    Freyskeyd synchronize #249
  • Jan 28 15:04
    Freyskeyd opened #249
  • Jan 28 11:20
    imetallica closed #119
  • Jan 28 11:20
    imetallica commented #119
  • Jan 28 10:40
    Freyskeyd commented #119
  • Jan 28 10:40
    slashdotdash commented #184
  • Jan 28 10:39
    Freyskeyd commented #52
Romain Tribes
@Sephi-Chan
Thanks ! :)
Ah ah it break tests ^^'
It's awful how tests and console can be different :'(
Since there are no more symbols the access via . doesn't work anymore (I suppose)
Romain Tribes
@Sephi-Chan
defmodule Seelies.ConvoyReachesDestination do
  defstruct [:game_id, :convoy_id]

  def execute(game = %Seelies.Game{game_id: game_id}, event = %Seelies.ConvoyReachesDestination{convoy_id: convoy_id}) do
    IO.inspect({:game, game})
    IO.inspect({:event, event}) # => {:event, %Seelies.ConvoyReachesDestination{convoy_id: "c1", game_id: "42"}}

    %Seelies.ConvoyReachedDestination{game_id: game_id, convoy_id: convoy_id}
  end
end
    assert_receive_event(Seelies.ConvoyReachedDestination, fn (event) ->
      IO.inspect({:received_event, event}) # => {:received_event, %Seelies.ConvoyReachedDestination{convoy_id: nil, game_id: nil}}

      assert event.game_id == "42"
      assert event.convoy_id == "c1"
    end)
It's strange that the event is "emptied" in the assertion
I have 8 failing tests: all the tests using assert_receive_event blocks.
Dave Vallance
@dvallance
Quick question. Is there anything built into commanded that would help convert a custom event (just a struct) into a Commanded.EventStore.EventData type. I'm looking at using Commanded.EventStore.append_to_stream and see that it requires the 'EventData' .
...just as a follow up; In case there is some suggestion around this approach. What I am trying to achieve is basically just kicking off a process manager that is going to coordinate a few aggregates and I really just need the "kickoff" event there to act on. So I don't want to have to put the boiler plate of an aggregate and a dispatch just to get that event in there. Is that reasonable?
Ben Smith
@slashdotdash
Commanded.Event.Mapper is likely what you want to use.
I’m not sure why this module doesn’t have public documentation as it provides a convenient event mapping function. I will add it to the docs.
Dave Vallance
@dvallance
@slashdotdash sweet. Yes this exactly what i wanted!
Quite often we just want to kickoff a process and just need that event in there but didn't really know the best way to just get an event written to act on. If the public docs described something like this it might be very useful ;)
Marco Milanesi
@kpanic
hi, I have multiple routers with multiple aggregates. Not sure if it's my fault (commanded version 0.19.1) When I invoke RouterOne.dispatch(%Create{}) and I do RouterTwo.dispatch(%DoSomethingElse{} looks like the aggregate of RouterTwo receives the Created event emitted from the aggregate associated to RouterOne -- I am pretty sure I am doing something wrong.
Thanks!
Ben Smith
@slashdotdash
Do both aggregates share the same identity?
Marco Milanesi
@kpanic
@slashdotdash aggregates are different, but identified by the same identity key
Like the name of the identity (named :id)
Ben Smith
@slashdotdash

By default aggregate events are written into a stream using their identity. If you have two different aggregates with the same identity their events will be written into the same stream.

You can use the identity prefix router setting to ensure each aggregate’s event are persisted into different streams, even though they share the same identity:

defmodule MyRouter do
  use Commanded.Commands.Router

  identify Foo, by: :id, prefix: "foo-"
  identify Bar, by: :id, prefix: "bar-“
end
Marco Milanesi
@kpanic
awesome! I will try that! thanks!
Ben Smith
@slashdotdash
The above also helps to distinguish who own which events in the event store by looking at the prefix prepended to the stream name
  • Foo with an id of 1 - stream will be named foo-1
  • Bar with an id of 1 - stream will be named bar-1
You can choose whatever prefix you like, but don’t change it once you have production events otherwise the aggregate won’t be able to load the events using the old prefix (unless you update the stream name in the ES database).
Marco Milanesi
@kpanic
@slashdotdash cool, looks like it's working like a charm. Really appreciate.
Ben Smith
@slashdotdash
:smiley:
Marco Milanesi
@kpanic
btw with a CompositeRouter.dispatch is it possible to dispatch a list of commands? ;)
Ben Smith
@slashdotdash
No, it’s only used to combine multiple routers
Marco Milanesi
@kpanic
gotcha, ok. thanks again :wink:
Francesco Belladonna
@Fire-Dragon-DoL

Hello, have a question, I have a process manager which is interested in only one event and it always dispatch a specific command (data obtained fromt he event).

What should I put in interested? since I only have one event, there is a start, but there is no "finish"

Ben Smith
@slashdotdash
Could you use an event handler instead if all the information needed for the command is contained within the single event?
Dave Vallance
@dvallance
@Fire-Dragon-DoL Don't you just want to use a EventHandler then? The process manager is to coordinate aggretgates.
Dave Vallance
@dvallance
@slashdotdash Do you have to be really be diligent in closing ProcessManager instances? e.g. {:stop, instance_id} or is there a way to have an instance terminate itself. Like the lifespan option on aggregates?
Ben Smith
@slashdotdash
You can use the idle timeout feature to stop PM instances after a period of inactivity
This will reduce memory consumption (and the only downside is higher latency if/when the instance receives another event).
The {:stop, process_id} value is used to both terminate the instance process and delete its persisted state.
Dave Vallance
@dvallance
I saw that in the doc's but thought that it was for the ProcessManager itself and not for the instances that it spawns.
Ben Smith
@slashdotdash
Sorry, wrong link
It’s in the docs
Look up "idle timeout"
Dave Vallance
@dvallance
Sweet!
Is there a way to hook into the idle timeout? I would like to actually tell it to stop and remove its persisted state?
Francesco Belladonna
@Fire-Dragon-DoL
@slashdotdash I think with the handler there is a problem were events might be detected twice (or more)
Dave Vallance
@dvallance
@Fire-Dragon-DoL the event handler will update a "event seen" value and know its already processed an event. ...however if it crashes before returning the value and it restarts it could redo whatever code you had in the handler, so that code you might want to make sure is idempotent
Yury Kotov
@beorc
@slashdotdash What is the easiest way to understand which event handler fails to handle en event on consistency timeout?
Ben Smith
@slashdotdash
@beorc There’s no easy whay to determine which handler(s) failed.
vheathen
@vheathen

Returning to versioning: where do you think it's better to put event version number? Event struct itself, command? I've seen recommendation to use metadata field for such side things (like current username, event version, event timestamp) to keep event itself clean, and I believe its a good idea. But in that case where to keep current version? And on every command invocation programmer should remember to put this info into a metadata field.

It could be an option to put version info into a command and create a middleware that will extract this info and put it into the meta. Is it a good idea?

Peter Richards
@pejrich

Hi. I'm not using AggregateLifespan anywhere, but I am getting the following error:

function Commanded.Aggregates.DefaultLifespan.after_error/0 is undefined or private. Did you mean one of:

      * after_error/1

Do I need to implement something for the aggregates to stop this error?