Skip to content

Commit 7bcb422

Browse files
authored
chore(postgres): s/uri/url/ to be more specific and consistent (#396)
1 parent c7f6fbc commit 7bcb422

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

docs/docs/core/initialization.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ This takes care of the following effects:
4949

5050
The following environment variables are supported:
5151

52-
* `COCOINDEX_DATABASE_URL` (required): The URI of the Postgres database to use as the internal storage, e.g. `postgres://cocoindex:cocoindex@localhost/cocoindex`
52+
* `COCOINDEX_DATABASE_URL` (required): The URL of the Postgres database to use as the internal storage, e.g. `postgres://cocoindex:cocoindex@localhost/cocoindex`
5353
* `COCOINDEX_DATABASE_USER` (optional): The username for the Postgres database. If not provided, username will come from `COCOINDEX_DATABASE_URL`.
5454
* `COCOINDEX_DATABASE_PASSWORD` (optional): The password for the Postgres database. If not provided, password will come from `COCOINDEX_DATABASE_URL`.
5555

@@ -66,9 +66,9 @@ It takes a `Settings` object as argument, which is a dataclass that contains the
6666
#### DatabaseConnectionSpec
6767

6868
`DatabaseConnectionSpec` has the following fields:
69-
* `uri` (type: `str`, required): The URI of the Postgres database to use as the internal storage, e.g. `postgres://cocoindex:cocoindex@localhost/cocoindex`.
70-
* `user` (type: `str`, optional): The username for the Postgres database. If not provided, username will come from `uri`.
71-
* `password` (type: `str`, optional): The password for the Postgres database. If not provided, password will come from `uri`.
69+
* `url` (type: `str`, required): The URL of the Postgres database to use as the internal storage, e.g. `postgres://cocoindex:cocoindex@localhost/cocoindex`.
70+
* `user` (type: `str`, optional): The username for the Postgres database. If not provided, username will come from `url`.
71+
* `password` (type: `str`, optional): The password for the Postgres database. If not provided, password will come from `url`.
7272

7373
### Example
7474

@@ -83,7 +83,7 @@ def main():
8383
cocoindex.init(
8484
cocoindex.Settings(
8585
database=cocoindex.DatabaseConnectionSpec(
86-
uri="postgres://cocoindex:cocoindex@localhost/cocoindex"
86+
url="postgres://cocoindex:cocoindex@localhost/cocoindex"
8787
)))
8888
...
8989

docs/docs/ops/storages.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ Please read and agree the license before starting the instance.
379379
The `Neo4j` storage exports each row as a relationship to Neo4j Knowledge Graph. The spec takes the following fields:
380380

381381
* `connection` (type: [auth reference](../core/flow_def#auth-registry) to `Neo4jConnectionSpec`): The connection to the Neo4j database. `Neo4jConnectionSpec` has the following fields:
382-
* `uri` (type: `str`): The URI of the Neo4j database to use as the internal storage, e.g. `bolt://localhost:7687`.
382+
* `url` (type: `str`): The URI of the Neo4j database to use as the internal storage, e.g. `bolt://localhost:7687`.
383383
* `user` (type: `str`): Username for the Neo4j database.
384384
* `password` (type: `str`): Password for the Neo4j database.
385385
* `db` (type: `str`, optional): The name of the Neo4j database to use as the internal storage, e.g. `neo4j`.

python/cocoindex/lib.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def _load_field(target: dict[str, str], name: str, env_name: str, required: bool
2424

2525
@dataclass
2626
class DatabaseConnectionSpec:
27-
uri: str
27+
url: str
2828
user: str | None = None
2929
password: str | None = None
3030

@@ -38,7 +38,7 @@ def from_env(cls) -> Self:
3838
"""Load settings from environment variables."""
3939

4040
db_kwargs: dict[str, str] = dict()
41-
_load_field(db_kwargs, "uri", "COCOINDEX_DATABASE_URL", required=True)
41+
_load_field(db_kwargs, "url", "COCOINDEX_DATABASE_URL", required=True)
4242
_load_field(db_kwargs, "user", "COCOINDEX_DATABASE_USER")
4343
_load_field(db_kwargs, "password", "COCOINDEX_DATABASE_PASSWORD")
4444
database = DatabaseConnectionSpec(**db_kwargs)

src/lib_context.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ pub struct DbPools {
7070
impl DbPools {
7171
pub async fn get_pool(&self, conn_spec: &settings::DatabaseConnectionSpec) -> Result<PgPool> {
7272
let db_pool_cell = {
73-
let key = (conn_spec.uri.clone(), conn_spec.user.clone());
73+
let key = (conn_spec.url.clone(), conn_spec.user.clone());
7474
let mut db_pools = self.pools.lock().unwrap();
7575
db_pools.entry(key).or_default().clone()
7676
};
7777
let pool = db_pool_cell
7878
.get_or_try_init(|| async move {
79-
let mut pg_options: PgConnectOptions = conn_spec.uri.parse()?;
79+
let mut pg_options: PgConnectOptions = conn_spec.url.parse()?;
8080
if let Some(user) = &conn_spec.user {
8181
pg_options = pg_options.username(user);
8282
}

src/settings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use serde::Deserialize;
22

33
#[derive(Deserialize, Debug)]
44
pub struct DatabaseConnectionSpec {
5-
pub uri: String,
5+
pub url: String,
66
pub user: Option<String>,
77
pub password: Option<String>,
88
}

0 commit comments

Comments
 (0)