Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
孙龙
/
ichunt_golang_demo
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
ba7a2ba8
authored
Apr 21, 2021
by
孙龙
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
up
parent
328086f7
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
49 additions
and
4 deletions
app/common/config/redis.go
app/dao/dao.go
app/dao/user.go
config/dev/redis.toml
router/httpserver.go
app/common/config/redis.go
View file @
ba7a2ba8
...
@@ -31,5 +31,16 @@ func BuildRedisGroupConfigs() ( map[string]RedisGroupDatabase) {
...
@@ -31,5 +31,16 @@ func BuildRedisGroupConfigs() ( map[string]RedisGroupDatabase) {
WriteTimeout
:
time
.
Duration
(
lib
.
Instance
(
"redis"
)
.
GetInt
(
"api.write_timeout"
))
*
time
.
Second
,
WriteTimeout
:
time
.
Duration
(
lib
.
Instance
(
"redis"
)
.
GetInt
(
"api.write_timeout"
))
*
time
.
Second
,
MinIdleConns
:
lib
.
Instance
(
"redis"
)
.
GetInt
(
"api.min_idle_conns"
),
MinIdleConns
:
lib
.
Instance
(
"redis"
)
.
GetInt
(
"api.min_idle_conns"
),
},
},
"sku"
:
{
MasterHost
:
lib
.
Instance
(
"redis"
)
.
GetString
(
"sku.master.host"
),
Password
:
lib
.
Instance
(
"redis"
)
.
GetString
(
"sku.master.password"
),
SlaveHost
:
lib
.
Instance
(
"redis"
)
.
GetStringSlice
(
"sku.slave.host"
),
ReadonlyPassword
:
lib
.
Instance
(
"redis"
)
.
GetString
(
"sku.slave.password"
),
DialTimeout
:
time
.
Duration
(
lib
.
Instance
(
"redis"
)
.
GetInt
(
"sku.dial_timeout"
))
*
time
.
Second
,
ReadTimeout
:
time
.
Duration
(
lib
.
Instance
(
"redis"
)
.
GetInt
(
"sku.read_timeout"
))
*
time
.
Second
,
WriteTimeout
:
time
.
Duration
(
lib
.
Instance
(
"redis"
)
.
GetInt
(
"sku.write_timeout"
))
*
time
.
Second
,
MinIdleConns
:
lib
.
Instance
(
"redis"
)
.
GetInt
(
"sku.min_idle_conns"
),
},
}
}
}
}
app/dao/dao.go
View file @
ba7a2ba8
...
@@ -95,7 +95,7 @@ func redisSetup(d *dao) *dao{
...
@@ -95,7 +95,7 @@ func redisSetup(d *dao) *dao{
AutoEjectHost
:
true
,
//是否弹出故障主机
AutoEjectHost
:
true
,
//是否弹出故障主机
ServerFailureLimit
:
3
,
//达到失败次数时弹出
ServerFailureLimit
:
3
,
//达到失败次数时弹出
ServerRetryTimeout
:
5
*
time
.
Second
,
//在“ServerRetryTimeout”之后重试弹出的主机`
ServerRetryTimeout
:
5
*
time
.
Second
,
//在“ServerRetryTimeout”之后重试弹出的主机`
MinServerNum
:
1
,
//保留min服务器 针对从服务器
MinServerNum
:
0
,
//保留min服务器 针对从服务器
})
})
if
err
!=
nil
{
if
err
!=
nil
{
...
...
app/dao/user.go
View file @
ba7a2ba8
...
@@ -3,6 +3,7 @@ package dao
...
@@ -3,6 +3,7 @@ package dao
import
"fmt"
import
"fmt"
func
GetUser
(){
func
GetUser
(){
fmt
.
Println
(
"555555555555555555555555555555555"
)
res
,
err
:=
Dao
.
GetDb
(
"micro"
)
.
QueryString
(
"select service_name from lie_service_info where is_delete = 1 "
)
res
,
err
:=
Dao
.
GetDb
(
"micro"
)
.
QueryString
(
"select service_name from lie_service_info where is_delete = 1 "
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -13,9 +14,23 @@ func GetUser(){
...
@@ -13,9 +14,23 @@ func GetUser(){
if
err
!=
nil
{
if
err
!=
nil
{
}
}
fmt
.
Println
(
res
)
//
fmt.Println(res)
//Dao.GetRedisDbGroup("api").Set("abcdef","123456789",0)
//Dao.GetRedisDbGroup("api").Set("abcdef","123456789",0)
fmt
.
Println
(
Dao
.
GetRedisDbGroup
(
"api"
)
.
Get
(
"abcdef"
)
.
String
())
//fmt.Println("555555555555555555555555555555555")
//a := Dao.GetRedisDbGroup("api").Get("abcdef")
//fmt.Println(a.Result())
//
//fmt.Println(Dao.GetRedisDbGroup("api").Get("abcdef"))
fmt
.
Println
(
Dao
.
GetRedisDbGroup
(
"api"
)
.
Get
(
"abcdef"
))
//fmt.Println(Dao.GetRedisDbGroup("api").Get("abcdef"))
//fmt.Println(Dao.GetRedisDbGroup("api").Get("abcdef"))
//fmt.Println(Dao.GetRedisDbGroup("api").Get("abcdef"))
//fmt.Println(Dao.GetRedisDbGroup("api").Get("abcdef"))
//fmt.Println(Dao.GetRedisDbGroup("api").Get("abcdef"))
//fmt.Println(Dao.GetRedisDbGroup("api").Get("abcdef"))
fmt
.
Println
(
Dao
.
GetRedisDbGroup
(
"sku"
)
.
Get
(
"abcdef"
)
.
String
())
//fmt.Println("555555555555555555555555555555555")
}
}
config/dev/redis.toml
View file @
ba7a2ba8
...
@@ -12,3 +12,19 @@
...
@@ -12,3 +12,19 @@
"192.168.1.235:6379"
,
"192.168.1.235:6379"
,
"192.168.1.237:6379"
,
"192.168.1.237:6379"
,
]
]
[sku]
dial_timeout
=
20
min_idle_conns
=
10
read_timeout
=
10
write_timeout
=
10
[sku.master]
host
=
"192.168.1.235:6379"
password
=
"icDb29mLy2s"
[sku.slave]
password
=
"icDb29mLy2s"
host
=
[
"192.168.1.235:6379"
,
"192.168.1.237:6379"
,
]
router/httpserver.go
View file @
ba7a2ba8
...
@@ -22,7 +22,10 @@ func HttpServerRun() {
...
@@ -22,7 +22,10 @@ func HttpServerRun() {
//fmt.Println(cfg.Instance("proxy").GetString("base.debug_mode"))
//fmt.Println(cfg.Instance("proxy").GetString("base.debug_mode"))
gin
.
SetMode
(
cfg
.
Instance
(
"proxy"
)
.
GetString
(
"base.debug_mode"
))
gin
.
SetMode
(
cfg
.
Instance
(
"proxy"
)
.
GetString
(
"base.debug_mode"
))
r
:=
InitRouter
(
middleware
.
RequestLog
(),
middleware
.
RecoveryMiddleware
())
r
:=
InitRouter
(
//middleware.RequestLog(),
middleware
.
RecoveryMiddleware
(),
)
HttpSrvHandler
=
&
http
.
Server
{
HttpSrvHandler
=
&
http
.
Server
{
Addr
:
cfg
.
Instance
(
"proxy"
)
.
GetString
(
"http.addr"
),
Addr
:
cfg
.
Instance
(
"proxy"
)
.
GetString
(
"http.addr"
),
//Addr: "192.168.1.234:2002",
//Addr: "192.168.1.234:2002",
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment