mirror of
https://github.com/go-gitea/gitea
synced 2025-01-23 17:17:48 +01:00
Queue: Allow Redis to connect to unix
This commit is contained in:
parent
1013ced326
commit
1fb9104009
@ -41,6 +41,7 @@ type RedisQueue struct {
|
||||
|
||||
// RedisQueueConfiguration is the configuration for the redis queue
|
||||
type RedisQueueConfiguration struct {
|
||||
Network string
|
||||
Addresses string
|
||||
Password string
|
||||
DBIndex int
|
||||
@ -88,6 +89,7 @@ func NewRedisQueue(handle HandlerFunc, cfg, exemplar interface{}) (Queue, error)
|
||||
return nil, errors.New("no redis host found")
|
||||
} else if len(dbs) == 1 {
|
||||
queue.client = redis.NewClient(&redis.Options{
|
||||
Network: config.Network,
|
||||
Addr: strings.TrimSpace(dbs[0]), // use default Addr
|
||||
Password: config.Password, // no password set
|
||||
DB: config.DBIndex, // use default DB
|
||||
|
@ -22,6 +22,7 @@ type queueSettings struct {
|
||||
BatchLength int
|
||||
ConnectionString string
|
||||
Type string
|
||||
Network string
|
||||
Addresses string
|
||||
Password string
|
||||
QueueName string
|
||||
@ -47,6 +48,7 @@ func CreateQueue(name string, handle queue.HandlerFunc, exemplar interface{}) qu
|
||||
opts["BatchLength"] = q.BatchLength
|
||||
opts["DataDir"] = q.DataDir
|
||||
opts["Addresses"] = q.Addresses
|
||||
opts["Network"] = q.Network
|
||||
opts["Password"] = q.Password
|
||||
opts["DBIndex"] = q.DBIndex
|
||||
opts["QueueName"] = q.QueueName
|
||||
@ -111,7 +113,7 @@ func getQueueSettings(name string) queueSettings {
|
||||
q.BoostWorkers = sec.Key("BOOST_WORKERS").MustInt(Queue.BoostWorkers)
|
||||
q.QueueName = sec.Key("QUEUE_NAME").MustString(Queue.QueueName)
|
||||
|
||||
q.Addresses, q.Password, q.DBIndex, _ = ParseQueueConnStr(q.ConnectionString)
|
||||
q.Network, q.Addresses, q.Password, q.DBIndex, _ = ParseQueueConnStr(q.ConnectionString)
|
||||
return q
|
||||
}
|
||||
|
||||
@ -128,7 +130,7 @@ func NewQueueService() {
|
||||
Queue.ConnectionString = sec.Key("CONN_STR").MustString(path.Join(AppDataPath, ""))
|
||||
validTypes := queue.RegisteredTypesAsString()
|
||||
Queue.Type = sec.Key("TYPE").In(string(queue.PersistableChannelQueueType), validTypes)
|
||||
Queue.Addresses, Queue.Password, Queue.DBIndex, _ = ParseQueueConnStr(Queue.ConnectionString)
|
||||
Queue.Network, Queue.Addresses, Queue.Password, Queue.DBIndex, _ = ParseQueueConnStr(Queue.ConnectionString)
|
||||
Queue.WrapIfNecessary = sec.Key("WRAP_IF_NECESSARY").MustBool(true)
|
||||
Queue.MaxAttempts = sec.Key("MAX_ATTEMPTS").MustInt(10)
|
||||
Queue.Timeout = sec.Key("TIMEOUT").MustDuration(GracefulHammerTime + 30*time.Second)
|
||||
@ -183,7 +185,7 @@ func NewQueueService() {
|
||||
}
|
||||
|
||||
// ParseQueueConnStr parses a queue connection string
|
||||
func ParseQueueConnStr(connStr string) (addrs, password string, dbIdx int, err error) {
|
||||
func ParseQueueConnStr(connStr string) (network, addrs, password string, dbIdx int, err error) {
|
||||
fields := strings.Fields(connStr)
|
||||
for _, f := range fields {
|
||||
items := strings.SplitN(f, "=", 2)
|
||||
@ -191,6 +193,8 @@ func ParseQueueConnStr(connStr string) (addrs, password string, dbIdx int, err e
|
||||
continue
|
||||
}
|
||||
switch strings.ToLower(items[0]) {
|
||||
case "network":
|
||||
network = items[1]
|
||||
case "addrs":
|
||||
addrs = items[1]
|
||||
case "password":
|
||||
|
Loading…
x
Reference in New Issue
Block a user