Skip to content

Commit

Permalink
create docs.go
Browse files Browse the repository at this point in the history
  • Loading branch information
Kevin Deems authored and kevindweb committed Dec 15, 2024
1 parent 54362f7 commit cd84e8b
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

🛡️ Dynamically shield your services from traffic overload using smart, metrics-driven congestion control.

See [Netflix concurrency-limits](https://github.com/Netflix/concurrency-limits) for the inspiration.

## Key Features

- 📊 **Adaptive Traffic Management**: Automatically adjusts request concurrency based on real-time Prometheus metrics
Expand Down
27 changes: 27 additions & 0 deletions doc.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Package throttleproxy provides an adaptive backpressure proxy mechanism for dynamically managing
// traffic and protecting backend services using Prometheus metrics.
//
// Usage Example:
//
// config := proxymw.BackpressureConfig{
// EnableBackpressure: true,
// BackpressureQueries: []BackpressureQuery{
// {
// Query: `sum(rate(http_server_errors_total[5m]))`,
// Name: "http_error_rate"
// WarningThreshold: 0.5,
// EmergencyThreshold: 0.8,
// }
// },
// CongestionWindowMin: 10,
// CongestionWindowMax: 100,
// }
//
// Use Cases:
// - Protecting microservices from traffic spikes
// - Preventing cascading failures
// - Maintaining system stability under unpredictable load
//
// The package supports both server-side HTTP proxy and client-side RoundTripper
// implementations, providing flexible integration options.
package main // import "github.com/kevindweb/throttle-proxy"
4 changes: 2 additions & 2 deletions proxymw/middleware.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ func (se *ServeExit) Init(_ context.Context) {}
func (se *ServeExit) Next(rr Request) error {
rrw, ok := rr.(ResponseWriter)
if !ok {
return fmt.Errorf("request is of type %T not RequestResponseWriter", rr)
return fmt.Errorf("request is of type %T not ResponseWriter", rr)
}

w := rrw.ResponseWriter()
Expand Down Expand Up @@ -270,7 +270,7 @@ func writeAPIError(w http.ResponseWriter, errorMessage string, code int) {

response := APIErrorResponse{
Status: "error",
ErrorType: "query-proxy",
ErrorType: "throttle-proxy",
Error: errorMessage,
}

Expand Down

0 comments on commit cd84e8b

Please sign in to comment.