Fix bug
This commit is contained in:
@@ -16,16 +16,18 @@ type RouteConfig struct {
|
||||
MaxScale int `yaml:"max_scale"`
|
||||
}
|
||||
|
||||
type RedisConfig struct {
|
||||
Host string `yaml:"host"`
|
||||
Port uint16 `yaml:"port"`
|
||||
User string `yaml:"user"`
|
||||
Password string `yaml:"password"`
|
||||
Database int `yaml:"database"`
|
||||
}
|
||||
|
||||
type Configuration struct {
|
||||
Host string `yaml:"host"`
|
||||
Port uint16 `yaml:"port"`
|
||||
Redis struct {
|
||||
Host string `yaml:"host"`
|
||||
Port uint16 `yaml:"port"`
|
||||
User string `yaml:"user"`
|
||||
Password string `yaml:"password"`
|
||||
Database int `yaml:"database"`
|
||||
} `yaml:"redis"`
|
||||
Host string `yaml:"host"`
|
||||
Port uint16 `yaml:"port"`
|
||||
Redis RedisConfig `yaml:"redis"`
|
||||
Routes struct {
|
||||
Face RouteConfig `yaml:"face"`
|
||||
Head RouteConfig `yaml:"head"`
|
||||
|
||||
@@ -33,7 +33,7 @@ func init() {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if err = r.Connect(config.Redis.URI, config.Redis.Database); err != nil {
|
||||
if err = r.Connect(config.Redis); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"fmt"
|
||||
"image"
|
||||
"image/draw"
|
||||
"time"
|
||||
@@ -14,10 +15,12 @@ type Redis struct {
|
||||
conn *redis.Client
|
||||
}
|
||||
|
||||
func (r *Redis) Connect(uri string, database int) error {
|
||||
func (r *Redis) Connect(conf RedisConfig) error {
|
||||
c := redis.NewClient(&redis.Options{
|
||||
Addr: uri,
|
||||
DB: database,
|
||||
Addr: fmt.Sprintf("%s:%d", conf.Host, conf.Port),
|
||||
Username: conf.User,
|
||||
Password: conf.Password,
|
||||
DB: conf.Database,
|
||||
})
|
||||
|
||||
r.conn = c
|
||||
|
||||
Reference in New Issue
Block a user