Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
X
xpkg
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
屠思豪
xpkg
Commits
b9c4159d
提交
b9c4159d
authored
9月 18, 2025
作者:
mooncake9527
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
upd
上级
555bac62
隐藏空白字符变更
内嵌
并排
正在显示
15 个修改的文件
包含
100 行增加
和
75 行删除
+100
-75
xpkg.yaml
conf/xpkg.yaml
+13
-7
config.go
config/config.go
+21
-16
init.go
config/init.go
+3
-0
consts.go
consts/consts.go
+5
-5
init.go
database/init.go
+15
-17
mysql.go
database/mysql.go
+1
-1
redis.go
database/redis.go
+1
-1
init.go
eventbus/init.go
+1
-0
xgin.go
gin/xgin/xgin.go
+6
-6
init.go
init.go
+3
-3
webLogUtils.go
utils/webLogUtils/webLogUtils.go
+10
-4
cron_job.go
xcron/dao/cron_job.go
+0
-5
cron_job_log.go
xcron/dao/cron_job_log.go
+0
-5
cron_job_record.go
xcron/dao/cron_job_record.go
+0
-5
init.go
xcron/dao/init.go
+21
-0
没有找到文件。
conf/xpkg.yaml
浏览文件 @
b9c4159d
...
@@ -7,15 +7,20 @@ app:
...
@@ -7,15 +7,20 @@ app:
cors
:
false
# true or false
cors
:
false
# true or false
requestID
:
requestID
:
key
:
trace-id
# string or empty
key
:
trace-id
# string or empty
enableStat
:
false
enableStat
:
false
enableMetrics
:
true
enableMetrics
:
true
enableHTTPProfile
:
true
enableHTTPProfile
:
true
enableLimit
:
false
enableLimit
:
false
enableCircuitBreaker
:
false
enableCircuitBreaker
:
false
enableTrace
:
false
trace
:
tracingSamplingRate
:
1.0
enable
:
false
samplingRate
:
1.0
registryDiscoveryType
:
"
"
registryDiscoveryType
:
"
"
cacheType
:
"
memory"
cacheType
:
"
memory"
webLog
:
enable
:
true
schema
:
operator
ignorePaths
:
ipRateLimiter
:
ipRateLimiter
:
enable
:
true
enable
:
true
window
:
1m
window
:
1m
...
@@ -99,6 +104,7 @@ auth:
...
@@ -99,6 +104,7 @@ auth:
cron
:
cron
:
enable
:
true
enable
:
true
schema
:
operator
oss
:
oss
:
endpoint
:
https://oss-cn-hangzhou.aliyuncs.com
endpoint
:
https://oss-cn-hangzhou.aliyuncs.com
...
...
config/config.go
浏览文件 @
b9c4159d
...
@@ -53,7 +53,7 @@ func Get() *Config {
...
@@ -53,7 +53,7 @@ func Get() *Config {
func
CronOpen
()
bool
{
func
CronOpen
()
bool
{
enable
:=
false
enable
:=
false
Read
(
func
(
c
*
Config
)
{
Read
(
func
(
c
*
Config
)
{
enable
=
c
.
Cron
Jobs
.
Enable
enable
=
c
.
Cron
.
Enable
})
})
return
enable
return
enable
}
}
...
@@ -110,7 +110,7 @@ type Config struct {
...
@@ -110,7 +110,7 @@ type Config struct {
Jaeger
Jaeger
`yaml:"jaeger" json:"jaeger"`
Jaeger
Jaeger
`yaml:"jaeger" json:"jaeger"`
Logger
Logger
`yaml:"logger" json:"logger"`
Logger
Logger
`yaml:"logger" json:"logger"`
Redis
Redis
`yaml:"redis" json:"redis"`
Redis
Redis
`yaml:"redis" json:"redis"`
Cron
Jobs
Cron
`yaml:"cron" json:"cron"`
Cron
Cron
`yaml:"cron" json:"cron"`
Oss
oss
.
AliOssConfig
`yaml:"oss" json:"oss"`
Oss
oss
.
AliOssConfig
`yaml:"oss" json:"oss"`
Content
[]
byte
`yaml:"-" json:"-"`
Content
[]
byte
`yaml:"-" json:"-"`
}
}
...
@@ -214,19 +214,13 @@ type Email struct {
...
@@ -214,19 +214,13 @@ type Email struct {
}
}
type
App
struct
{
type
App
struct
{
CacheType
string
`yaml:"cacheType" json:"cacheType"`
CacheType
string
`yaml:"cacheType" json:"cacheType"`
Middleware
Middleware
`yaml:"middleware" json:"middleware"`
Middleware
Middleware
`yaml:"middleware" json:"middleware"`
EnableCircuitBreaker
bool
`yaml:"enableCircuitBreaker" json:"enableCircuitBreaker"`
EnableHTTPProfile
bool
`yaml:"enableHTTPProfile" json:"enableHTTPProfile"`
EnableLimit
bool
`yaml:"enableLimit" json:"enableLimit"`
EnableMetrics
bool
`yaml:"enableMetrics" json:"enableMetrics"`
EnableStat
bool
`yaml:"enableStat" json:"enableStat"`
EnableTrace
bool
`yaml:"enableTrace" json:"enableTrace"`
Env
string
`yaml:"env" json:"env"`
Env
string
`yaml:"env" json:"env"`
Host
string
`yaml:"host" json:"host"`
Host
string
`yaml:"host" json:"host"`
Name
string
`yaml:"name" json:"name"`
Name
string
`yaml:"name" json:"name"`
RegistryDiscoveryType
string
`yaml:"registryDiscoveryType" json:"registryDiscoveryType"`
// e.g. nacos, consul , close if empty
RegistryDiscoveryType
string
`yaml:"registryDiscoveryType" json:"registryDiscoveryType"`
// e.g. nacos, consul , close if empty
TracingSamplingRate
float64
`yaml:"tracingSamplingRate" json:"tracingSamplingRate"`
Version
string
`yaml:"version" json:"version"`
Version
string
`yaml:"version" json:"version"`
IPRateLimiter
IPRateLimiter
`yaml:"ipRateLimiter" json:"ipRateLimiter"`
IPRateLimiter
IPRateLimiter
`yaml:"ipRateLimiter" json:"ipRateLimiter"`
...
@@ -239,8 +233,14 @@ type App struct {
...
@@ -239,8 +233,14 @@ type App struct {
}
}
type
Middleware
struct
{
type
Middleware
struct
{
Cors
bool
`yaml:"cors" json:"cors"`
Cors
bool
`yaml:"cors" json:"cors"`
RequestID
RequestID
`yaml:"requestID" json:"requestID"`
RequestID
RequestID
`yaml:"requestID" json:"requestID"`
EnableCircuitBreaker
bool
`yaml:"enableCircuitBreaker" json:"enableCircuitBreaker"`
EnableHTTPProfile
bool
`yaml:"enableHTTPProfile" json:"enableHTTPProfile"`
EnableLimit
bool
`yaml:"enableLimit" json:"enableLimit"`
EnableMetrics
bool
`yaml:"enableMetrics" json:"enableMetrics"`
EnableStat
bool
`yaml:"enableStat" json:"enableStat"`
Trace
Trace
`yaml:"trace" json:"trace"`
}
}
type
RequestID
struct
{
type
RequestID
struct
{
...
@@ -255,9 +255,15 @@ type IDGeneration struct {
...
@@ -255,9 +255,15 @@ type IDGeneration struct {
type
WebLog
struct
{
type
WebLog
struct
{
Enable
bool
`yaml:"enable" json:"enable"`
Enable
bool
`yaml:"enable" json:"enable"`
Schema
string
`yaml:"schema" json:"schema"`
IgnorePaths
[]
string
`yaml:"ignorePaths" json:"ignorePaths"`
IgnorePaths
[]
string
`yaml:"ignorePaths" json:"ignorePaths"`
}
}
type
Trace
struct
{
Enable
bool
`yaml:"enable" json:"enable"`
SamplingRate
float64
`yaml:"samplingRate" json:"samplingRate"`
}
type
IPRateLimiter
struct
{
type
IPRateLimiter
struct
{
Enable
bool
`yaml:"enable" json:"enable"`
Enable
bool
`yaml:"enable" json:"enable"`
Sync
bool
`yaml:"sync" json:"sync"`
Sync
bool
`yaml:"sync" json:"sync"`
...
@@ -341,7 +347,6 @@ type Redis struct {
...
@@ -341,7 +347,6 @@ type Redis struct {
type
Database
struct
{
type
Database
struct
{
Name
string
`yaml:"name" json:"name"`
Name
string
`yaml:"name" json:"name"`
Driver
string
`yaml:"driver" json:"driver"`
Driver
string
`yaml:"driver" json:"driver"`
Default
bool
`yaml:"default" json:"default"`
Mongodb
Mongodb
`yaml:"mongodb" json:"mongodb"`
Mongodb
Mongodb
`yaml:"mongodb" json:"mongodb"`
Mysql
Mysql
`yaml:"mysql" json:"mysql"`
Mysql
Mysql
`yaml:"mysql" json:"mysql"`
Postgresql
Mysql
`yaml:"postgresql" json:"postgresql"`
Postgresql
Mysql
`yaml:"postgresql" json:"postgresql"`
...
@@ -390,8 +395,8 @@ type UpgradeLimit struct {
...
@@ -390,8 +395,8 @@ type UpgradeLimit struct {
}
}
type
Cron
struct
{
type
Cron
struct
{
// Jobs []CronJob`yaml:"jobs" json:"jobs
"`
Enable
bool
`yaml:"enable" json:"enable
"`
Enable
bool
`yaml:"enable" json:"enable
"`
Schema
string
`yaml:"schema" json:"schema
"`
}
}
type
Leaf
struct
{
type
Leaf
struct
{
...
...
config/init.go
浏览文件 @
b9c4159d
...
@@ -2,11 +2,13 @@ package config
...
@@ -2,11 +2,13 @@ package config
import
(
import
(
"bytes"
"bytes"
"context"
"os"
"os"
"strings"
"strings"
"github.com/spf13/cast"
"github.com/spf13/cast"
"github.com/spf13/viper"
"github.com/spf13/viper"
"gitlab.wanzhuangkj.com/tush/xpkg/eventbus"
"gitlab.wanzhuangkj.com/tush/xpkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/logger"
)
)
...
@@ -59,6 +61,7 @@ func Parse() (err error) {
...
@@ -59,6 +61,7 @@ func Parse() (err error) {
return
err
return
err
}
}
}
}
eventbus
.
Eb
.
Publish
(
context
.
TODO
(),
eventbus
.
TopicParseConfFinish
)
return
nil
return
nil
}
}
...
...
consts/consts.go
浏览文件 @
b9c4159d
package
consts
package
consts
var
(
var
(
DefaultSchema
string
//
DefaultSchema string
RootRoute
string
RootRoute
string
)
)
func
SetDefaultSchema
(
schema
string
)
{
//
func SetDefaultSchema(schema string) {
DefaultSchema
=
schema
//
DefaultSchema = schema
}
//
}
func
SetRootRoute
(
v
string
)
{
func
SetRootRoute
(
v
string
)
{
RootRoute
=
v
RootRoute
=
v
...
...
database/init.go
浏览文件 @
b9c4159d
...
@@ -5,8 +5,6 @@ import (
...
@@ -5,8 +5,6 @@ import (
"strings"
"strings"
"gitlab.wanzhuangkj.com/tush/xpkg/config"
"gitlab.wanzhuangkj.com/tush/xpkg/config"
"gitlab.wanzhuangkj.com/tush/xpkg/consts"
"gitlab.wanzhuangkj.com/tush/xpkg/logger"
"gitlab.wanzhuangkj.com/tush/xpkg/sgorm"
"gitlab.wanzhuangkj.com/tush/xpkg/sgorm"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror"
"gitlab.wanzhuangkj.com/tush/xpkg/xerrors/xerror"
)
)
...
@@ -21,21 +19,21 @@ func InitDB() (err error) {
...
@@ -21,21 +19,21 @@ func InitDB() (err error) {
config
.
Read
(
func
(
c
*
config
.
Config
)
{
config
.
Read
(
func
(
c
*
config
.
Config
)
{
databases
=
c
.
Database
databases
=
c
.
Database
})
})
if
len
(
databases
)
==
1
{
//
if len(databases) == 1 {
consts
.
DefaultSchema
=
databases
[
0
]
.
Name
//
consts.DefaultSchema = databases[0].Name
}
else
{
//
} else {
found
:=
false
//
found := false
for
_
,
db
:=
range
databases
{
//
for _, db := range databases {
if
db
.
Default
{
//
if db.Default {
consts
.
DefaultSchema
=
db
.
Name
//
consts.DefaultSchema = db.Name
found
=
true
//
found = true
}
//
}
}
//
}
if
!
found
{
//
if !found {
consts
.
DefaultSchema
=
databases
[
0
]
.
Name
//
consts.DefaultSchema = databases[0].Name
}
//
}
}
//
}
logger
.
Info
(
"[database] default schema: "
+
consts
.
DefaultSchema
)
//
logger.Info("[database] default schema: " + consts.DefaultSchema)
for
_
,
db
:=
range
databases
{
for
_
,
db
:=
range
databases
{
switch
strings
.
ToLower
(
db
.
Driver
)
{
switch
strings
.
ToLower
(
db
.
Driver
)
{
case
sgorm
.
DBDriverMysql
,
sgorm
.
DBDriverTidb
:
case
sgorm
.
DBDriverMysql
,
sgorm
.
DBDriverTidb
:
...
...
database/mysql.go
浏览文件 @
b9c4159d
...
@@ -15,7 +15,7 @@ import (
...
@@ -15,7 +15,7 @@ import (
func
InitMysql
(
dbConfig
*
config
.
Database
)
(
*
sgorm
.
DB
,
error
)
{
func
InitMysql
(
dbConfig
*
config
.
Database
)
(
*
sgorm
.
DB
,
error
)
{
enableTrace
:=
false
enableTrace
:=
false
config
.
Read
(
func
(
c
*
config
.
Config
)
{
config
.
Read
(
func
(
c
*
config
.
Config
)
{
enableTrace
=
c
.
App
.
EnableTrac
e
enableTrace
=
c
.
App
.
Middleware
.
Trace
.
Enabl
e
})
})
opts
:=
[]
mysql
.
Option
{
opts
:=
[]
mysql
.
Option
{
mysql
.
WithMaxIdleConns
(
dbConfig
.
Mysql
.
MaxIdleConns
),
mysql
.
WithMaxIdleConns
(
dbConfig
.
Mysql
.
MaxIdleConns
),
...
...
database/redis.go
浏览文件 @
b9c4159d
...
@@ -61,7 +61,7 @@ func InitRedis() {
...
@@ -61,7 +61,7 @@ func InitRedis() {
enableTrace
:=
false
enableTrace
:=
false
config
.
Read
(
func
(
c
*
config
.
Config
)
{
config
.
Read
(
func
(
c
*
config
.
Config
)
{
copier
.
Copy
(
&
redisCfg
,
&
c
.
Redis
)
copier
.
Copy
(
&
redisCfg
,
&
c
.
Redis
)
enableTrace
=
c
.
App
.
EnableTrac
e
enableTrace
=
c
.
App
.
Middleware
.
Trace
.
Enabl
e
})
})
opts
:=
[]
goredis
.
Option
{
opts
:=
[]
goredis
.
Option
{
goredis
.
WithLogger
(
logger
.
Get
()),
goredis
.
WithLogger
(
logger
.
Get
()),
...
...
eventbus/init.go
浏览文件 @
b9c4159d
...
@@ -3,6 +3,7 @@ package eventbus
...
@@ -3,6 +3,7 @@ package eventbus
var
Eb
=
New
()
var
Eb
=
New
()
const
(
const
(
TopicParseConfFinish
string
=
"event:application:conf:init:finish"
// 配置文件解析完毕
TopicDBInitFinish
string
=
"event:application:database:init:finish"
// 数据库连接初始化完成
TopicDBInitFinish
string
=
"event:application:database:init:finish"
// 数据库连接初始化完成
TopicCacheInitFinish
string
=
"event:application:cache:init:finish"
// cache初始化完成
TopicCacheInitFinish
string
=
"event:application:cache:init:finish"
// cache初始化完成
TopicCronInitFinish
string
=
"event:application:cron:init:finish"
// 定时任务初始化完成
TopicCronInitFinish
string
=
"event:application:cron:init:finish"
// 定时任务初始化完成
...
...
gin/xgin/xgin.go
浏览文件 @
b9c4159d
...
@@ -67,31 +67,31 @@ func New() *gin.Engine {
...
@@ -67,31 +67,31 @@ func New() *gin.Engine {
jwt
.
WithSigningMethod
(
jwt
.
HS256
),
jwt
.
WithSigningMethod
(
jwt
.
HS256
),
)
)
}
}
if
app
.
EnableMetrics
{
if
app
.
Middleware
.
EnableMetrics
{
r
.
Use
(
metrics
.
Metrics
(
r
,
r
.
Use
(
metrics
.
Metrics
(
r
,
metrics
.
WithIgnoreStatusCodes
(
http
.
StatusNotFound
),
// ignore 404 status codes
metrics
.
WithIgnoreStatusCodes
(
http
.
StatusNotFound
),
// ignore 404 status codes
))
))
}
}
if
app
.
EnableLimit
{
if
app
.
Middleware
.
EnableLimit
{
r
.
Use
(
middleware
.
RateLimit
())
r
.
Use
(
middleware
.
RateLimit
())
}
}
if
app
.
EnableCircuitBreaker
{
if
app
.
Middleware
.
EnableCircuitBreaker
{
r
.
Use
(
middleware
.
CircuitBreaker
())
r
.
Use
(
middleware
.
CircuitBreaker
())
}
}
if
app
.
EnableTrac
e
{
if
app
.
Middleware
.
Trace
.
Enabl
e
{
r
.
Use
(
middleware
.
Tracing
(
app
.
Name
))
r
.
Use
(
middleware
.
Tracing
(
app
.
Name
))
}
}
if
app
.
EnableHTTPProfile
{
if
app
.
Middleware
.
EnableHTTPProfile
{
prof
.
Register
(
r
,
prof
.
WithIOWaitTime
())
prof
.
Register
(
r
,
prof
.
WithIOWaitTime
())
}
}
binding
.
Validator
=
validator
.
Init
()
binding
.
Validator
=
validator
.
Init
()
r
.
Use
(
xvalidator
.
Translation
())
r
.
Use
(
xvalidator
.
Translation
())
webLogUtils
.
Init
(
consts
.
DefaultSchema
)
webLogUtils
.
Init
()
if
config
.
IsNotProd
()
{
if
config
.
IsNotProd
()
{
r
.
GET
(
consts
.
RootRoute
+
"/config"
,
gin
.
WrapF
(
errcode
.
ShowConfig
([]
byte
(
config
.
Show
()))))
r
.
GET
(
consts
.
RootRoute
+
"/config"
,
gin
.
WrapF
(
errcode
.
ShowConfig
([]
byte
(
config
.
Show
()))))
...
...
init.go
浏览文件 @
b9c4159d
...
@@ -45,19 +45,19 @@ func Init() (err error) {
...
@@ -45,19 +45,19 @@ func Init() (err error) {
if
err
:=
initLogger
(
conf
);
err
!=
nil
{
if
err
:=
initLogger
(
conf
);
err
!=
nil
{
return
err
return
err
}
}
if
conf
.
App
.
EnableTrac
e
{
if
conf
.
App
.
Middleware
.
Trace
.
Enabl
e
{
tracer
.
InitWithConfig
(
tracer
.
InitWithConfig
(
conf
.
App
.
Name
,
conf
.
App
.
Name
,
conf
.
App
.
Env
,
conf
.
App
.
Env
,
conf
.
App
.
Version
,
conf
.
App
.
Version
,
conf
.
Jaeger
.
AgentHost
,
conf
.
Jaeger
.
AgentHost
,
strconv
.
Itoa
(
conf
.
Jaeger
.
AgentPort
),
strconv
.
Itoa
(
conf
.
Jaeger
.
AgentPort
),
conf
.
App
.
Tracing
SamplingRate
,
conf
.
App
.
Middleware
.
Trace
.
SamplingRate
,
)
)
logger
.
Info
(
"[tracer] initialized"
)
logger
.
Info
(
"[tracer] initialized"
)
}
}
if
conf
.
App
.
EnableStat
{
if
conf
.
App
.
Middleware
.
EnableStat
{
stat
.
Init
(
stat
.
Init
(
stat
.
WithLog
(
logger
.
Get
()),
stat
.
WithAlarm
(),
stat
.
WithLog
(
logger
.
Get
()),
stat
.
WithAlarm
(),
stat
.
WithPrintField
(
logger
.
String
(
"service_name"
,
conf
.
App
.
Name
),
logger
.
String
(
"host"
,
conf
.
App
.
Host
)),
stat
.
WithPrintField
(
logger
.
String
(
"service_name"
,
conf
.
App
.
Name
),
logger
.
String
(
"host"
,
conf
.
App
.
Host
)),
...
...
utils/webLogUtils/webLogUtils.go
浏览文件 @
b9c4159d
...
@@ -27,10 +27,15 @@ import (
...
@@ -27,10 +27,15 @@ import (
)
)
var
(
var
(
schema
string
enable
bool
=
false
enable
bool
=
false
ignore
=
make
(
map
[
string
]
struct
{})
ignore
=
make
(
map
[
string
]
struct
{})
)
)
func
SetSchema
(
v
string
)
{
schema
=
v
}
func
WebLogInterceptor
()
func
(
c
*
gin
.
Context
)
{
func
WebLogInterceptor
()
func
(
c
*
gin
.
Context
)
{
return
func
(
c
*
gin
.
Context
)
{
return
func
(
c
*
gin
.
Context
)
{
if
!
enable
{
if
!
enable
{
...
@@ -92,7 +97,7 @@ func GetUserID(ctx context.Context) xsf.ID {
...
@@ -92,7 +97,7 @@ func GetUserID(ctx context.Context) xsf.ID {
var
merger
*
merge
.
FanIn
var
merger
*
merge
.
FanIn
func
Init
(
schema
string
)
{
func
Init
()
{
var
webLogCfg
config
.
WebLog
var
webLogCfg
config
.
WebLog
config
.
IsProd
()
config
.
IsProd
()
config
.
Read
(
func
(
c
*
config
.
Config
)
{
config
.
Read
(
func
(
c
*
config
.
Config
)
{
...
@@ -101,6 +106,7 @@ func Init(schema string) {
...
@@ -101,6 +106,7 @@ func Init(schema string) {
if
!
webLogCfg
.
Enable
{
if
!
webLogCfg
.
Enable
{
return
return
}
}
schema
=
webLogCfg
.
Schema
isProd
:=
config
.
IsProd
()
isProd
:=
config
.
IsProd
()
for
_
,
p
:=
range
webLogCfg
.
IgnorePaths
{
for
_
,
p
:=
range
webLogCfg
.
IgnorePaths
{
ignore
[
strings
.
TrimSpace
(
p
)]
=
struct
{}{}
ignore
[
strings
.
TrimSpace
(
p
)]
=
struct
{}{}
...
@@ -127,7 +133,7 @@ func Init(schema string) {
...
@@ -127,7 +133,7 @@ func Init(schema string) {
return
nil
return
nil
}
}
insertFn
:=
func
()
error
{
insertFn
:=
func
()
error
{
if
err
:=
WebLogDao
.
CreateSliceSilent
(
ctx
,
ors
);
err
!=
nil
{
if
err
:=
webLogDaoInstance
.
CreateSliceSilent
(
ctx
,
ors
);
err
!=
nil
{
logger
.
Error
(
"[webLog] insert fail detail"
,
logger
.
Err
(
err
),
ctxUtils
.
CtxTraceIDField
(
ctx
))
logger
.
Error
(
"[webLog] insert fail detail"
,
logger
.
Err
(
err
),
ctxUtils
.
CtxTraceIDField
(
ctx
))
return
err
return
err
}
}
...
@@ -147,7 +153,7 @@ func Init(schema string) {
...
@@ -147,7 +153,7 @@ func Init(schema string) {
merger
.
Start
()
merger
.
Start
()
WebLogDao
.
db
=
database
.
DB
(
schema
)
webLogDaoInstance
.
db
=
database
.
DB
(
schema
)
}
}
func
AddAsync
(
ctx
context
.
Context
,
traceNo
,
operate
string
,
req
*
entity
.
CopyHttpReq
,
rsp
*
entity
.
CopyHttpRsp
)
{
func
AddAsync
(
ctx
context
.
Context
,
traceNo
,
operate
string
,
req
*
entity
.
CopyHttpReq
,
rsp
*
entity
.
CopyHttpRsp
)
{
...
@@ -173,7 +179,7 @@ type webLogDao struct {
...
@@ -173,7 +179,7 @@ type webLogDao struct {
db
*
gorm
.
DB
db
*
gorm
.
DB
}
}
var
WebLogDao
=
&
webLogDao
{}
var
webLogDaoInstance
=
&
webLogDao
{}
func
(
x
*
webLogDao
)
CreateSliceSilent
(
ctx
context
.
Context
,
ors
[]
*
WebLog
)
error
{
func
(
x
*
webLogDao
)
CreateSliceSilent
(
ctx
context
.
Context
,
ors
[]
*
WebLog
)
error
{
return
x
.
db
.
WithContext
(
ctx
)
.
Session
(
&
gorm
.
Session
{
Logger
:
glogger
.
Discard
})
.
Create
(
ors
)
.
Error
return
x
.
db
.
WithContext
(
ctx
)
.
Session
(
&
gorm
.
Session
{
Logger
:
glogger
.
Discard
})
.
Create
(
ors
)
.
Error
...
...
xcron/dao/cron_job.go
浏览文件 @
b9c4159d
...
@@ -3,8 +3,6 @@ package dao
...
@@ -3,8 +3,6 @@ package dao
import
(
import
(
"context"
"context"
"gitlab.wanzhuangkj.com/tush/xpkg/consts"
"gitlab.wanzhuangkj.com/tush/xpkg/database"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/enums"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/models"
...
@@ -22,9 +20,6 @@ type cronJobDao struct {
...
@@ -22,9 +20,6 @@ type cronJobDao struct {
var
CronJobDao
=
&
cronJobDao
{
var
CronJobDao
=
&
cronJobDao
{
ODao
:
&
odao
.
ODao
[
models
.
CronJob
]{
ODao
:
&
odao
.
ODao
[
models
.
CronJob
]{
XDB
:
&
database
.
XDB
{
Schema
:
consts
.
DefaultSchema
,
},
Sf
:
new
(
singleflight
.
Group
),
Sf
:
new
(
singleflight
.
Group
),
},
},
}
}
...
...
xcron/dao/cron_job_log.go
浏览文件 @
b9c4159d
...
@@ -3,12 +3,10 @@ package dao
...
@@ -3,12 +3,10 @@ package dao
import
(
import
(
"context"
"context"
"gitlab.wanzhuangkj.com/tush/xpkg/consts"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/models"
"gitlab.wanzhuangkj.com/tush/xpkg/database"
"golang.org/x/sync/singleflight"
"golang.org/x/sync/singleflight"
)
)
...
@@ -18,9 +16,6 @@ type cronJobLogDao struct {
...
@@ -18,9 +16,6 @@ type cronJobLogDao struct {
var
CronJobLogDao
=
&
cronJobLogDao
{
var
CronJobLogDao
=
&
cronJobLogDao
{
ODao
:
&
odao
.
ODao
[
models
.
CronJobLog
]{
ODao
:
&
odao
.
ODao
[
models
.
CronJobLog
]{
XDB
:
&
database
.
XDB
{
Schema
:
consts
.
DefaultSchema
,
},
Sf
:
new
(
singleflight
.
Group
),
Sf
:
new
(
singleflight
.
Group
),
},
},
}
}
...
...
xcron/dao/cron_job_record.go
浏览文件 @
b9c4159d
...
@@ -3,8 +3,6 @@ package dao
...
@@ -3,8 +3,6 @@ package dao
import
(
import
(
"context"
"context"
"gitlab.wanzhuangkj.com/tush/xpkg/consts"
"gitlab.wanzhuangkj.com/tush/xpkg/database"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/utils/xsf"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
"gitlab.wanzhuangkj.com/tush/xpkg/xcommon/odao"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/models"
"gitlab.wanzhuangkj.com/tush/xpkg/xcron/models"
...
@@ -18,9 +16,6 @@ type cronJobRecordDao struct {
...
@@ -18,9 +16,6 @@ type cronJobRecordDao struct {
var
CronJobRecordDao
=
&
cronJobRecordDao
{
var
CronJobRecordDao
=
&
cronJobRecordDao
{
ODao
:
&
odao
.
ODao
[
models
.
CronJobRecord
]{
ODao
:
&
odao
.
ODao
[
models
.
CronJobRecord
]{
XDB
:
&
database
.
XDB
{
Schema
:
consts
.
DefaultSchema
,
},
Sf
:
new
(
singleflight
.
Group
),
Sf
:
new
(
singleflight
.
Group
),
},
},
}
}
...
...
xcron/dao/init.go
0 → 100644
浏览文件 @
b9c4159d
package
dao
import
(
"context"
"gitlab.wanzhuangkj.com/tush/xpkg/config"
"gitlab.wanzhuangkj.com/tush/xpkg/database"
"gitlab.wanzhuangkj.com/tush/xpkg/eventbus"
)
func
init
()
{
_
=
eventbus
.
Eb
.
Subscribe
(
eventbus
.
TopicParseConfFinish
,
func
(
ctx
context
.
Context
)
{
schema
:=
""
config
.
Read
(
func
(
c
*
config
.
Config
)
{
schema
=
c
.
Cron
.
Schema
})
CronJobDao
.
ODao
.
XDB
=
&
database
.
XDB
{
Schema
:
schema
}
CronJobLogDao
.
ODao
.
XDB
=
&
database
.
XDB
{
Schema
:
schema
}
CronJobRecordDao
.
ODao
.
XDB
=
&
database
.
XDB
{
Schema
:
schema
}
})
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论