-
Notifications
You must be signed in to change notification settings - Fork 0
/
pool.go
43 lines (33 loc) · 876 Bytes
/
pool.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package proxy
import (
"errors"
"github.com/valyala/fasthttp"
)
var (
// errClosed is the error resulting if the pool is closed via pool.Close().
errClosed = errors.New("pool is closed")
)
// Proxier can be HTTP or WebSocket proxier
// TODO:
type Proxier interface {
ServeHTTP(ctx *fasthttp.RequestCtx)
// ?
SetClient(addr string) Proxier
// Reset .
Reset()
// Close .
Close()
}
// Pool interface ...
// this interface ref to: https://github.com/fatih/pool/blob/master/pool.go
type Pool interface {
// Get returns a new ReverseProxy from the pool.
Get(string) (*ReverseProxy, error)
// Put Reseting the ReverseProxy puts it back to the Pool.
Put(*ReverseProxy) error
// Close closes the pool and all its connections. After Close() the pool is
// no longer usable.
Close()
// Len returns the current number of connections of the pool.
Len() int
}