docs(proxy): sharpen AX usage comments
Co-Authored-By: Virgil <virgil@lethean.io>
This commit is contained in:
parent
7dd9807a6e
commit
5a3fcf4fab
2 changed files with 19 additions and 6 deletions
14
proxy.go
14
proxy.go
|
|
@ -14,10 +14,12 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
// Proxy owns the servers, splitters, stats, workers, and monitoring API.
|
||||
// Proxy is the top-level orchestrator.
|
||||
//
|
||||
// p, result := proxy.New(cfg)
|
||||
// if result.OK { p.Start() }
|
||||
// if result.OK {
|
||||
// p.Start()
|
||||
// }
|
||||
type Proxy struct {
|
||||
config *Config
|
||||
configMu sync.RWMutex
|
||||
|
|
@ -110,7 +112,9 @@ type CloseEvent struct {
|
|||
|
||||
// ConfigWatcher polls a config file for changes.
|
||||
//
|
||||
// watcher := proxy.NewConfigWatcher("config.json", func(cfg *proxy.Config) { p.Reload(cfg) })
|
||||
// watcher := proxy.NewConfigWatcher("config.json", func(cfg *proxy.Config) {
|
||||
// p.Reload(cfg)
|
||||
// })
|
||||
type ConfigWatcher struct {
|
||||
path string
|
||||
onChange func(*Config)
|
||||
|
|
@ -121,7 +125,9 @@ type ConfigWatcher struct {
|
|||
// RateLimiter throttles new connections per source IP.
|
||||
//
|
||||
// limiter := proxy.NewRateLimiter(proxy.RateLimit{MaxConnectionsPerMinute: 30, BanDurationSeconds: 300})
|
||||
// limiter.Allow("1.2.3.4:3333")
|
||||
// if limiter.Allow("1.2.3.4:3333") {
|
||||
// // accept the socket
|
||||
// }
|
||||
type RateLimiter struct {
|
||||
config RateLimit
|
||||
buckets map[string]*tokenBucket
|
||||
|
|
|
|||
11
server.go
11
server.go
|
|
@ -7,8 +7,15 @@ import (
|
|||
|
||||
// Server listens on one BindAddr and creates a Miner for each accepted connection.
|
||||
//
|
||||
// srv, result := proxy.NewServer(bind, tlsCfg, rateLimiter, onAccept)
|
||||
// if result.OK { srv.Start() }
|
||||
// srv, result := proxy.NewServer(
|
||||
// proxy.BindAddr{Host: "0.0.0.0", Port: 3333, TLS: false},
|
||||
// nil,
|
||||
// proxy.NewRateLimiter(proxy.RateLimit{MaxConnectionsPerMinute: 30}),
|
||||
// onAccept,
|
||||
// )
|
||||
// if result.OK {
|
||||
// srv.Start()
|
||||
// }
|
||||
type Server struct {
|
||||
addr BindAddr
|
||||
tlsCfg *tls.Config // nil for plain TCP
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue