ha

command module
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 21, 2025 License: Apache-2.0 Imports: 22 Imported by: 0

README

ha

Highly available leaderless SQLite cluster powered by embedded NATS JetStream server.

Installation

Install from source
go install github.com/litesql/ha@latest

Usage

  1. Create an sqlite database:
sqlite3 mydatabase.db 'CREATE TABLE users (id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT);'
  1. Start the first ha node
ha mydatabase.db
  1. Start an another ha node
ha --port 8081 --pg-port 5433 --nats-port 0 --replication-url nats://localhost:4222 mydatabase.db
  1. Insert some data using HTTP client
curl -d '[{"sql": "INSERT INTO users(name) VALUES('\''HA user'\'')"}]' \
http://localhost:8080
  1. Or use a PostgreSQL client
PGPASSWORD="ha" psql -h localhost -U ha
INSERT INTO users(name) VALUES('HA user from PostgreSQL Wire Protocol');
SELECT * FROM users;
  1. Connect to another server and check the values
PGPASSWORD="ha" psql -h localhost -U ha -p 5433
SELECT * FROM users;
Backup database
curl -O -J http://localhost:8080

Local Read Replicas

  • Use ha-sync SQLite extension to create local embedded replicas from a remote HA database.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL