From c28d7ad7883f3df27e2ae4f86e2651458cb84655 Mon Sep 17 00:00:00 2001 From: Jimmy Zelinskie Date: Sat, 15 Jan 2022 13:03:41 -0500 Subject: [PATCH] lint: lint markdown files --- .markdownlint.yaml | 3 +++ CONTRIBUTING.md | 6 ++++-- README.md | 14 +++++++------- docs/architecture.md | 6 +++--- docs/frontend.md | 22 ++++++++++++---------- docs/storage/redis.md | 7 +++---- 6 files changed, 32 insertions(+), 26 deletions(-) create mode 100644 .markdownlint.yaml diff --git a/.markdownlint.yaml b/.markdownlint.yaml new file mode 100644 index 0000000..80875d4 --- /dev/null +++ b/.markdownlint.yaml @@ -0,0 +1,3 @@ +--- +line-length: false +no-hard-tabs: false diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index adbf076..d6e7898 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,3 +1,5 @@ +# How to Contribute + ## Discussion Long-term discussion and bug reports are maintained via [GitHub Issues]. @@ -55,7 +57,7 @@ All files should have `gofmt` executed on them and code should strive to have fu We follow a rough convention for commit messages that is designed to answer two questions: what changed and why. The subject line should feature the what and the body of the commit should describe the why. -``` +```git scripts: add the test-cluster command this uses tmux to setup a test cluster that you can easily kill and @@ -66,7 +68,7 @@ Fixes #38 The format can be described more formally as follows: -``` +```git : diff --git a/README.md b/README.md index 5221d08..6d9f308 100644 --- a/README.md +++ b/README.md @@ -57,10 +57,10 @@ For more information read [CONTRIBUTING.md]. In order to compile the project, the [latest stable version of Go] and knowledge of a [working Go environment] are required. ```sh -$ git clone git@github.com:chihaya/chihaya.git -$ cd chihaya -$ go build ./cmd/chihaya -$ ./chihaya --help +git clone git@github.com:chihaya/chihaya.git +cd chihaya +go build ./cmd/chihaya +./chihaya --help ``` [latest stable version of Go]: https://golang.org/dl @@ -79,15 +79,15 @@ The following will run all tests and benchmarks. Removing `-bench` will just run unit tests. ```sh -$ go test -bench $(go list ./...) +go test -bench $(go list ./...) ``` The Chihaya executable contains a command to end-to-end test a BitTorrent tracker. See ```sh -$ chihaya --help -``` +chihaya --help +``` ### Configuration diff --git a/docs/architecture.md b/docs/architecture.md index dad5b8e..efc86f6 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -1,6 +1,6 @@ # Architecture -### Overview +## Overview BitTorrent clients send Announce and Scrape requests to a _Frontend_. Frontends parse requests and write responses for the particular protocol they implement. @@ -11,6 +11,6 @@ After all PreHooks have executed, any missing response fields that are required PostHooks are asynchronous tasks that occur after a response has been delivered to the client. Because they are unnecessary to for generating a response, updates to the Storage for a particular request are done asynchronously in a PostHook. -### Diagram +## Diagram -![](https://user-images.githubusercontent.com/343539/52676700-05c45c80-2ef9-11e9-9887-8366008b4e7e.png) +![architecture diagram](https://user-images.githubusercontent.com/343539/52676700-05c45c80-2ef9-11e9-9887-8366008b4e7e.png) diff --git a/docs/frontend.md b/docs/frontend.md index 5826eab..bf698db 100644 --- a/docs/frontend.md +++ b/docs/frontend.md @@ -44,11 +44,11 @@ The typical control flow of handling announces, in more detail, is: 6. Send the response to the Client. 7. Pass the request and response to the `TrackerLogic`'s `AfterAnnounce` or `AfterScrape` method. 8. Finish, accept next request. -9. For invalid requests or errors during processing: Send an error response to the client. - This step may be skipped for suspected denial-of-service attacks. - The error response may contain information about the cause of the error. - Only errors where the Client is at fault should be explained, internal server errors should be returned without explanation. - Then finish, and accept the next request. +9. For invalid requests or errors during processing: Send an error response to the client. + This step may be skipped for suspected denial-of-service attacks. + The error response may contain information about the cause of the error. + Only errors where the Client is at fault should be explained, internal server errors should be returned without explanation. + Then finish, and accept the next request. #### Configuration @@ -62,20 +62,22 @@ Frontends may provide runtime metrics, such as the number of requests or their d Metrics must be reported using [Prometheus]. A frontend should provide at least the following metrics: + - The number of valid and invalid requests handled - The average time it takes to handle a single request. - This request timing should be made optional using a config entry. + This request timing should be made optional using a config entry. Requests should be separated by type, i.e. Scrapes, Announces, and other protocol-specific requests. If the frontend serves multiple transports or networks, metrics for them should be separable. It is recommended to publish one Prometheus `HistogramVec` with: + - A name like `chihaya_PROTOCOL_response_duration_milliseconds` - A value holding the duration in milliseconds of the reported request - Labels for: - - `action` (= `announce`, `scrape`, ...) - - `address_family` (= `Unknown`, `IPv4`, `IPv6`, ...), if applicable - - `error` (= A textual representation of the error encountered during processing.) + - `action` (= `announce`, `scrape`, ...) + - `address_family` (= `Unknown`, `IPv4`, `IPv6`, ...), if applicable + - `error` (= A textual representation of the error encountered during processing.) Because `error` is expected to hold the textual representation of any error that occurred during the request, great care must be taken to ensure all error messages are static. `error` must not contain any information directly taken from the request, e.g. the value of an invalid parameter. This would cause this dimension of prometheus to explode, which slows down prometheus clients and reporters. @@ -106,4 +108,4 @@ This way, a PreHook can communicate with a PostHook by setting a context value. [BEP 3]: http://bittorrent.org/beps/bep_0003.html [BEP 15]: http://bittorrent.org/beps/bep_0015.html [Prometheus]: https://prometheus.io/ -[old-opentracker-style]: https://web.archive.org/web/20170503181830/http://opentracker.blog.h3q.com/2007/12/28/the-ipv6-situation/ \ No newline at end of file +[old-opentracker-style]: https://web.archive.org/web/20170503181830/http://opentracker.blog.h3q.com/2007/12/28/the-ipv6-situation/ diff --git a/docs/storage/redis.md b/docs/storage/redis.md index da3b3fb..c3a81f7 100644 --- a/docs/storage/redis.md +++ b/docs/storage/redis.md @@ -59,7 +59,7 @@ All the InfoHashes (swarms) are also stored in a redis hash, with IP family as t Here is an example: -``` +```yaml - IPv4 - IPv4_S_: - IPv4_L_: @@ -73,15 +73,14 @@ Here is an example: - : ``` - In this case, prometheus would record two swarms, three seeders, and one leecher. These three keys per address family are used to record the count of swarms, seeders, and leechers. -``` +```yaml - IPv4_infohash_count: 2 - IPv4_S_count: 3 - IPv4_L_count: 1 ``` -Note: IPv4_infohash_count has a different meaning compared to the `memory` storage: +Note: `IPv4_infohash_count` has a different meaning compared to the `memory` storage: It represents the number of infohashes reported by seeder, meaning that infohashes without seeders are not counted.