Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
245d9af
Start adding support for sync streams
simolus3 Jun 19, 2025
65bdf1b
Add protocol changes
simolus3 Jul 1, 2025
73e15ce
Use serde_with
simolus3 Jul 1, 2025
90bcbab
Start with subscription logic
simolus3 Jul 2, 2025
5967d89
Start tracking subscriptions
simolus3 Jul 3, 2025
ae9ea85
Track subscriptions
simolus3 Jul 4, 2025
9ac34ae
Test handling default streams
simolus3 Jul 9, 2025
a0267c4
Update last_synced_at for subscriptions
simolus3 Jul 9, 2025
91eaa6d
Allow subscribing to streams
simolus3 Jul 10, 2025
6bf0bca
Expire subscriptions after TTL
simolus3 Jul 14, 2025
ff219d5
Support unsubscribing
simolus3 Jul 14, 2025
d39e201
Delete outdated subscriptions
simolus3 Jul 14, 2025
3129e4e
Include default ttl
simolus3 Jul 14, 2025
5ce30ca
New protocol format
simolus3 Jul 15, 2025
0f487d5
Fix tests
simolus3 Jul 22, 2025
9652865
More stream management tests
simolus3 Jul 22, 2025
950f448
Remove immediate parameter when unsubscribing
simolus3 Jul 22, 2025
9751005
Increase expires_at only when subscribing again
simolus3 Jul 22, 2025
db83d17
Implement new protocol format
simolus3 Aug 7, 2025
4644a82
Report errors
simolus3 Aug 7, 2025
97d447f
Update TTL behavior
simolus3 Aug 12, 2025
2c803e3
Refresh on keepalive
simolus3 Aug 12, 2025
b947528
Instruction to update expiry
simolus3 Aug 13, 2025
3016ddc
Add correct offline state
simolus3 Aug 13, 2025
e7453b5
Add offline sync state helper function
simolus3 Aug 13, 2025
a42845a
Simplify error reporting
simolus3 Aug 13, 2025
a136226
Improve comment
simolus3 Aug 13, 2025
23481d8
Use set for associated buckets
simolus3 Aug 18, 2025
c42169f
Compute progress in core extension
simolus3 Aug 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
144 changes: 144 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const_format = "0.2.34"
futures-lite = { version = "2.6.0", default-features = false, features = ["alloc"] }
rustc-hash = { version = "2.1", default-features = false }
thiserror = { version = "2", default-features = false }
serde_with = { version = "3.14.0", default-features = false, features = ["alloc", "macros"] }

[dependencies.uuid]
version = "1.4.1"
Expand Down
25 changes: 24 additions & 1 deletion crates/core/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::error::{PSResult, PowerSyncError};
use crate::fix_data::apply_v035_fix;
use crate::sync::BucketPriority;

pub const LATEST_VERSION: i32 = 10;
pub const LATEST_VERSION: i32 = 11;

pub fn powersync_migrate(
ctx: *mut sqlite::context,
Expand Down Expand Up @@ -384,5 +384,28 @@ INSERT INTO ps_migration(id, down_migrations) VALUES (10, json_array(
.into_db_result(local_db)?;
}

if current_version < 11 && target_version >= 11 {
let stmt = "\
CREATE TABLE ps_stream_subscriptions (
id INTEGER NOT NULL PRIMARY KEY,
stream_name TEXT NOT NULL,
active INTEGER NOT NULL DEFAULT FALSE,
is_default INTEGER NOT NULL DEFAULT FALSE,
local_priority INTEGER,
local_params TEXT NOT NULL DEFAULT 'null',
ttl INTEGER,
expires_at INTEGER,
last_synced_at INTEGER,
UNIQUE (stream_name, local_params)
) STRICT;

INSERT INTO ps_migration(id, down_migrations) VALUES(11, json_array(
json_object('sql', 'DROP TABLE ps_stream_subscriptions'),
json_object('sql', 'DELETE FROM ps_migration WHERE id >= 11')
));
";
local_db.exec_safe(stmt).into_db_result(local_db)?;
}

Ok(())
}
7 changes: 5 additions & 2 deletions crates/core/src/sync/checkpoint.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use alloc::{string::String, vec::Vec};
use alloc::{rc::Rc, string::String, vec::Vec};
use num_traits::Zero;

use crate::sync::{BucketPriority, Checksum, line::BucketChecksum};
use crate::sync::line::{BucketChecksum, BucketSubscriptionReason};
use crate::sync::{BucketPriority, Checksum};
use sqlite_nostd::{self as sqlite, Connection, ResultCode};

/// A structure cloned from [BucketChecksum]s with an owned bucket name instead of one borrowed from
Expand All @@ -12,6 +13,7 @@ pub struct OwnedBucketChecksum {
pub checksum: Checksum,
pub priority: BucketPriority,
pub count: Option<i64>,
pub subscriptions: Rc<Vec<BucketSubscriptionReason>>,
}

impl OwnedBucketChecksum {
Expand All @@ -30,6 +32,7 @@ impl From<&'_ BucketChecksum<'_>> for OwnedBucketChecksum {
checksum: value.checksum,
priority: value.priority.unwrap_or(BucketPriority::FALLBACK),
count: value.count,
subscriptions: value.subscriptions.clone(),
}
}
}
Expand Down
Loading
Loading