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
Hide 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 {
...
@@ -8,29 +8,25 @@ type Config struct {
LogResponseLength
int
LogResponseLength
int
LogShowSql
bool
LogShowSql
bool
//RedisAddr Redis conf
RedisConf
RedisConf
RedisAddr
string
RedisPwd
string
RedisDb
int
//EsServerHttp
EsConf
EsConf
EsServerHttp
string
//mysqlrym
MysqlConf
MysqlConf
MysqlConf
MysqlConf
}
}
func
BaseConfig
(
conf
Config
)
{
func
BaseConfig
(
conf
Config
)
{
ServerName
=
conf
.
ServerName
Env
=
conf
.
Env
LogLevel
=
conf
.
LogLevel
LogLevel
=
conf
.
LogLevel
LogColorful
=
conf
.
LogColorful
LogColorful
=
conf
.
LogColorful
LogResponseLength
=
conf
.
LogResponseLength
LogResponseLength
=
conf
.
LogResponseLength
LogShowSql
=
conf
.
LogShowSql
LogShowSql
=
conf
.
LogShowSql
RedisAddr
=
conf
.
RedisAddr
RedisPwd
=
conf
.
RedisPwd
Es
=
conf
.
EsConf
RedisDb
=
conf
.
RedisDb
ServerName
=
conf
.
ServerName
Redis
=
conf
.
RedisConf
Env
=
conf
.
Env
EsServerHttp
=
conf
.
EsServerHttp
MySql
=
conf
.
MysqlConf
MySql
=
conf
.
MysqlConf
}
}
...
@@ -46,12 +42,21 @@ var LogResponseLength = 10
...
@@ -46,12 +42,21 @@ var LogResponseLength = 10
var
LogShowSql
=
true
var
LogShowSql
=
true
//Redis conf
//Redis conf
var
RedisAddr
=
""
type
RedisConf
struct
{
var
RedisPwd
=
""
RedisAddr
string
var
RedisDb
=
0
RedisPwd
string
RedisDb
int
}
var
Redis
=
RedisConf
{}
//ES conf
//ES conf
var
EsServerHttp
=
""
type
EsConf
struct
{
ServerHost
string
ServerPort
int
}
var
Es
=
EsConf
{}
//Mysql conf
//Mysql conf
type
MysqlConf
struct
{
type
MysqlConf
struct
{
...
...
es/EsClient.go
View file @
307b8f3c
...
@@ -18,7 +18,7 @@ var Client *elastic.Client
...
@@ -18,7 +18,7 @@ var Client *elastic.Client
//初始化
//初始化
func
init
()
{
func
init
()
{
host
:=
conf
.
EsServerHttp
host
:=
fmt
.
Sprintf
(
"http://%s:%d"
,
conf
.
Es
.
ServerHost
,
conf
.
Es
.
ServerPort
)
var
err
error
var
err
error
errorLog
:=
_log
.
New
(
os
.
Stdout
,
"APP"
,
_log
.
LstdFlags
)
errorLog
:=
_log
.
New
(
os
.
Stdout
,
"APP"
,
_log
.
LstdFlags
)
Client
,
err
=
elastic
.
NewClient
(
elastic
.
SetErrorLog
(
errorLog
),
elastic
.
SetURL
(
host
))
Client
,
err
=
elastic
.
NewClient
(
elastic
.
SetErrorLog
(
errorLog
),
elastic
.
SetURL
(
host
))
...
...
redis/RedisClient.go
View file @
307b8f3c
...
@@ -17,9 +17,9 @@ var redisClient *redis.Client
...
@@ -17,9 +17,9 @@ var redisClient *redis.Client
func
init
()
{
func
init
()
{
redisClient
=
redis
.
NewClient
(
&
redis
.
Options
{
redisClient
=
redis
.
NewClient
(
&
redis
.
Options
{
Addr
:
conf
.
RedisAddr
,
Addr
:
conf
.
Redis
.
Redis
Addr
,
Password
:
conf
.
RedisPwd
,
Password
:
conf
.
Redis
.
Redis
Pwd
,
DB
:
conf
.
RedisDb
,
// redis一共16个库,指定其中一个库即可
DB
:
conf
.
Redis
.
Redis
Db
,
// redis一共16个库,指定其中一个库即可
})
})
_
,
err
:=
redisClient
.
Ping
()
.
Result
()
_
,
err
:=
redisClient
.
Ping
()
.
Result
()
if
err
!=
nil
{
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