Skip to content

Commit 5f06c24

Browse files
committed
[*] migrate to single table architecture
1 parent 9bccaed commit 5f06c24

File tree

15 files changed

+1226
-433
lines changed

15 files changed

+1226
-433
lines changed

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,10 @@ dist/
8282
*.bak
8383
*.backup
8484
*.orig
85+
86+
# Spec-kit files
87+
templates/
88+
specs/
89+
memory/
90+
scripts/
91+
.github/prompts/

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# etcd_fdw - Bidirectional Synchronization
2+
3+
## Overview
4+
5+
etcd_fdw provides bidirectional synchronization between etcd and PostgreSQL using a single table architecture with revision status encoding.
6+
7+
## Architecture
8+
9+
- **Single Table**: All data stored in `etcd` table with revision-based synchronization status
10+
- **Revision Encoding**: `-1` = pending sync to etcd, `>0` = synchronized from etcd
11+
- **Polling Mechanism**: PostgreSQL to etcd sync uses configurable polling interval
12+
13+
## Installation
14+
15+
```bash
16+
go install github.com/cybertec-postgresql/etcd_fdw/cmd/etcd_fdw@latest
17+
```
18+
19+
## Usage
20+
21+
```bash
22+
# Basic usage
23+
etcd_fdw --postgres-dsn="postgres://user:pass@localhost/db" --etcd-dsn="etcd://localhost:2379/prefix"
24+
25+
# With custom polling interval
26+
etcd_fdw --postgres-dsn="..." --etcd-dsn="..." --polling-interval=2s
27+
```

cmd/etcd_fdw/cli_test.go

Lines changed: 24 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ func TestCLIParsing(t *testing.T) {
2727
},
2828
wantErr: false,
2929
expected: Config{
30-
PostgresDSN: "postgres://user:pass@localhost:5432/db",
31-
EtcdDSN: "etcd://localhost:2379/",
32-
LogLevel: "info", // default value
30+
PostgresDSN: "postgres://user:pass@localhost:5432/db",
31+
EtcdDSN: "etcd://localhost:2379/",
32+
LogLevel: "info", // default value
33+
PollingInterval: "1s", // default value
3334
},
3435
},
3536
{
@@ -40,27 +41,20 @@ func TestCLIParsing(t *testing.T) {
4041
},
4142
wantErr: false,
4243
expected: Config{
43-
PostgresDSN: "postgres://user:pass@localhost:5432/db",
44-
EtcdDSN: "etcd://localhost:2379,localhost:2380,localhost:2381/",
45-
LogLevel: "info", // default value
46-
},
47-
},
48-
{
49-
name: "help flag",
50-
args: []string{"--help"},
51-
wantErr: false,
52-
expected: Config{
53-
Help: true,
54-
LogLevel: "info", // default value
44+
PostgresDSN: "postgres://user:pass@localhost:5432/db",
45+
EtcdDSN: "etcd://localhost:2379,localhost:2380,localhost:2381/",
46+
LogLevel: "info", // default value
47+
PollingInterval: "1s", // default value
5548
},
5649
},
5750
{
5851
name: "version flag",
5952
args: []string{"--version"},
6053
wantErr: false,
6154
expected: Config{
62-
Version: true,
63-
LogLevel: "info", // default value
55+
Version: true,
56+
LogLevel: "info", // default value
57+
PollingInterval: "1s", // default value
6458
},
6559
},
6660
{
@@ -71,12 +65,12 @@ func TestCLIParsing(t *testing.T) {
7165
"--log-level", "debug",
7266
"--dry-run",
7367
},
74-
wantErr: false,
68+
wantErr: true, // dry-run not implemented
7569
expected: Config{
76-
PostgresDSN: "postgres://user:pass@localhost:5432/db",
77-
EtcdDSN: "etcd://localhost:2379/",
78-
LogLevel: "debug",
79-
DryRun: true,
70+
PostgresDSN: "postgres://user:pass@localhost:5432/db",
71+
EtcdDSN: "etcd://localhost:2379/",
72+
LogLevel: "debug",
73+
PollingInterval: "1s", // default value
8074
},
8175
},
8276
{
@@ -87,9 +81,10 @@ func TestCLIParsing(t *testing.T) {
8781
},
8882
wantErr: false,
8983
expected: Config{
90-
PostgresDSN: "postgres://user:pass@localhost:5432/db",
91-
EtcdDSN: "etcd://localhost:2379/config/?tls=enabled&dial_timeout=5s",
92-
LogLevel: "info", // default value
84+
PostgresDSN: "postgres://user:pass@localhost:5432/db",
85+
EtcdDSN: "etcd://localhost:2379/config/?tls=enabled&dial_timeout=5s",
86+
LogLevel: "info", // default value
87+
PollingInterval: "1s", // default value
9388
},
9489
},
9590
{
@@ -101,9 +96,10 @@ func TestCLIParsing(t *testing.T) {
10196
},
10297
wantErr: false,
10398
expected: Config{
104-
PostgresDSN: "postgres://user:pass@localhost:5432/db",
105-
EtcdDSN: "etcd://localhost:2379/",
106-
LogLevel: "warn",
99+
PostgresDSN: "postgres://user:pass@localhost:5432/db",
100+
EtcdDSN: "etcd://localhost:2379/",
101+
LogLevel: "warn",
102+
PollingInterval: "1s", // default value
107103
},
108104
},
109105
}

0 commit comments

Comments
 (0)