Skip to content

Commit

Permalink
Make pool_name configurable for service_domain_db
Browse files Browse the repository at this point in the history
  • Loading branch information
arcusfelis committed Aug 2, 2021
1 parent 9557370 commit 2b251e9
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]
pool_name = "global"
event_cleaning_interval = 1800
event_max_age = 7200
```

### `pool_name`

Pool name to use for a database connection.

* **Syntax:** atom
* **Default:** `global`
* **Example:** `pool_name = "global"`

### `event_cleaning_interval`

The number of seconds between cleaning attempts of the `domain_events` table.
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 @@ -258,7 +258,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(pool_name, 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 @@ -53,7 +53,9 @@ config_spec() ->
<<"event_cleaning_interval">> => #option{type = integer,
validate = positive},
<<"event_max_age">> => #option{type = integer,
validate = positive}
validate = positive},
<<"pool_name">> => #option{type = atom,
validate = pool_name}
}}.

start_link() ->
Expand Down

0 comments on commit 2b251e9

Please sign in to comment.