Skip to content

Commit

Permalink
docs: fix lint errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ErfanMomeniii authored and Erfan Momeni committed Jan 4, 2025
1 parent f4682bd commit a476945
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
6 changes: 3 additions & 3 deletions docs/middleware/loadshedding.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ enforcing timeouts on request processing. It helps manage server load effectivel
exceed a specified timeout duration. This is especially useful in high-traffic scenarios, where preventing server
overload is critical to maintaining service availability and performance.

### Features
## Features

- **Request Timeout Enforcement**: Ensures that no request exceeds the specified processing time.
- **Customizable Response**: Allows you to define a specific response for timed-out requests.
- **Exclusion Criteria**: Provides flexibility to exclude specific requests from load-shedding logic.
- **Improved Stability**: Helps prevent server crashes under heavy load by shedding excess requests.

### Use Cases
## Use Cases

- **High-Traffic Scenarios**: Protect critical resources by shedding long-running or resource-intensive requests.
- **Health Check Protection**: Exclude endpoints like `/health` to ensure critical monitoring remains unaffected.
Expand Down Expand Up @@ -70,4 +70,4 @@ func main() {

app.Listen(":3000")
}
```
```
14 changes: 10 additions & 4 deletions docs/whats_new.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Here's a quick overview of the changes in Fiber `v3`:
- [Filesystem](#filesystem)
- [Monitor](#monitor)
- [Healthcheck](#healthcheck)
- [Load shedding](#loadshedding)
- [Load shedding](#-load-shedding)
- [📋 Migration guide](#-migration-guide)

## Drop for old Go versions
Expand Down Expand Up @@ -812,14 +812,19 @@ The Healthcheck middleware has been enhanced to support more than two routes, wi
Refer to the [healthcheck middleware migration guide](./middleware/healthcheck.md) or the [general migration guide](#-migration-guide) to review the changes.

### Load shedding

We've added **Load Shedding Middleware**.It ensures system stability under high load by enforcing timeouts on request processing. This mechanism allows the application to shed excessive load gracefully and maintain responsiveness.

**Functionality**
#### Functionality

- **Timeout Enforcement**: Automatically terminates requests exceeding a specified processing time.

- **Custom Response**: Uses a configurable load-shedding handler to define the response for shed requests.

- **Request Exclusion**: Allows certain requests to bypass load-shedding logic through an exclusion filter.

This middleware is designed to enhance server resilience and improve the user experience during periods of high traffic.

## 📋 Migration guide

- [🚀 App](#-app-1)
Expand Down Expand Up @@ -1372,17 +1377,18 @@ app.Get("/live", healthcheck.NewHealthChecker())
```
#### Load shedding
This middleware uses `context.WithTimeout` to manage the lifecycle of requests. If a request exceeds the specified timeout, the custom load-shedding handler is triggered, ensuring the system remains stable under stress.
**Key Parameters**
##### Key Parameters
`timeout` (`time.Duration`): The maximum time a request is allowed to process. Requests exceeding this time are terminated.
`loadSheddingHandler` (`fiber.Handler`): A custom handler that executes when a request exceeds the timeout. Typically used to return a `503 Service Unavailable` response or a custom message.
`exclude` (`func(fiber.Ctx) bool`): A filter function to exclude specific requests from being subjected to the load-shedding logic (optional).
**Usage Example**
#### Usage Example
```go
import "github.com/gofiber/fiber/v3/middleware/loadshedding
Expand Down

0 comments on commit a476945

Please sign in to comment.