-
Notifications
You must be signed in to change notification settings - Fork 23
Add NewSyncedDatabaseConnector
#64
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
Conversation
Also tested this with a AWS server and the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds a new constructor for synced connectors and refactors existing sync setup to use a unified helper with offline support.
- Introduces
NewSyncedDatabaseConnector
for always-on syncing, with anoffline
mode flag - Refactors
openEmbeddedReplicaConnector
intoopenSyncConnector
and updates C bindings to use a config struct - Extends
libsql_config
in the C header with anoffline
field and updates the workflow for end-to-end testing
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
libsql.go | Added NewSyncedDatabaseConnector , refactored sync helper, and updated CGo binding to use libsql_open_sync_with_config |
lib/include/libsql.h | Extended libsql_config with offline and added tracing API |
.github/workflows/test.yml | Added CI steps to install libsql server and run tests on macOS and Linux |
Comments suppressed due to low confidence (2)
lib/include/libsql.h:69
- The C function
libsql_open_sync_with_config
is invoked from Go but not declared in this header. Add its prototype tolibsql.h
so cgo can locate and link it correctly.
int libsql_sync2(libsql_database_t db, replicated *out_replicated, const char **out_err_msg);
libsql.go:141
- There are no tests for the new offline sync path introduced by
NewSyncedDatabaseConnector
. Consider adding unit or integration tests covering both online and offline modes.
func NewSyncedDatabaseConnector(dbPath string, primaryUrl string, opts ...Option) (*Connector, error) {
return openEmbeddedReplicaConnector(dbPath, primaryUrl, authToken, readYourWrites, encryptionKey, syncInterval) | ||
return openSyncConnector(dbPath, primaryUrl, authToken, readYourWrites, encryptionKey, syncInterval, false) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Add a Go doc comment for NewSyncedDatabaseConnector
explaining its parameters, behavior, and how the offline
flag differs from NewEmbeddedReplicaConnector
.
// NewSyncedDatabaseConnector creates a Connector for a synchronized database. | |
// | |
// Parameters: | |
// - dbPath: The file path to the local database. | |
// - primaryUrl: The URL of the primary database to synchronize with. | |
// - opts: A variadic list of options to configure the connector (e.g., encryption key, sync interval). | |
// | |
// Behavior: | |
// This function initializes a Connector that synchronizes the local database with a primary database. | |
// It applies the provided options to configure the connector. If any errors occur during option application, | |
// they are aggregated and returned. | |
// | |
// Difference from NewEmbeddedReplicaConnector: | |
// The `offline` flag passed to `openSyncConnector` is set to `true` in this function, indicating that | |
// the connector operates in synchronized mode. In contrast, `NewEmbeddedReplicaConnector` sets the `offline` | |
// flag to `false`, indicating embedded replica mode. |
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, @avinassh can you also review for sanity?
new server does not support encryption yet |
Resolves #60.