-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #185 from MrAnno/max-elements
Configurable batch sizes with the `max_elements` subscription option
- Loading branch information
Showing
16 changed files
with
181 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
common/src/database/schema/postgres/_013_add_max_elements_field_in_subscriptions_table.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use anyhow::Result; | ||
use async_trait::async_trait; | ||
use deadpool_postgres::Transaction; | ||
|
||
use crate::{database::postgres::PostgresMigration, migration}; | ||
|
||
pub(super) struct AddMaxElementsFieldInSubscriptionsTable; | ||
migration!( | ||
AddMaxElementsFieldInSubscriptionsTable, | ||
13, | ||
"add max_elements field in subscriptions table" | ||
); | ||
|
||
#[async_trait] | ||
impl PostgresMigration for AddMaxElementsFieldInSubscriptionsTable { | ||
async fn up(&self, tx: &mut Transaction) -> Result<()> { | ||
tx.execute( | ||
"ALTER TABLE subscriptions ADD COLUMN IF NOT EXISTS max_elements INT4;", | ||
&[], | ||
) | ||
.await?; | ||
Ok(()) | ||
} | ||
|
||
async fn down(&self, tx: &mut Transaction) -> Result<()> { | ||
tx.execute( | ||
"ALTER TABLE subscriptions DROP COLUMN IF EXISTS max_elements", | ||
&[], | ||
) | ||
.await?; | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
common/src/database/schema/sqlite/_013_add_max_elements_field_in_subscriptions_table.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
use anyhow::{anyhow, Result}; | ||
use rusqlite::Connection; | ||
|
||
use crate::database::sqlite::SQLiteMigration; | ||
use crate::migration; | ||
|
||
pub(super) struct AddMaxElementsFieldInSubscriptionsTable; | ||
migration!( | ||
AddMaxElementsFieldInSubscriptionsTable, | ||
13, | ||
"add max_elements field in subscriptions table" | ||
); | ||
|
||
impl SQLiteMigration for AddMaxElementsFieldInSubscriptionsTable { | ||
fn up(&self, conn: &Connection) -> Result<()> { | ||
conn.execute("ALTER TABLE subscriptions ADD COLUMN max_elements INTEGER", []) | ||
.map_err(|err| anyhow!("SQLiteError: {}", err))?; | ||
Ok(()) | ||
} | ||
|
||
fn down(&self, conn: &Connection) -> Result<()> { | ||
conn.execute("ALTER TABLE subscriptions DROP COLUMN max_elements", []) | ||
.map_err(|err| anyhow!("SQLiteError: {}", err))?; | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.