12 stable releases
1.3.1 | Nov 26, 2021 |
---|---|
1.2.10 | Nov 24, 2021 |
1.1.1 | Nov 24, 2021 |
1.0.0 | Nov 24, 2021 |
#35 in #golang
34 downloads per month
2.5MB
551 lines
Contains (ELF exe/lib, 1.5MB) main_shared, (WOFF font, 290KB) doc/noto-sans-kr-v13-korean-regular.woff, (WOFF font, 190KB) doc/FiraSans-Medium.woff, (WOFF font, 135KB) doc/FiraSans-Medium.woff2, (WOFF font, 185KB) doc/FiraSans-Regular.woff, (WOFF font, 130KB) doc/FiraSans-Regular.woff2 and 12 more.
ruster
Ruster is a library using ffi for database management with psql/pg_dump + mysql/mysqldump written in Rust.
The generated C static and shared libraries can be reused in other languages (Golang for example).
Build ruster
The build of project produces 2 go binaries, 1 static library (libruster.a) and 1 shared library (libruster.so).
The headers of C functions are in lib/ruster.h and must be present before code generation.
make build-shared
make build-static
Using ruster
PostgreSQL
/*
#cgo LDFLAGS: -L./lib -lruster
#include "./lib/ruster.h"
*/
import "C"
import (
"os"
)
func main() {
os.Getenv("PGPASSWORD")
err := func() error {
C.pg_dump_database(
C.CString("localhost"),
C.CString("5432"),
C.CString("postgres"),
C.CString("postgres"),
C.CString("pg_dump.sql"),
C.CString("true"),
);
return nil
}
if err() == nil {
func() {
C.psql_restore_database(
C.CString("localhost"),
C.CString("5432"),
C.CString("postgres"),
C.CString("postgres"),
C.CString("pg_dump.sql"),
C.CString("true"),
);
}()
}
}
MySQL - Mariadb
/*
#cgo LDFLAGS: -L./lib -lruster
#include "./lib/ruster.h"
*/
import "C"
import (
"os"
)
func main() {
os.Getenv("MYSQL_PWD")
err := func() error {
C.mysqldump_database(
C.CString("localhost"),
C.CString("3306"),
C.CString("root"),
C.CString("mysql"),
C.CString("dump.sql"),
C.CString("true"),
);
return nil
}
time.Sleep(time.Duration(250)*time.Millisecond)
if err() == nil {
func() {
C.mysql_restore_database(
C.CString("localhost"),
C.CString("3306"),
C.CString("root"),
C.CString("mysql"),
C.CString("dump.sql"),
C.CString("true"),
);
}()
}
}
Run ruster examples
make run-shared
make run-static
Bench
./time main_shared
./time main_static
Tests
./time test-rust-lib
Dependencies
~3–11MB
~109K SLoC