Skip to content

Commit

Permalink
Merge pull request #3205 from esl/mu-configurable-pool-name-for-domai…
Browse files Browse the repository at this point in the history
…n-service

Make pool_name configurable for service_domain_db
  • Loading branch information
vkatsuba committed Aug 5, 2021
2 parents fa5e5a2 + 7da39d8 commit 771f102
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
15 changes: 15 additions & 0 deletions doc/developers-guide/domain_management.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,21 @@ Configure host-type first to delete such domains.

## Service options

```toml
[services.service_domain_db]
db_pool = "global"
event_cleaning_interval = 1800
event_max_age = 7200
```

### `db_pool`
By default, this service uses the RDBMS connection pool configured with the scope `"global"`.
You can put a specific host type there to use the pool with the `"host"` or `"single_host"` scope for that particular host type. See [outgoing connections docs](../advanced-configuration/outgoing-connections.md) for more information about pool scopes.

* **Syntax:** string
* **Default:** `global`
* **Example:** `db_pool = "my_host_type"`

### `event_cleaning_interval`
The number of seconds between cleaning attempts of the `domain_events` table.
* **Syntax:** positive integer
Expand Down
5 changes: 4 additions & 1 deletion src/domain/mongoose_domain_sql.erl
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,10 @@ row_to_map({HostType, Enabled}) ->
#{host_type => HostType, enabled => mongoose_rdbms:to_bool(Enabled)}.

get_db_pool() ->
hd(ejabberd_config:get_global_option(hosts)).
proplists:get_value(db_pool, get_service_opts(), global).

get_service_opts() ->
mongoose_service:get_service_opts(service_domain_db).

transaction(F) ->
Pool = get_db_pool(),
Expand Down
4 changes: 3 additions & 1 deletion src/domain/service_domain_db.erl
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ config_spec() ->
<<"event_cleaning_interval">> => #option{type = integer,
validate = positive},
<<"event_max_age">> => #option{type = integer,
validate = positive}
validate = positive},
<<"db_pool">> => #option{type = atom,
validate = pool_name}
}}.

start_link() ->
Expand Down

0 comments on commit 771f102

Please sign in to comment.