Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
rym-util
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhengqiuyun
rym-util
Commits
307b8f3c
Commit
307b8f3c
authored
Aug 10, 2022
by
zhengqiuyun86
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
初始化
parent
339e1d59
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
26 additions
and
21 deletions
+26
-21
conf.go
conf/conf.go
+22
-17
EsClient.go
es/EsClient.go
+1
-1
RedisClient.go
redis/RedisClient.go
+3
-3
No files found.
conf/conf.go
View file @
307b8f3c
...
...
@@ -8,29 +8,25 @@ type Config struct {
LogResponseLength
int
LogShowSql
bool
//RedisAddr Redis conf
RedisAddr
string
RedisPwd
string
RedisDb
int
RedisConf
RedisConf
//EsServerHttp
EsServerHttp
string
EsConf
EsConf
//mysqlrym
MysqlConf
MysqlConf
}
func
BaseConfig
(
conf
Config
)
{
ServerName
=
conf
.
ServerName
Env
=
conf
.
Env
LogLevel
=
conf
.
LogLevel
LogColorful
=
conf
.
LogColorful
LogResponseLength
=
conf
.
LogResponseLength
LogShowSql
=
conf
.
LogShowSql
RedisAddr
=
conf
.
RedisAddr
RedisPwd
=
conf
.
RedisPwd
RedisDb
=
conf
.
RedisDb
ServerName
=
conf
.
ServerName
Env
=
conf
.
Env
EsServerHttp
=
conf
.
EsServerHttp
Es
=
conf
.
EsConf
Redis
=
conf
.
RedisConf
MySql
=
conf
.
MysqlConf
}
...
...
@@ -46,12 +42,21 @@ var LogResponseLength = 10
var
LogShowSql
=
true
//Redis conf
var
RedisAddr
=
""
var
RedisPwd
=
""
var
RedisDb
=
0
type
RedisConf
struct
{
RedisAddr
string
RedisPwd
string
RedisDb
int
}
var
Redis
=
RedisConf
{}
//ES conf
var
EsServerHttp
=
""
type
EsConf
struct
{
ServerHost
string
ServerPort
int
}
var
Es
=
EsConf
{}
//Mysql conf
type
MysqlConf
struct
{
...
...
es/EsClient.go
View file @
307b8f3c
...
...
@@ -18,7 +18,7 @@ var Client *elastic.Client
//初始化
func
init
()
{
host
:=
conf
.
EsServerHttp
host
:=
fmt
.
Sprintf
(
"http://%s:%d"
,
conf
.
Es
.
ServerHost
,
conf
.
Es
.
ServerPort
)
var
err
error
errorLog
:=
_log
.
New
(
os
.
Stdout
,
"APP"
,
_log
.
LstdFlags
)
Client
,
err
=
elastic
.
NewClient
(
elastic
.
SetErrorLog
(
errorLog
),
elastic
.
SetURL
(
host
))
...
...
redis/RedisClient.go
View file @
307b8f3c
...
...
@@ -17,9 +17,9 @@ var redisClient *redis.Client
func
init
()
{
redisClient
=
redis
.
NewClient
(
&
redis
.
Options
{
Addr
:
conf
.
RedisAddr
,
Password
:
conf
.
RedisPwd
,
DB
:
conf
.
RedisDb
,
// redis一共16个库,指定其中一个库即可
Addr
:
conf
.
Redis
.
Redis
Addr
,
Password
:
conf
.
Redis
.
Redis
Pwd
,
DB
:
conf
.
Redis
.
Redis
Db
,
// redis一共16个库,指定其中一个库即可
})
_
,
err
:=
redisClient
.
Ping
()
.
Result
()
if
err
!=
nil
{
...
...
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