diff options
author | Wim <wim@42.be> | 2017-12-03 01:24:05 +0100 |
---|---|---|
committer | Wim <wim@42.be> | 2017-12-03 01:24:05 +0100 |
commit | ed9118b34620f1ecd5f28506328d4ffe1b04793d (patch) | |
tree | 442998012f6779446a463e402fa7c0836edcac91 /vendor/github.com/shazow/rateio/doc.go | |
parent | 59e55cfbd5cc3c82236c5e8b95e5baff256f7143 (diff) | |
download | matterbridge-msglm-ed9118b34620f1ecd5f28506328d4ffe1b04793d.tar.gz matterbridge-msglm-ed9118b34620f1ecd5f28506328d4ffe1b04793d.tar.bz2 matterbridge-msglm-ed9118b34620f1ecd5f28506328d4ffe1b04793d.zip |
Add sshchat dependencies in vendor
Diffstat (limited to 'vendor/github.com/shazow/rateio/doc.go')
-rw-r--r-- | vendor/github.com/shazow/rateio/doc.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/vendor/github.com/shazow/rateio/doc.go b/vendor/github.com/shazow/rateio/doc.go new file mode 100644 index 00000000..1c5e0851 --- /dev/null +++ b/vendor/github.com/shazow/rateio/doc.go @@ -0,0 +1,29 @@ +/* +Package rateio provides an io interfaces for rate-limiting. + +This can be used to apply rate limiting to any type that implements an io-style interface. + +For example, we can use it to restrict the reading rate of a net.Conn: + + type limitedConn struct { + net.Conn + io.Reader // Our rate-limited io.Reader for net.Conn + } + + func (r *limitedConn) Read(p []byte) (n int, err error) { + return r.Reader.Read(p) + } + + // ReadLimitConn returns a net.Conn whose io.Reader interface is rate-limited by limiter. + func ReadLimitConn(conn net.Conn, limiter rateio.Limiter) net.Conn { + return &limitedConn{ + Conn: conn, + Reader: rateio.NewReader(conn, limiter), + } + } + +Then we can use ReadLimitConn to wrap our existing net.Conn and continue using +the wrapped version in its place. + +*/ +package rateio |