https://github.com/hahnavi/libsql-syncd
Sync libSQL embedded replica using message-triggered updates.
https://github.com/hahnavi/libsql-syncd
libsql sqlite turso
Last synced: about 1 year ago
JSON representation
Sync libSQL embedded replica using message-triggered updates.
- Host: GitHub
- URL: https://github.com/hahnavi/libsql-syncd
- Owner: hahnavi
- License: mit
- Created: 2024-05-29T17:38:38.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-05-30T08:02:57.000Z (almost 2 years ago)
- Last Synced: 2025-01-31T22:44:36.957Z (about 1 year ago)
- Topics: libsql, sqlite, turso
- Language: Rust
- Homepage:
- Size: 9.77 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# libsql-syncd
**libsql-syncd** is a tool that synchronizes your libSQL embedded replica with a primary database using Redis Pub/Sub to trigger synchronization. This keeps your embedded replica up-to-date efficiently and provides an easy way to maintain synchronization without the need for constant polling.
## Getting Started
To run **libsql-syncd**, follow these steps:
1. Build the Project:
```sh
cargo build --release
```
1. Set Environment Variables:
If you prefer, you can set environment variables manually or use `.env` file.
- Copy the `.env.example` file to a new file named `.env`.
- Edit the `.env` file and replace placeholders with your actual values.
- `LIBSQL_SYNC_URL`: URL of the primary.
- `LIBSQL_AUTH_TOKEN`: Authentication token.
- `LIBSQL_DB_PATH`: Location of the embedded replica file.
- `REDIS_URL`: URL of the Redis server.
- `REDIS_CHANNEL`: Channel name of the Redis Pub/Sub.
- `HOST_ID`: ID of the host. If the value matches the message from Redis Pub/Sub, sync will be skipped.
1. Run the App:
- After building the project, navigate to the `target/release` directory.
- Run the generated binary file:
```sh
./libsql-syncd
```
## Trigger Synchronization
To trigger synchronization, send a message to the Redis Pub/Sub channel specified in the environment variable (`REDIS_CHANNEL`). The payload is the host ID that triggers the synchronization. **libsql-syncd** will skip the sync if the payload matches the `HOST_ID` from the environment variable.