From b45d3f79f5b9955891a06f9079c6c210584d5aaf Mon Sep 17 00:00:00 2001 From: "kayos@tcp.direct" Date: Wed, 6 Jul 2022 04:41:58 -0700 Subject: [PATCH] Update README.md --- LICENSE | 2 +- README.md | 66 ++++++++++++++++++++++++++++++++----------------------- 2 files changed, 40 insertions(+), 28 deletions(-) diff --git a/LICENSE b/LICENSE index a3f10ca..3bbe3c8 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2021 yunginnanet +Copyright (c) 2021 yunginnanet (kayos@tcp.direct) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/README.md b/README.md index 16dd936..497d000 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,23 @@ -# Rate5 +# Rate5 [![GoDoc](https://godoc.org/github.com/yunginnanet/?status.svg)](https://godoc.org/github.com/yunginnanet/Rate5) [![Go Report Card](https://goreportcard.com/badge/github.com/yunginnanet/Rate5)](https://goreportcard.com/report/github.com/yunginnanet/Rate5) [![Go](https://github.com/yunginnanet/Rate5/actions/workflows/go.yml/badge.svg?branch=main)](https://github.com/yunginnanet/Rate5/actions/workflows/go.yml) [![codecov](https://codecov.io/gh/yunginnanet/Rate5/branch/main/graph/badge.svg?token=R7WU58G5L7)](https://codecov.io/gh/yunginnanet/Rate5) - -A generic ratelimitter for any golang project. -See [the docs](https://godoc.org/github.com/yunginnanet/Rate5) and the [examples](_examples/rated.go) below for more details. - - -## Short Example -``` -import rate5 "github.com/yunginnanet/rate5" +A performant and generic ratelimitter for any golang project. +See [the docs](https://godoc.org/github.com/yunginnanet/Rate5) and the unit tests as well as the below example for more details. -var Rater *rate5.Limiter +## Basic Example +```go +import rate5 "github.com/yunginnanet/rate5" -[...] +var Rater *rate5.Limiter + +[...] type Client struct { ID string Conn net.Conn loggedin bool -} +} // Rate5 doesn't care where you derive the string used for ratelimiting func (c Client) UniqueKey() string { @@ -29,24 +27,38 @@ func (c Client) UniqueKey() string { } return c.ID } - + func (s *Server) handleTCP(c *Client) { // Returns true if ratelimited if Rater.Check(c) { - c.Conn.Write([]byte("too many connections")) + c.Conn.Write([]byte("too many connections")) c.Conn.Close() return } -[...] - -``` - -## In-depth example - -[Concurrent TCP Server with Rate5 Ratelimiter](_examples/rated.go) - -## To-Do -More Documentation -More To-Dos -~~Test Cases~~ -More test cases. +// [...] +} +``` + +## License + +``` +MIT License + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +```