Skip to content

Commit

Permalink
refactor: WatchDogFactory func rename
Browse files Browse the repository at this point in the history
  • Loading branch information
CC11001100 committed Aug 14, 2023
1 parent e33156b commit 2845449
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion storage_lock_lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ func (x *StorageLock) lockNotExists(ctx context.Context, e *events.Event, lockId
}

// 为自己创建一只新的看门狗
x.storageLockWatchDog, err = x.options.WatchDogFactory.New(ctx, e.Fork(), x, ownerId)
x.storageLockWatchDog, err = x.options.WatchDogFactory.NewWatchDog(ctx, e.Fork(), x, ownerId)
if err != nil {
// 看门狗创建失败,尝试释放掉锁
x.lockRollback(ctx, e.Fork(), lockId, ownerId, lockInformation)
Expand Down
4 changes: 2 additions & 2 deletions watch_dog_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ type WatchDogFactory interface {
// Name 此工厂是什么品种的狗狗而工作,用于表明工厂的类型
Name() string

// New 创建一只看门狗
// NewWatchDog 创建一只看门狗
// ctx: 控制超时传递上下文之类的
// e: 新创建的WatchDog如果需要支持事件的话,则保存这个WatchDog的根事件,后面它所触发的事件都是这个事件的子事件
// lock: 在为哪个锁创建WatchDog,WatchDog可能会用到锁的一些上下文之类的,比如lockId啥的
// ownerId: 这个WatchDog是为哪个主人而创建,狗狗都是很忠诚的,一只狗狗终生只为一个主人守护他的锁
New(ctx context.Context, e *events.Event, lock *StorageLock, ownerId string) (WatchDog, error)
NewWatchDog(ctx context.Context, e *events.Event, lock *StorageLock, ownerId string) (WatchDog, error)
}
2 changes: 1 addition & 1 deletion watch_dog_factory_commons_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ func (x *WatchDogFactoryCommonsImpl) Name() string {
return WatchDogFactoryCommonsImplName
}

func (x *WatchDogFactoryCommonsImpl) New(ctx context.Context, e *events.Event, lock *StorageLock, ownerId string) (WatchDog, error) {
func (x *WatchDogFactoryCommonsImpl) NewWatchDog(ctx context.Context, e *events.Event, lock *StorageLock, ownerId string) (WatchDog, error) {
return NewWatchDogCommonsImpl(ctx, e, lock, ownerId), nil
}
2 changes: 1 addition & 1 deletion watch_dog_factory_func_wrapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ func (x *WatchDogFactoryFuncWrapper) Name() string {
return x.name
}

func (x *WatchDogFactoryFuncWrapper) New(ctx context.Context, e *events.Event, lock *StorageLock, ownerId string) (WatchDog, error) {
func (x *WatchDogFactoryFuncWrapper) NewWatchDog(ctx context.Context, e *events.Event, lock *StorageLock, ownerId string) (WatchDog, error) {
return x.newFunc(ctx, e, lock, ownerId)
}

0 comments on commit 2845449

Please sign in to comment.