Elffuss BraidHub

kikocis/EDC public

cc2a9ff178c4 · 1.6 KiBRenderedRawPermalink
1# SQL persistence
2
3Every store in the EDC, intended as persistence for state, comes out of the box with two implementations:
4- in-memory
5- sql (postgresql dialect)
6
7By default, the `in-memory` stores are provided by the dependency injection, the `sql` implementations can be used by
8simply registering the relative extensions (e.g. `asset-index-sql`, `contract-negotiation-store-sql`, ...).
9
10## Configuration
11
12### DataSources
13
14For using `sql` extensions, a `DataSource` is needed, and it should be registered on the `DataSourceRegistry` service.
15
16The `sql-pool-apache-commons` extension takes care to create and register pooled data sources starting from configuration.
17It expects at least one data source called `default` that can be configured with `Vault` keys:
18```
19edc.datasource.default.url=...
20edc.datasource.default.name=...
21edc.datasource.default.password=...
22```
23(note: if no vault entries are found for such keys, they will be obtained from the configuration).
24
25Other datasources can be defined using the same settings structure:
26```
27edc.datasource.<datasource-name>.url=...
28edc.datasource.<datasource-name>.name=...
29edc.datasource.<datasource-name>.password=...
30```
31
32`<datasource-name>` can be a string that then can be used by the stores configuration to use specific data sources.
33
34### Using custom datasource in stores
35
36Using a custom datasource in a store can be done by configuring the setting:
37```
38edc.sql.store.<store-context>.datasource=<datasource-name>
39```
40
41This way the `<store-context>` (that could be `asset`, `contractnegotiation`...) will use the `<datasource-name>` datasource.