Module: PgEventstore
- Defined in:
- lib/pg_eventstore.rb,
lib/pg_eventstore/cli.rb,
lib/pg_eventstore/web.rb,
lib/pg_eventstore/event.rb,
lib/pg_eventstore/utils.rb,
lib/pg_eventstore/client.rb,
lib/pg_eventstore/config.rb,
lib/pg_eventstore/errors.rb,
lib/pg_eventstore/stream.rb,
lib/pg_eventstore/queries.rb,
lib/pg_eventstore/version.rb,
lib/pg_eventstore/callbacks.rb,
lib/pg_eventstore/partition.rb,
lib/pg_eventstore/connection.rb,
lib/pg_eventstore/middleware.rb,
lib/pg_eventstore/maintenance.rb,
lib/pg_eventstore/sql_builder.rb,
lib/pg_eventstore/commands/read.rb,
lib/pg_eventstore/pg_connection.rb,
lib/pg_eventstore/cli/exit_codes.rb,
lib/pg_eventstore/commands/append.rb,
lib/pg_eventstore/web/application.rb,
lib/pg_eventstore/abstract_command.rb,
lib/pg_eventstore/commands/link_to.rb,
lib/pg_eventstore/event_serializer.rb,
lib/pg_eventstore/commands/multiple.rb,
lib/pg_eventstore/event_deserializer.rb,
lib/pg_eventstore/rspec/test_helpers.rb,
lib/pg_eventstore/event_class_resolver.rb,
lib/pg_eventstore/commands/delete_event.rb,
lib/pg_eventstore/queries/event_queries.rb,
lib/pg_eventstore/web/paginator/helpers.rb,
lib/pg_eventstore/commands/delete_stream.rb,
lib/pg_eventstore/queries/links_resolver.rb,
lib/pg_eventstore/cli/parsers/base_parser.rb,
lib/pg_eventstore/cli/commands/base_command.rb,
lib/pg_eventstore/cli/commands/help_command.rb,
lib/pg_eventstore/queries/partition_queries.rb,
lib/pg_eventstore/web/subscriptions/helpers.rb,
lib/pg_eventstore/cli/parsers/default_parser.rb,
lib/pg_eventstore/subscriptions/basic_runner.rb,
lib/pg_eventstore/subscriptions/runner_state.rb,
lib/pg_eventstore/subscriptions/subscription.rb,
lib/pg_eventstore/cli/parser_options/metadata.rb,
lib/pg_eventstore/queries/maintenance_queries.rb,
lib/pg_eventstore/queries/transaction_queries.rb,
lib/pg_eventstore/extensions/options_extension.rb,
lib/pg_eventstore/web/paginator/base_collection.rb,
lib/pg_eventstore/extensions/callbacks_extension.rb,
lib/pg_eventstore/query_builders/basic_filtering.rb,
lib/pg_eventstore/subscriptions/commands_handler.rb,
lib/pg_eventstore/subscriptions/events_processor.rb,
lib/pg_eventstore/cli/parser_options/base_options.rb,
lib/pg_eventstore/cli/parsers/subscription_parser.rb,
lib/pg_eventstore/query_builders/events_filtering.rb,
lib/pg_eventstore/subscriptions/subscriptions_set.rb,
lib/pg_eventstore/web/paginator/events_collection.rb,
lib/pg_eventstore/web/subscriptions/subscriptions.rb,
lib/pg_eventstore/cli/try_unlock_subscriptions_set.rb,
lib/pg_eventstore/commands/all_stream_read_grouped.rb,
lib/pg_eventstore/web/subscriptions/set_collection.rb,
lib/pg_eventstore/subscriptions/subscription_feeder.rb,
lib/pg_eventstore/subscriptions/subscription_runner.rb,
lib/pg_eventstore/cli/parser_options/default_options.rb,
lib/pg_eventstore/cli/try_to_delete_subscriptions_set.rb,
lib/pg_eventstore/query_builders/partitions_filtering.rb,
lib/pg_eventstore/subscriptions/subscriptions_manager.rb,
lib/pg_eventstore/web/paginator/stream_ids_collection.rb,
lib/pg_eventstore/web/subscriptions/subscriptions_set.rb,
lib/pg_eventstore/commands/regular_stream_read_grouped.rb,
lib/pg_eventstore/web/paginator/event_types_collection.rb,
lib/pg_eventstore/commands/system_stream_read_paginated.rb,
lib/pg_eventstore/extensions/using_connection_extension.rb,
lib/pg_eventstore/subscriptions/subscriptions_lifecycle.rb,
lib/pg_eventstore/web/paginator/stream_names_collection.rb,
lib/pg_eventstore/commands/regular_stream_read_paginated.rb,
lib/pg_eventstore/extensions/callback_handlers_extension.rb,
lib/pg_eventstore/subscriptions/runner_recovery_strategy.rb,
lib/pg_eventstore/cli/commands/stop_subscriptions_command.rb,
lib/pg_eventstore/cli/parser_options/subscription_options.rb,
lib/pg_eventstore/cli/wait_for_subscriptions_set_shutdown.rb,
lib/pg_eventstore/cli/commands/start_subscriptions_command.rb,
lib/pg_eventstore/web/paginator/stream_contexts_collection.rb,
lib/pg_eventstore/subscriptions/subscription_runners_feeder.rb,
lib/pg_eventstore/subscriptions/subscriptions_set_lifecycle.rb,
lib/pg_eventstore/subscriptions/queries/subscription_queries.rb,
lib/pg_eventstore/subscriptions/subscription_feeder_commands.rb,
lib/pg_eventstore/subscriptions/subscription_runner_commands.rb,
lib/pg_eventstore/web/subscriptions/with_state/subscriptions.rb,
lib/pg_eventstore/commands/event_modifiers/prepare_link_event.rb,
lib/pg_eventstore/web/subscriptions/with_state/set_collection.rb,
lib/pg_eventstore/commands/event_modifiers/prepare_regular_event.rb,
lib/pg_eventstore/subscriptions/subscription_handler_performance.rb,
lib/pg_eventstore/web/subscriptions/with_state/subscriptions_set.rb,
lib/pg_eventstore/subscriptions/extensions/base_command_extension.rb,
lib/pg_eventstore/subscriptions/queries/subscriptions_set_queries.rb,
lib/pg_eventstore/subscriptions/subscription_feeder_commands/base.rb,
lib/pg_eventstore/subscriptions/subscription_feeder_commands/ping.rb,
lib/pg_eventstore/subscriptions/subscription_feeder_commands/stop.rb,
lib/pg_eventstore/subscriptions/subscription_runner_commands/base.rb,
lib/pg_eventstore/subscriptions/subscription_runner_commands/stop.rb,
lib/pg_eventstore/subscriptions/subscription_runner_commands/start.rb,
lib/pg_eventstore/cli/commands/callback_handlers/start_cmd_handlers.rb,
lib/pg_eventstore/subscriptions/queries/subscription_command_queries.rb,
lib/pg_eventstore/subscriptions/subscription_feeder_commands/restore.rb,
lib/pg_eventstore/subscriptions/subscription_runner_commands/restore.rb,
lib/pg_eventstore/web/subscriptions/subscriptions_to_set_association.rb,
lib/pg_eventstore/subscriptions/subscription_feeder_commands/stop_all.rb,
lib/pg_eventstore/subscriptions/subscription_feeder_commands/start_all.rb,
lib/pg_eventstore/subscriptions/extensions/command_class_lookup_extension.rb,
lib/pg_eventstore/subscriptions/queries/subscriptions_set_command_queries.rb,
lib/pg_eventstore/subscriptions/callback_handlers/commands_handler_handlers.rb,
lib/pg_eventstore/subscriptions/callback_handlers/events_processor_handlers.rb,
lib/pg_eventstore/subscriptions/subscription_runner_commands/reset_position.rb,
lib/pg_eventstore/subscriptions/command_handlers/subscription_feeder_commands.rb,
lib/pg_eventstore/subscriptions/runner_recovery_strategies/restore_connection.rb,
lib/pg_eventstore/subscriptions/callback_handlers/subscription_feeder_handlers.rb,
lib/pg_eventstore/subscriptions/callback_handlers/subscription_runner_handlers.rb,
lib/pg_eventstore/subscriptions/command_handlers/subscription_runners_commands.rb,
lib/pg_eventstore/subscriptions/runner_recovery_strategies/restore_subscription_feeder.rb,
lib/pg_eventstore/subscriptions/runner_recovery_strategies/restore_subscription_runner.rb
Defined Under Namespace
Modules: CLI, CommandHandlers, Commands, Extensions, Middleware, QueryBuilders, RunnerRecoveryStrategies, RunnerRecoveryStrategy, TestHelpers, Web
Classes: BasicRunner, Callbacks, Client, Config, Connection, EmptyChunkFedError, Error, Event, EventClassResolver, Maintenance, MissingPartitions, NotPersistedEventError, Partition, RecordNotFound, Stream, StreamNotFoundError, Subscription, SubscriptionAlreadyLockedError, SubscriptionsManager, SubscriptionsSet, SystemStreamError, TooManyRecordsToLockError, Utils, WrappedException, WrongExpectedRevisionError, WrongLockIdError
Constant Summary
collapse
- DEFAULT_CONFIG =
:default
- VERSION =
'1.13.2'
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.logger ⇒ Logger?
35
36
37
|
# File 'lib/pg_eventstore.rb', line 35
def logger
@logger
end
|
.mutex ⇒ Object
Returns the value of attribute mutex.
31
32
33
|
# File 'lib/pg_eventstore.rb', line 31
def mutex
@mutex
end
|
Class Method Details
.available_configs ⇒ Array<Symbol>
56
57
58
|
# File 'lib/pg_eventstore.rb', line 56
def available_configs
@config.keys
end
|
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/pg_eventstore.rb', line 62
def config(name = DEFAULT_CONFIG)
return @config[name] if @config[name]
error_message = <<~TEXT
Could not find #{name.inspect} config. You can define it like this:
PgEventstore.configure(name: #{name.inspect}) do |config|
# your config goes here
end
TEXT
raise error_message
end
|
Creates a Config if not exists and yields it to the given block.
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/pg_eventstore.rb', line 40
def configure(name: DEFAULT_CONFIG)
mutex.synchronize do
@config[name] = @config[name] ? Config.new(name: name, **@config[name].options_hash) : Config.new(name: name)
connection_config_was = @config[name].connection_options
yield(@config[name]).tap do
@config[name].freeze
next if connection_config_was == @config[name].connection_options
@connection.delete(name)
end
end
end
|
Look ups and returns a Connection, based on the given config. If not exists - it creates one. This operation is a thread-safe
78
79
80
81
82
|
# File 'lib/pg_eventstore.rb', line 78
def connection(name = DEFAULT_CONFIG)
mutex.synchronize do
@connection[name] ||= Connection.new(**config(name).connection_options)
end
end
|
.subscriptions_manager(config_name = DEFAULT_CONFIG, subscription_set:, max_retries: nil, retries_interval: nil, force_lock: false) ⇒ PgEventstore::SubscriptionsManager
90
91
92
93
94
95
96
97
98
99
|
# File 'lib/pg_eventstore.rb', line 90
def subscriptions_manager(config_name = DEFAULT_CONFIG, subscription_set:, max_retries: nil, retries_interval: nil,
force_lock: false)
SubscriptionsManager.new(
config: config(config_name),
set_name: subscription_set,
max_retries: max_retries,
retries_interval: retries_interval,
force_lock: force_lock
)
end
|