Skip to content

Commit 35a0729

Browse files
authored
Add Replica support (wpgx v0.3 required) (#7)
* add replica support * remove cis
1 parent 4ba4d23 commit 35a0729

11 files changed

Lines changed: 194 additions & 291 deletions

File tree

.github/workflows/buf.yml

Lines changed: 0 additions & 9 deletions
This file was deleted.

.github/workflows/ci-kotlin.yml

Lines changed: 0 additions & 52 deletions
This file was deleted.

.github/workflows/ci-python.yml

Lines changed: 0 additions & 44 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 0 additions & 102 deletions
This file was deleted.

.github/workflows/gen.yml

Lines changed: 0 additions & 38 deletions
This file was deleted.

GUIDE.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ as this combo.
1818

1919
Production versions:
2020

21-
+ sqlc: v2.2.2-wicked-fork
21+
+ sqlc: v2.3.0-wicked-fork
2222
+ dcache: v0.3.0 (Note: redis/v8 users please use v0.1.4)
23-
+ wgpx: v0.2.3
23+
+ wgpx: v0.3.0
2424

2525
# Sqlc (this wicked fork)
2626

@@ -54,10 +54,10 @@ your customers are disappointed, or (2) before the product is launched, writing
5454
# cgo must be enabled because: https://github.com/pganalyze/pg_query_go
5555
git clone https://github.com/Stumble/sqlc.git
5656
cd sqlc/
57-
git checkout v2.2.2
57+
git checkout v2.3.0
5858
make install
5959
sqlc version
60-
# you shall see: v2.2.2-wicked-fork
60+
# you shall see: v2.3.0-wicked-fork
6161
```
6262

6363
## Getting started

internal/codegen/golang/option.go

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,19 @@ import (
77
)
88

99
const (
10-
WPgxOptionKeyCache = "cache"
11-
WPgxOptionKeyInvalidate = "invalidate"
12-
WpgxOptionKeyCountIntent = "count_intent"
13-
WpgxOptionKeyTimeout = "timeout"
10+
WPgxOptionKeyCache = "cache"
11+
WPgxOptionKeyInvalidate = "invalidate"
12+
WpgxOptionKeyCountIntent = "count_intent"
13+
WpgxOptionKeyTimeout = "timeout"
14+
WpgxOptionKeyAllowReplica = "allow_replica"
1415
)
1516

1617
type WPgxOption struct {
17-
Cache time.Duration
18-
Invalidates []string
19-
CountIntent bool
20-
Timeout time.Duration
18+
Cache time.Duration
19+
Invalidates []string
20+
CountIntent bool
21+
Timeout time.Duration
22+
AllowReplica bool
2123
}
2224

2325
func parseOption(options map[string]string, queryNames map[string]bool) (rv WPgxOption, err error) {
@@ -57,6 +59,14 @@ func parseOption(options map[string]string, queryNames map[string]bool) (rv WPgx
5759
if rv.Timeout < 1*time.Millisecond {
5860
return rv, fmt.Errorf("timeout duration too short: %s", v)
5961
}
62+
case WpgxOptionKeyAllowReplica:
63+
if v == "true" {
64+
rv.AllowReplica = true
65+
} else if v == "false" {
66+
rv.AllowReplica = false
67+
} else {
68+
return rv, fmt.Errorf("Unknown allow_replica value: %s", v)
69+
}
6070
default:
6171
return rv, fmt.Errorf("Unknown option: %s", k)
6272
}

0 commit comments

Comments
 (0)