You can not select more than 25 topics
Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- package factory
-
- import (
- "reflect"
-
- _ "gitlink.org.cn/cloudream/jcs-pub/common/pkgs/storage"
- "gitlink.org.cn/cloudream/jcs-pub/common/pkgs/storage/factory/reg"
- stgtypes "gitlink.org.cn/cloudream/jcs-pub/common/pkgs/storage/types"
- jcstypes "gitlink.org.cn/cloudream/jcs-pub/common/types"
- )
-
- // 此函数永远不会返回nil。如果找不到对应的Builder,则会返回EmptyBuilder,
- // 此Builder的所有函数都会返回否定值或者封装后的ErrUnsupported错误(需要使用errors.Is检查)
- func GetBuilder(detail *jcstypes.UserSpaceDetail) stgtypes.StorageBuilder {
- typ := reflect.TypeOf(detail.UserSpace.Storage)
-
- ctor, ok := reg.StorageBuilders[typ]
- if !ok {
- return &stgtypes.EmptyBuilder{}
- }
-
- return ctor(detail)
- }
|