-
-
Notifications
You must be signed in to change notification settings - Fork 4
Production-ready proxy: working Postgres scaling, race fixes, ops, tests, non-Docker docs (#54, #52) #59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Production-ready proxy: working Postgres scaling, race fixes, ops, tests, non-Docker docs (#54, #52) #59
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
658a693
docs: add production-ready proxy design spec (#54, #52)
SamTV12345 2a9da08
docs: add production-ready proxy implementation plan (#54, #52)
SamTV12345 e322887
fix: make Postgres functional and pad assignment atomic (#54)
SamTV12345 67e97e4
refactor: add RWMutex-guarded BackendState
SamTV12345 1e77d31
feat: add Prometheus metrics package
SamTV12345 31fc916
feat: add managementPort setting and startup config validation
SamTV12345 6018182
feat: race-free routing, graceful shutdown, health/metrics endpoints
SamTV12345 f8e828f
ci: run go vet and race tests with a Postgres service
SamTV12345 64e6686
docs: add installation without Docker, Postgres setup, systemd unit (…
SamTV12345 7ae6fd8
ci: add GoReleaser config and tag-triggered release workflow
SamTV12345 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| name: Release | ||
| on: | ||
| push: | ||
| tags: | ||
| - 'v*' | ||
| permissions: | ||
| contents: write | ||
| jobs: | ||
| goreleaser: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
| - uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: '1.25' | ||
| - uses: goreleaser/goreleaser-action@v6 | ||
| with: | ||
| version: '~> v2' | ||
| args: release --clean | ||
| env: | ||
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| name: Test | ||
| on: | ||
| push: | ||
| branches: [main] | ||
| pull_request: | ||
| jobs: | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| services: | ||
| postgres: | ||
| image: postgres:16 | ||
| env: | ||
| POSTGRES_USER: proxy | ||
| POSTGRES_PASSWORD: proxy | ||
| POSTGRES_DB: etherpad_proxy | ||
| ports: | ||
| - 5432:5432 | ||
| options: >- | ||
| --health-cmd "pg_isready -U proxy" | ||
| --health-interval 10s | ||
| --health-timeout 5s | ||
| --health-retries 5 | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - uses: actions/setup-go@v5 | ||
| with: | ||
| go-version: '1.25' | ||
| - name: Vet | ||
| run: go vet ./... | ||
| - name: Test (race) | ||
| env: | ||
| PG_TEST_DSN: postgres://proxy:proxy@localhost:5432/etherpad_proxy?sslmode=disable | ||
| run: go test -race ./... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| version: 2 | ||
| project_name: etherpad-proxy | ||
| builds: | ||
| - id: etherpad-proxy | ||
| main: . | ||
| binary: etherpad-proxy | ||
| env: | ||
| - CGO_ENABLED=0 | ||
| goos: | ||
| - linux | ||
| - darwin | ||
| - windows | ||
| goarch: | ||
| - amd64 | ||
| - arm64 | ||
| archives: | ||
| - id: default | ||
| formats: [tar.gz] | ||
| format_overrides: | ||
| - goos: windows | ||
| formats: [zip] | ||
| files: | ||
| - README.md | ||
| - LICENSE.md | ||
| - settings.json.template | ||
| - support/etherpad-proxy.service | ||
| checksum: | ||
| name_template: 'checksums.txt' | ||
| release: | ||
| github: | ||
| owner: ether | ||
| name: etherpad-proxy |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "net/http" | ||
| "net/http/httptest" | ||
| "net/url" | ||
| "slices" | ||
| "strconv" | ||
| "testing" | ||
|
|
||
| "github.com/ether/etherpad-proxy/models" | ||
| ) | ||
|
|
||
| // newStatsBackend starts a test server replying to /stats with the given | ||
| // activePads count, and returns its host and port. | ||
| func newStatsBackend(t *testing.T, activePads int) (string, int) { | ||
| t.Helper() | ||
| srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { | ||
| if r.URL.Path == "/stats" { | ||
| fmt.Fprintf(w, `{"activePads": %d}`, activePads) | ||
| return | ||
| } | ||
| w.WriteHeader(http.StatusNotFound) | ||
| })) | ||
| t.Cleanup(srv.Close) | ||
| u, _ := url.Parse(srv.URL) | ||
| port, _ := strconv.Atoi(u.Port()) | ||
| return u.Hostname(), port | ||
| } | ||
|
|
||
| func TestCheckAvailabilityCapacityAndDown(t *testing.T) { | ||
| okHost, okPort := newStatsBackend(t, 1) // under capacity -> up + available | ||
| fullHost, fullPort := newStatsBackend(t, 99) // over capacity -> up but not available | ||
|
|
||
| settings := models.Settings{ | ||
| MaxPadsPerInstance: 5, | ||
| Backends: map[string]models.Backend{ | ||
| "ok": {Host: okHost, Port: okPort}, | ||
| "full": {Host: fullHost, Port: fullPort}, | ||
| "down": {Host: "127.0.0.1", Port: 1}, // nothing listening -> not up | ||
| }, | ||
| } | ||
|
|
||
| got := checkAvailability(settings) | ||
|
|
||
| if !slices.Contains(got.Up, "ok") || !slices.Contains(got.Up, "full") { | ||
| t.Fatalf("expected ok and full to be up, got %v", got.Up) | ||
| } | ||
| if slices.Contains(got.Up, "down") { | ||
| t.Fatalf("down backend should not be up, got %v", got.Up) | ||
| } | ||
| if !slices.Contains(got.Available, "ok") { | ||
| t.Fatalf("ok should be available, got %v", got.Available) | ||
| } | ||
| if slices.Contains(got.Available, "full") { | ||
| t.Fatalf("full backend should not be available, got %v", got.Available) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1. Broken config template
🐞 Bug≡ CorrectnessAgent Prompt
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools