Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support to queue_target and queue_interval #172

Merged
merged 3 commits into from
Aug 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions guides/Getting Started.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,19 @@ EventStore is [available in Hex](https://hex.pm/packages/eventstore) and can be
url: "postgres://postgres:postgres@localhost/eventstore",
pool_size: 10
pool_overflow: 5
queue_target: 5_000
queue_interval: 10_000
```

The database connection pool configuration options are:

- `:pool_size` - The number of connections (default: `10`).
- `:pool_overflow` - The maximum number of overflow connections to start if all connections are checked out (default: `0`).

Handling requests is done through a queue. When DBConnection is started, there are two relevant options to control the queue:

- `:queue_target` - in milliseconds (default: `50`).
- `:queue_interval` - in milliseconds (default: `1000`).

4. Add your event store module to the `event_stores` list for your app in mix config:

Expand Down
10 changes: 7 additions & 3 deletions lib/event_store/config.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule EventStore.Config do
Provides access to the EventStore configuration.
"""

@integer_url_query_params ["pool_size"]
@integer_url_query_params ["pool_size", "queue_target", "queue_interval"]

@doc """
Get the event store configuration for the environment.
Expand Down Expand Up @@ -163,15 +163,19 @@ defmodule EventStore.Config do

[
pool_size: 10,
pool_overflow: 0
pool_overflow: 0,
queue_target: 5_000,
queue_interval: 10_000
]
|> Keyword.merge(config)
|> Keyword.take(
@default_postgrex_opts ++
[
:pool,
:pool_size,
:pool_overflow
:pool_overflow,
:queue_target,
:queue_interval
]
)
|> Keyword.put(:backoff_type, :exp)
Expand Down