-
Notifications
You must be signed in to change notification settings - Fork 3
(feat) Added rust sync implementation #20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Chriztiaan
wants to merge
22
commits into
main
Choose a base branch
from
feat/rust-sync-implementation
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+1,602
−367
Open
Changes from 14 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
434ec8f
Added integration test shell.
Chriztiaan 563012f
Added initial integration tests.
Chriztiaan 89f5181
Support 0.4.0 for C_SHARP sync implementation.
Chriztiaan f731d70
Initial rust sync support.
Chriztiaan e372cf6
Fixed crud tests. Removed boolean parameter from BucketStorageTests.
Chriztiaan 88006ec
Revert SyncDataBucket changes.
Chriztiaan b6599c9
Fixed bucket storage tests related to core extension changes.
Chriztiaan 0fbc7e4
Introduced PowerSyncControlCommand constants.
Chriztiaan b258570
Removed old package.
Chriztiaan 1037191
Tracer fix for csharp sync.
Chriztiaan a310bac
Cleanup. Final iteration result handling that works for both Rust and…
Chriztiaan 08b4ee7
Ignoring NET-iOS8 warning.
Chriztiaan 077ee4c
Changelog and cleanup entries.
Chriztiaan bbdcd27
MAUI workloads for test restore.
Chriztiaan 0e012b8
Removed unused function.
Chriztiaan 9fb2ec7
Passing null payloads to control (if exists). Invoke notifyCompletedU…
Chriztiaan 6cda500
Updating setup for latest versions.
Chriztiaan d516eae
Further improvements on rust sync implementation. Triggering crud upl…
Chriztiaan 9710cba
Using `main.sqlite_sequence` instead of `sqlite_sequence`.
Chriztiaan 8bdff42
Hardcoded MAUI version for dependencies.
Chriztiaan a6b8b1f
Using event stream to interface with central control call.
Chriztiaan 848d78c
Warning cleanup.
Chriztiaan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
129 changes: 129 additions & 0 deletions
129
PowerSync/PowerSync.Common/Client/Sync/Stream/CoreInstructions.cs
This file contains hidden or 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,129 @@ | ||
| using Newtonsoft.Json.Linq; | ||
| using Newtonsoft.Json; | ||
|
|
||
| namespace PowerSync.Common.Client.Sync.Stream; | ||
|
|
||
| /// <summary> | ||
| /// An internal instruction emitted by the sync client in the core extension in response to the | ||
| /// SDK passing sync data into the extension. | ||
| /// </summary> | ||
| public abstract class Instruction | ||
| { | ||
|
|
||
| public static Instruction[] ParseInstructions(string rawResponse) | ||
| { | ||
| var jsonArray = JArray.Parse(rawResponse); | ||
| List<Instruction> instructions = []; | ||
|
|
||
| foreach (JObject item in jsonArray) | ||
| { | ||
| var instruction = ParseInstruction(item); | ||
| if (instruction == null) | ||
| { | ||
| throw new JsonSerializationException("Failed to parse instruction from JSON."); | ||
| } | ||
| instructions.Add(instruction); | ||
| } | ||
|
|
||
| return instructions.ToArray(); | ||
| } | ||
|
|
||
| public static Instruction? ParseInstruction(JObject json) | ||
| { | ||
| if (json.ContainsKey("LogLine")) | ||
| return json["LogLine"]!.ToObject<LogLine>(); | ||
| if (json.ContainsKey("UpdateSyncStatus")) | ||
| return json["UpdateSyncStatus"]!.ToObject<UpdateSyncStatus>(); | ||
| if (json.ContainsKey("EstablishSyncStream")) | ||
| return json["EstablishSyncStream"]!.ToObject<EstablishSyncStream>(); | ||
| if (json.ContainsKey("FetchCredentials")) | ||
| return json["FetchCredentials"]!.ToObject<FetchCredentials>(); | ||
| if (json.ContainsKey("CloseSyncStream")) | ||
| return new CloseSyncStream(); | ||
| if (json.ContainsKey("FlushFileSystem")) | ||
| return new FlushFileSystem(); | ||
| if (json.ContainsKey("DidCompleteSync")) | ||
| return new DidCompleteSync(); | ||
|
|
||
| throw new JsonSerializationException("Unknown Instruction type."); | ||
| } | ||
| } | ||
|
|
||
| public class LogLine : Instruction | ||
| { | ||
| [JsonProperty("severity")] | ||
| public string Severity { get; set; } = null!; // "DEBUG", "INFO", "WARNING" | ||
|
|
||
| [JsonProperty("line")] | ||
| public string Line { get; set; } = null!; | ||
| } | ||
|
|
||
| public class EstablishSyncStream : Instruction | ||
| { | ||
| [JsonProperty("request")] | ||
| public StreamingSyncRequest Request { get; set; } = null!; | ||
| } | ||
|
|
||
| public class UpdateSyncStatus : Instruction | ||
| { | ||
| [JsonProperty("status")] | ||
| public CoreSyncStatus Status { get; set; } = null!; | ||
| } | ||
|
|
||
| public class CoreSyncStatus | ||
| { | ||
| [JsonProperty("connected")] | ||
| public bool Connected { get; set; } | ||
|
|
||
| [JsonProperty("connecting")] | ||
| public bool Connecting { get; set; } | ||
|
|
||
| [JsonProperty("priority_status")] | ||
| public List<SyncPriorityStatus> PriorityStatus { get; set; } = []; | ||
|
|
||
| [JsonProperty("downloading")] | ||
| public DownloadProgress? Downloading { get; set; } | ||
| } | ||
|
|
||
| public class SyncPriorityStatus | ||
| { | ||
| [JsonProperty("priority")] | ||
| public int Priority { get; set; } | ||
|
|
||
| [JsonProperty("last_synced_at")] | ||
| public long LastSyncedAt { get; set; } | ||
|
|
||
| [JsonProperty("has_synced")] | ||
| public bool? HasSynced { get; set; } | ||
| } | ||
|
|
||
| public class DownloadProgress | ||
| { | ||
| [JsonProperty("buckets")] | ||
| public Dictionary<string, BucketProgress> Buckets { get; set; } = null!; | ||
| } | ||
|
|
||
| public class BucketProgress | ||
| { | ||
| [JsonProperty("priority")] | ||
| public int Priority { get; set; } | ||
|
|
||
| [JsonProperty("at_last")] | ||
| public int AtLast { get; set; } | ||
|
|
||
| [JsonProperty("since_last")] | ||
| public int SinceLast { get; set; } | ||
|
|
||
| [JsonProperty("target_count")] | ||
| public int TargetCount { get; set; } | ||
| } | ||
|
|
||
| public class FetchCredentials : Instruction | ||
| { | ||
| [JsonProperty("did_expire")] | ||
| public bool DidExpire { get; set; } | ||
| } | ||
|
|
||
| public class CloseSyncStream : Instruction { } | ||
| public class FlushFileSystem : Instruction { } | ||
| public class DidCompleteSync : Instruction { } |
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.