mirror of
https://github.com/certimate-go/certimate.git
synced 2026-07-20 21:01:41 +08:00
refactor: clean code
This commit is contained in:
parent
439ff56ed9
commit
0311609a2d
@ -25,11 +25,7 @@ type CertificateService struct {
|
||||
settingsRepo settingsRepository
|
||||
}
|
||||
|
||||
func NewCertificateService(
|
||||
acmeAccountRepo acmeAccountRepository,
|
||||
certificateRepo certificateRepository,
|
||||
settingsRepo settingsRepository,
|
||||
) *CertificateService {
|
||||
func NewCertificateService(acmeAccountRepo acmeAccountRepository, certificateRepo certificateRepository, settingsRepo settingsRepository) *CertificateService {
|
||||
return &CertificateService{
|
||||
acmeAccountRepo: acmeAccountRepo,
|
||||
certificateRepo: certificateRepo,
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package domain
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const CollectionNameAccess = "access"
|
||||
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package domain
|
||||
|
||||
import "time"
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type Meta struct {
|
||||
Id string `db:"id" json:"id"`
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
package scheduler
|
||||
|
||||
import "context"
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
type certificateService interface {
|
||||
InitSchedule(ctx context.Context) error
|
||||
}
|
||||
|
||||
func InitCertificateScheduler(service certificateService) error {
|
||||
func initCertificateScheduler(service certificateService) error {
|
||||
return service.InitSchedule(context.Background())
|
||||
}
|
||||
|
||||
@ -19,11 +19,11 @@ func Setup() {
|
||||
workflowSvc := workflow.NewWorkflowService(workflowRepo, workflowRunRepo, settingsRepo)
|
||||
certificateSvc := certificate.NewCertificateService(acmeAccountRepo, certificateRepo, settingsRepo)
|
||||
|
||||
if err := InitWorkflowScheduler(workflowSvc); err != nil {
|
||||
if err := initWorkflowScheduler(workflowSvc); err != nil {
|
||||
app.GetLogger().Error("failed to init workflow scheduler", slog.Any("error", err))
|
||||
}
|
||||
|
||||
if err := InitCertificateScheduler(certificateSvc); err != nil {
|
||||
if err := initCertificateScheduler(certificateSvc); err != nil {
|
||||
app.GetLogger().Error("failed to init certificate scheduler", slog.Any("error", err))
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,11 +1,13 @@
|
||||
package scheduler
|
||||
|
||||
import "context"
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
type workflowService interface {
|
||||
InitSchedule(ctx context.Context) error
|
||||
}
|
||||
|
||||
func InitWorkflowScheduler(service workflowService) error {
|
||||
func initWorkflowScheduler(service workflowService) error {
|
||||
return service.InitSchedule(context.Background())
|
||||
}
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package engine
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
var (
|
||||
// 表示工作流引擎执行被中断,可能已结束
|
||||
|
||||
@ -13,7 +13,11 @@ var (
|
||||
|
||||
func thisSvcInst() *WorkflowService {
|
||||
thisSvcOnce.Do(func() {
|
||||
thisSvc = NewWorkflowService(repository.NewWorkflowRepository(), repository.NewWorkflowRunRepository(), repository.NewSettingsRepository())
|
||||
thisSvc = NewWorkflowService(
|
||||
repository.NewWorkflowRepository(),
|
||||
repository.NewWorkflowRunRepository(),
|
||||
repository.NewSettingsRepository(),
|
||||
)
|
||||
})
|
||||
return thisSvc
|
||||
}
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package cert
|
||||
|
||||
import "github.com/baidubce/bce-sdk-go/services/cert"
|
||||
import (
|
||||
"github.com/baidubce/bce-sdk-go/services/cert"
|
||||
)
|
||||
|
||||
type CreateCertArgs struct {
|
||||
cert.CreateCertArgs
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package v3
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
const region = "c3j1"
|
||||
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package cdn
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type sdkResponse interface {
|
||||
GetAPIError() error
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package kcm
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type sdkResponse interface {
|
||||
GetAPIError() error
|
||||
|
||||
Loading…
Reference in New Issue
Block a user