Skip to content

Commit

Permalink
优化部分代码
Browse files Browse the repository at this point in the history
- checkjob周期单位恢复为小时
- 预留调试代码,启用可跳过证书验证,用于自签发证书场景
- 消费队列内容时候无需Skip,入队列前已做好过滤
  • Loading branch information
jorben committed Mar 15, 2024
1 parent c0414bf commit 8b0387b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion checkjob.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (c *CheckJob) Run(ctx context.Context) {
go c.Walk(ctx)

// 创建周期定时器
ticker := time.NewTicker(time.Duration(c.Interval) * time.Minute)
ticker := time.NewTicker(time.Duration(c.Interval) * time.Hour)
defer ticker.Stop()
for range ticker.C {
// 执行周期校对任务
Expand Down
3 changes: 3 additions & 0 deletions storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@ func NewStorage(c *config.SyncConfig) (*Storage, error) {
Creds: credentials.NewStaticV4(c.Remote.SecretId, c.Remote.SecretKey, ""),
Region: c.Remote.Region,
Secure: c.Remote.UseSSL,
// 可以跳过证书校验,可用于自签发证书的场景
//Transport: &http.Transport{TLSClientConfig: &tls.Config{InsecureSkipVerify: true}},
})
if err != nil {
return nil, err
}

return &Storage{
Minio: cli,
Bucket: c.Remote.Bucket,
Expand Down
4 changes: 2 additions & 2 deletions transfer.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (t *Transfer) Run(ctx context.Context) {
err := filepath.WalkDir(path, func(subPath string, d fs.DirEntry, err error) error {
if err := t.Storage.FPutObject(ctx, subPath); err != nil {
log.Errorf("FPutObject err: %s, file: %s", err.Error(), subPath)
return filepath.SkipDir
return nil
}
log.Infof("Sync success, path: %s", subPath)
return nil
Expand All @@ -61,7 +61,7 @@ func (t *Transfer) Run(ctx context.Context) {
if err := t.Storage.RemoveObjects(ctx, path); err != nil {
continue
}
log.Debugf("Remove success, path: %s", path)
log.Infof("Remove success, path: %s", path)
}

}
Expand Down
2 changes: 1 addition & 1 deletion watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (w *Watcher) Watch() error {

if !w.Enable {
log.Debug("The real-time sync is disabled")
// Hold住进程,以便单用check job的场景
// Hold进程,以便单用check job的场景
<-make(chan struct{})
}

Expand Down

0 comments on commit 8b0387b

Please sign in to comment.