Class: Synapse::Configuration::MongoEventStoreDefinitionBuilder

Inherits:
DefinitionBuilder
  • Object
show all
Defined in:
lib/synapse/configuration/event_store/mongo/event_store.rb

Overview

Definition builder used to create a Mongo-backed event store

Examples:

The minimum possible effort to build an event store

mongo_event_store do
  use_client Mongo::MongoClient.new
end

Mix it up a bit

mongo_event_store :alt_event_store do
  use_per_event_strategy

  use_serializer :alt_serializer
  use_upcaster_chain :alt_upcaster_chain
  use_template :alt_template
end

Instance Method Summary collapse

Instance Method Details

#use_client(client) ⇒ undefined

Convenience method that creates an event store template with the given Mongo client

Parameters:

  • client (Mongo::MongoClient)

Returns:

  • (undefined)


23
24
25
# File 'lib/synapse/configuration/event_store/mongo/event_store.rb', line 23

def use_client(client)
  @template = EventStore::Mongo::Template.new client
end

#use_per_commit_strategyundefined

Changes the type of storage strategy to document-per-commit

Returns:

  • (undefined)

See Also:



31
32
33
# File 'lib/synapse/configuration/event_store/mongo/event_store.rb', line 31

def use_per_commit_strategy
  @storage_strategy_type = EventStore::Mongo::DocumentPerCommitStrategy
end

#use_per_event_strategyundefined

Changes the type of storage strategy to document-per-event

Returns:

  • (undefined)

See Also:



39
40
41
# File 'lib/synapse/configuration/event_store/mongo/event_store.rb', line 39

def use_per_event_strategy
  @storage_strategy_type = EventStore::Mongo::DocumentPerEventStrategy
end

#use_serializer(serializer) ⇒ undefined

Changes the serializer to use with this event store

Parameters:

  • serializer (Symbol)

Returns:

  • (undefined)

See Also:

  • Serialization::Serializer


48
49
50
# File 'lib/synapse/configuration/event_store/mongo/event_store.rb', line 48

def use_serializer(serializer)
  @serializer = serializer
end

#use_template(template) ⇒ undefined

Changes the Mongo template to use with this event store

Parameters:

  • template (Symbol)

Returns:

  • (undefined)

See Also:



57
58
59
# File 'lib/synapse/configuration/event_store/mongo/event_store.rb', line 57

def use_template(template)
  @template = template
end

#use_upcaster_chain(upcaster_chain) ⇒ undefined

Changes the upcaster chain to use with this event store

Parameters:

  • upcaster_chain (Symbol)

Returns:

  • (undefined)

See Also:

  • Upcasting::UpcasterChain


66
67
68
# File 'lib/synapse/configuration/event_store/mongo/event_store.rb', line 66

def use_upcaster_chain(upcaster_chain)
  @upcaster_chain = upcaster_chain
end