feat: database as plugin

This commit is contained in:
 Ilya Atamas
2019-04-22 12:49:19 +03:00
parent ab36f4f081
commit 838154ce9c
10 changed files with 82 additions and 41 deletions

View File

@@ -28,7 +28,7 @@ Start proxy server.
| `--cache-ttl <timeout>` | `CACHE_TTL` | `3600` | Cache expiration timeout in seconds |
| `--redis-address <address>` | `REDIS_ADDRESS` | `http://localhost:6379` | Redis address |
| `--redis-database <database>` | `REDIS_DATABASE` | `0` | Redis database |
| `--redis-password <password>` | `REDIS_PASSWORD` | - | Redis password |
| `--redis-password <password>` | `REDIS_PASSWORD` | - | Redis password |
| `--redis-prefix <prefix>` | `REDIS_PREFIX` | `ncp-` | Redis keys prefix |
### `ncp list`
@@ -54,16 +54,16 @@ import (
func main() {
proxy := npmproxy.Proxy{
RedisClient: redis.NewClient(&redis.Options{
Addr: "localhost:6379",
DB: 0,
Password: "",
}),
Database: npmproxy.DatabaseRedis{
Client: redis.NewClient(&redis.Options{
Addr: "localhost:6379",
}),
},
HttpClient: &http.Client{},
GetOptions: func() (npmproxy.Options, error) {
return npmproxy.Options{
RedisPrefix: "ncp-",
RedisExpireTimeout: 1 * time.Hour,
DatabasePrefix: "ncp-",
DatabaseExpiration: 1 * time.Hour,
UpstreamAddress: "https://registry.npmjs.org",
}, nil
},