envato / event_sourcery

A library for building event sourced applications in Ruby
MIT License
84 stars 10 forks source link

Allow passing an after_fork lambda to ESPRunner #199

Closed twe4ked closed 6 years ago

twe4ked commented 6 years ago

We're going to be using this to set the application_name on our Postgres connections so we can see where queries are coming from in pg_stat_activity.

after_fork = -> (event_processor) {
  [App.projections_database, App.event_store_database].each do |connection|
    processor_name = connection.literal(event_processor.processor_name)
    connection.execute("SET application_name TO '#{processor_name}'")
  end
}