You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-`github.com/stretchr/testify` — Test assertions and mocking
79
79
80
80
### Concurrency Model
81
81
@@ -93,6 +93,11 @@ The maintainer is gradually moving the codebase **away from package-level global
93
93
-**Scope helpers to their type.** Package-level functions that operate on or return a type's data should be methods on that type (or live in a nested package), not free functions in `server/`.
94
94
-**Prefer a single config surface.** Where an `action` field can discriminate behavior (e.g. one webhook URL for both up/down), favor that over two parallel flags, matching the notifier webhook.
95
95
96
+
### Testing Conventions
97
+
98
+
- Use `testify` for assertions and mocking
99
+
- Table-driven tests with subtests (`t.Run()`) for multiple scenarios
100
+
96
101
### Error Handling
97
102
98
103
- Wrap with context: `fmt.Errorf("message: %w", err)`
Copy file name to clipboardExpand all lines: README.md
+48Lines changed: 48 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -821,6 +821,54 @@ In this case the `status` is `"failed-backend-connection"` indicating that a bac
821
821
}
822
822
```
823
823
824
+
#### Route added
825
+
826
+
> [!NOTE] This event type is disabled by default
827
+
828
+
```json
829
+
{
830
+
"event": "route-added",
831
+
"timestamp": "2025-04-20T22:26:30.2568775-05:00",
832
+
"server": "localhost",
833
+
"backend": "localhost:25566"
834
+
}
835
+
```
836
+
837
+
#### Route removed
838
+
839
+
> [!NOTE] This event type is disabled by default
840
+
841
+
```json
842
+
{
843
+
"event": "route-removed",
844
+
"timestamp": "2025-04-20T22:26:30.2568775-05:00",
845
+
"server": "localhost"
846
+
}
847
+
```
848
+
849
+
#### Default route set
850
+
851
+
> [!NOTE] This event type is disabled by default
852
+
853
+
```json
854
+
{
855
+
"event": "default-route-set",
856
+
"timestamp": "2025-04-20T22:26:30.2568775-05:00",
857
+
"backend": "localhost:25566"
858
+
}
859
+
```
860
+
861
+
#### Default route removed
862
+
863
+
> [!NOTE] This event type is disabled by default
864
+
865
+
```json
866
+
{
867
+
"event": "default-route-removed",
868
+
"timestamp": "2025-04-20T22:26:30.2568775-05:00"
869
+
}
870
+
```
871
+
824
872
## Community Solutions
825
873
826
874
- **[MC Router Discovery](https://github.com/Seedloaf/mc-router-discovery):** A lightweight sidecar to ensure mc-router is in sync with your list of running servers.
Copy file name to clipboardExpand all lines: server/configs.go
+4-3Lines changed: 4 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -3,9 +3,10 @@ package server
3
3
import"time"
4
4
5
5
typeWebhookConfigstruct {
6
-
Urlstring`usage:"If set, a POST request that contains connection status notifications will be sent to this HTTP address"`
7
-
RequireUserbool`default:"false" usage:"Indicates if the webhook will only be called if a user is connecting rather than just server list/ping"`
8
-
Timeout time.Duration`default:"30s" usage:"Timeout for each connection status notification request"`
6
+
Urlstring`usage:"If set, a POST request that contains connection status notifications will be sent to this HTTP address"`
7
+
RequireUserbool`default:"false" usage:"Indicates if the webhook will only be called if a user is connecting rather than just server list/ping"`
8
+
Timeout time.Duration`default:"30s" usage:"Timeout for each connection status notification request"`
9
+
Events []WebhookEvent`default:"connect,disconnect" usage:"Comma delimited list of events to send to the webhook. Valid values are connect, disconnect, route-added, route-removed, default-route-set, default-route-removed"`
// WithDownScaler sets the optional down scaler for the routes. The down scaler is used to scale down servers when they are no longer needed.
110
+
// TODO this is a code smell because it creates a circular dependency between routes and down scaler. The down scaler needs to know about the routes to scale down servers, but the routes also need to know about the down scaler to start scaling down servers when they are no longer needed. This should be refactored in the future.
0 commit comments