Skip to content
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

docs: add docusaurus website #1

Merged
merged 3 commits into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions .github/workflows/deploy-website.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Deploy to GitHub Pages

on:
push:
branches:
- main
- release-*

workflow_dispatch:

jobs:
deploy:
name: Deploy to GitHub Pages
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'

- run: dotnet tool install --global gsferreira.XmlDocMarkdown.Docusaurus --version 0.0.1-beta3 # using this version while the Pull Request isn't accepted here: https://github.com/ejball/XmlDocMarkdown/pull/126
shell: bash

- name: .NET Publish
run: dotnet publish LoadShedding.sln -c Release -o ./drop

- run: dotnet tool list --global
shell: bash

- run: xmldocmd-docusaurus ./drop/Farfetch.LoadShedding.dll website/docs/reference/Farfetch.LoadShedding --type-folders
shell: bash

- run: xmldocmd-docusaurus ./drop/Farfetch.LoadShedding.AspNetCore.dll website/docs/reference/Farfetch.LoadShedding.AspNetCore --type-folders
shell: bash

- run: xmldocmd-docusaurus ./drop/Farfetch.LoadShedding.Prometheus.dll website/docs/reference/Farfetch.LoadShedding.Prometheus --type-folders
shell: bash

- uses: actions/setup-node@v3
with:
node-version: 18
cache: yarn
cache-dependency-path: website/yarn.lock

- name: Install dependencies
working-directory: ./website
run: yarn install --frozen-lockfile

- name: Build website
working-directory: ./website
run: yarn build

- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./website/build
48 changes: 48 additions & 0 deletions .github/workflows/test-deploy-website.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Test deployment

on:
pull_request:

jobs:
test-deploy:
name: Test deployment
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Setup .NET
uses: actions/setup-dotnet@v3
with:
dotnet-version: '8.0.x'

- run: dotnet tool install --global gsferreira.XmlDocMarkdown.Docusaurus --version 0.0.1-beta3 # using this version while the Pull Request isn't accepted here: https://github.com/ejball/XmlDocMarkdown/pull/126
shell: bash

- name: .NET Publish
run: dotnet publish LoadShedding.sln -c Release -o ./drop

- run: dotnet tool list --global
shell: bash

- run: xmldocmd-docusaurus ./drop/Farfetch.LoadShedding.dll website/docs/reference/Farfetch.LoadShedding --type-folders
shell: bash

- run: xmldocmd-docusaurus ./drop/Farfetch.LoadShedding.AspNetCore.dll website/docs/reference/Farfetch.LoadShedding.AspNetCore --type-folders
shell: bash

- run: xmldocmd-docusaurus ./drop/Farfetch.LoadShedding.Prometheus.dll website/docs/reference/Farfetch.LoadShedding.Prometheus --type-folders
shell: bash

- uses: actions/setup-node@v3
with:
node-version: 18
cache: yarn
cache-dependency-path: website/yarn.lock

- name: Install dependencies
working-directory: ./website
run: yarn install --frozen-lockfile

- name: Test build website
working-directory: ./website
run: yarn build
30 changes: 27 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,33 @@ Here are a few things you can do that will increase the likelihood of your pull
- Write [good commit messages](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) following [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/)
- Open a pull request with a title following [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/)

## Running Integration Tests
## Running Unit and Integration Tests

You can find a Makefile with steps for running using docker on the repository root.
### Running git workflows locally

