forked from envoyproxy/ratelimit
/
driver.go
39 lines (32 loc) · 1.09 KB
/
driver.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
package redis
// Errors that may be raised during config parsing.
type RedisError string
func (e RedisError) Error() string {
return string(e)
}
// Interface for a redis connection pool.
type Pool interface {
// Get a connection from the pool. Call Put() on the connection when done.
// Throws RedisError if a connection can not be obtained.
Get() Connection
// Put a connection back into the pool.
// @param c supplies the connection to put back.
Put(c Connection)
}
// Interface for a redis connection.
type Connection interface {
// Append a command onto the pipeline queue.
// @param command supplies the command to append.
// @param args supplies the additional arguments.
PipeAppend(command string, args ...interface{})
// Execute the pipeline queue and wait for a response.
// @return a response object.
// Throws a RedisError if there was an error fetching the response.
PipeResponse() Response
}
// Interface for a redis response.
type Response interface {
// @return the response as an integer.
// Throws a RedisError if the response is not convertable to an integer.
Int() int64
}