♻️ Refactor synchronization service
This commit is contained in:
31
internal/syncer/backend/backend.go
Normal file
31
internal/syncer/backend/backend.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package backend
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
)
|
||||
|
||||
var (
|
||||
// ErrRevisionConflict 表示远端版本已变化,需要重新拉取合并。
|
||||
ErrRevisionConflict = errors.New("sync revision conflict")
|
||||
)
|
||||
|
||||
// RemoteState 描述远端最新状态。
|
||||
type RemoteState struct {
|
||||
Revision string
|
||||
Exists bool
|
||||
}
|
||||
|
||||
// PublishOptions 描述一次发布操作的参数。
|
||||
type PublishOptions struct {
|
||||
ExpectedRevision string
|
||||
Message string
|
||||
}
|
||||
|
||||
// Backend 描述统一同步后端接口。
|
||||
type Backend interface {
|
||||
Verify(ctx context.Context) error
|
||||
DownloadLatest(ctx context.Context, dst string) (RemoteState, error)
|
||||
Upload(ctx context.Context, src string, options PublishOptions) (RemoteState, error)
|
||||
Close() error
|
||||
}
|
||||
Reference in New Issue
Block a user