[Act](https://github.com/nektos/act) is a tool that will use docker to build and test workflows locally.

#### 1. Act setup
- Follow the [instructions](https://github.com/nektos/act?tab=readme-ov-file#installation) to install act
- To check all available actions: `act -l`

#### 2. Run tests
- To run the default (push) event: `act`
- To run a specific job: `act -j build-test`

JoaoRodriguesGithub marked this conversation as resolved.
Show resolved Hide resolved
Alternatively, you can run unit and integration tests with the following commands:

For unit tests only:

```bash
dotnet test LoadShedding.sln --filter Category=Unit
```

For integration tests only:

```bash
dotnet test LoadShedding.sln --filter Category=Integration
```

## Resources

Expand All @@ -43,4 +67,4 @@ You can find a Makefile with steps for running using docker on the repository ro

By sending us your contributions, you are agreeing that your contribution is made subject to the terms of our [Contributor Ownership Statement](https://github.com/Farfetch/.github/blob/master/COS.md)

[code-of-conduct]: CODE_OF_CONDUCT.md
[code-of-conduct]: CODE_OF_CONDUCT.md
127 changes: 18 additions & 109 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,125 +1,34 @@
# LoadShedding
# LoadShedding · [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/farfetch/loadshedding/blob/main/LICENSE) [![nuget version](https://img.shields.io/nuget/v/loadshedding.svg?style=flat)](https://www.nuget.org/packages/LoadShedding/) ![Build Master](https://github.com/Farfetch/loadshedding/workflows/Build/badge.svg?branch=master)

This library provides a set of capabilities to enable the service to deal with requests overload and resource limits to avoid outages and to ensure the best usage of the service capacity.
## Introduction

## Documentation

<details open="open">
<summary>Getting Started</summary>

- [Installation](docs/getting_started/installation.md)
- Register Limits
- [Concurrency Adaptative Limiter](docs/getting_started/register_concurrency_adaptative_limiter.md)
- [Samples](samples)

</details>

## Samples

For sample projects showcasing the application types, dependencies and features please check the [samples](samples/) folder.

## Contributing

Read our [contributing guidelines](CONTRIBUTING.md) to learn about our development process, how to propose bugfixes and improvements, and how to build and test your changes.

### Requirements

- Makefile
- .NET 6
- Docker
- Docker Compose

#### Makefile - Simplify Tests and Build commands

**Important: You must have the Make app installed and configured in your local environment.**

With the makefile present in the Load-Shedding, the teams or engineers who want to contribute to the development of the Load-Shedding library, have a simplified way to run the tests and build the project, the commands are shown below and will wrap and use the same commands that the ones used in the pipeline.

Note: You should be in the root folder of the repository locally, to allow you run the commands.
⚡️ LoadShedding was designed to effectively manage concurrency in the .NET ecosystem.

### Building
🏗 Built upon the foundational principles and concepts pioneered by [Netflix](https://netflixtechblog.medium.com/performance-under-load-3e6fa9a60581).

To build the solution file, you can simply use this command.
🎁 Offers out-of-the-box Adaptative Concurrency Limiter implementation.

```bash
make build
```
🎁 Offers additional features like metrics, request prioritization, and configuration flexibility.

#### Testing (Unit)
## Installation

To run all the tests, you can simply use this command.
[Read the docs](https://farfetch.github.io/loadshedding/docs/getting-started/installation) for any further information.

```bash
make unit-tests
```

The command will build the solution and then run all the tests present and marked as Unit tests.

#### Testing (Integration)

To run all the integration tests, you can simply use this command.

```bash
make integration-tests
```

The command will build the solution and then run all the integration tests.

### Benchmark

Below, it is possible to see a benchmark analysis of the concurrency control mechanism, for this test multiple scenarios were created:

- **Limiter_Default:** Directly tests the AdaptiveConcurrencyLimiter with default priority;
- **Limiter_RandomPriority:** Directly tests the AdaptiveConcurrencyLimiter with random priorities;
- **LimiterMiddleware_Default:** Tests the ConcurrencyLimiterMiddleware that uses the AdaptiveConcurrencyLimiter with Http Requests context with default priority.
- **LimiterMiddleware_RandomPriority:** Tests the ConcurrencyLimiterMiddleware that uses the AdaptiveConcurrencyLimiter with Http Requests context with random priorities.

- **TaskQueueWith1000Items_EnqueueFixedPriority:** Tests the TaskQueue.Enqueue pre-loaded with 1000 items and a default priority;
- **TaskQueueEmpty_EnqueueRandomPriority:** Tests the TaskQueue.Enqueue with no elements;
- **TaskQueueWith1000Items_EnqueueRandomPriority:** Tests the TaskQueue.Enqueue pre-loaded with 1000 items and random priorities;
- **TaskQueueWith1000Items_Dequeue:** Tests the TaskQueue.Dequeue pre-loaded with 1000 items;
- **TaskQueue_EnqueueNewItem_LimitReached:** Tests the TaskQueue.Enqueue pre-loaded with 1000 items and the queue limit reached;

#### Limiter

``` ini
BenchmarkDotNet=v0.13.4, OS=Windows 10 (10.0.19044.2604/21H2/November2021Update)
Intel Core i7-10610U CPU 1.80GHz, 1 CPU, 8 logical and 4 physical cores
.NET SDK=7.0.103
[Host] : .NET 6.0.14 (6.0.1423.7309), X64 RyuJIT AVX2
Job-VLMTWN : .NET 6.0.14 (6.0.1423.7309), X64 RyuJIT AVX2

IterationCount=10
```
## Documentation

| Method | Mean | Error | StdDev | Min | Max | Rank | Completed Work Items | Lock Contentions | Gen0 | Allocated |
|--------------------------------- |---------:|---------:|---------:|---------:|---------:|-----:|---------------------:|-----------------:|-------:|----------:|
| Limiter_Default | 354.4 ns | 6.22 ns | 3.25 ns | 349.2 ns | 358.4 ns | 1 | 0.0000 | - | 0.1450 | 608 B |
| Limiter_RandomPriority | 366.3 ns | 4.82 ns | 2.52 ns | 363.6 ns | 369.6 ns | 2 | 0.0000 | - | 0.1450 | 608 B |
| LimiterMiddleware_Default | 436.6 ns | 28.55 ns | 16.99 ns | 416.7 ns | 471.4 ns | 3 | 0.0000 | - | 0.1855 | 776 B |
| LimiterMiddleware_RandomPriority | 468.7 ns | 6.55 ns | 3.90 ns | 463.7 ns | 475.3 ns | 4 | 0.0000 | - | 0.2027 | 848 B |
Learn more about using LoadShedding on the [site](https://farfetch.github.io/loadshedding/docs)!

##### TaskQueue
## Contributing

``` ini
BenchmarkDotNet=v0.13.4, OS=Windows 10 (10.0.19044.2604/21H2/November2021Update)
Intel Core i7-10610U CPU 1.80GHz, 1 CPU, 8 logical and 4 physical cores
.NET SDK=7.0.103
[Host] : .NET 6.0.14 (6.0.1423.7309), X64 RyuJIT AVX2
Job-THBOTE : .NET 6.0.14 (6.0.1423.7309), X64 RyuJIT AVX2
Read our [contributing guidelines](CONTRIBUTING.md) to learn about our development process, how to propose bugfixes and improvements, and how to build and test your changes.

InvocationCount=1 IterationCount=10 UnrollFactor=1
## Get in touch

```
You can find us at:

| Method | Mean | Error | StdDev | Min | Max | Rank | Completed Work Items | Lock Contentions | Allocated |
|--------------------------------------------- |----------:|----------:|----------:|---------:|----------:|-----:|---------------------:|-----------------:|----------:|
| TaskQueueWith1000Items_EnqueueFixedPriority | 11.311 μs | 3.8278 μs | 2.2779 μs | 6.800 μs | 14.800 μs | 4 | - | - | 896 B |
| TaskQueueEmpty_EnqueueRandomPriority | 6.700 μs | 3.8089 μs | 2.2666 μs | 4.800 μs | 11.800 μs | 2 | - | - | 896 B |
| TaskQueueWith1000Items_EnqueueRandomPriority | 3.650 μs | 0.3540 μs | 0.1852 μs | 3.400 μs | 4.000 μs | 1 | - | - | 896 B |
| TaskQueueWith1000Items_Dequeue | 5.500 μs | 1.0912 μs | 0.5707 μs | 4.600 μs | 6.400 μs | 2 | - | - | 704 B |
| TaskQueue_EnqueueNewItem_LimitReached | 8.111 μs | 2.2848 μs | 1.3596 μs | 7.000 μs | 10.500 μs | 3 | - | - | 1144 B |
- [GitHub Issues](https://github.com/Farfetch/loadshedding/issues)
- [GitHub Discussions](https://github.com/Farfetch/loadshedding/discussions)

#### Conclusion
## License

In all the scenarios the time added to the execution pipeline is very small and the impact caused by the limiter and task queue can be ignored.
LoadShedding is a free and open source project, released under the permissible [MIT license](LICENSE).
20 changes: 20 additions & 0 deletions website/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Dependencies
/node_modules

# Production
/build

# Generated files
.docusaurus
.cache-loader

# Misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
41 changes: 41 additions & 0 deletions website/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Website

This website is built using [Docusaurus](https://docusaurus.io/), a modern static website generator.

### Installation

```
$ yarn
```

### Local Development

```
$ yarn start
```

This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.

### Build

```
$ yarn build
```

This command generates static content into the `build` directory and can be served using any static contents hosting service.

### Deployment

Using SSH:

```
$ USE_SSH=true yarn deploy
```

Not using SSH:

```
$ GIT_USER=<Your GitHub username> yarn deploy
```

If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.
3 changes: 3 additions & 0 deletions website/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
presets: [require.resolve('@docusaurus/core/lib/babel/preset')],
};
7 changes: 7 additions & 0 deletions website/docs/benckmarks/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"label": "Benckmarks",
"position": 5,
"link": {
"type": "generated-index"
}
}
Loading
Loading