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.

service.go 2.7 kB

2 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. package distlock
  2. import (
  3. "gitlink.org.cn/cloudream/common/pkgs/distlock"
  4. "gitlink.org.cn/cloudream/common/pkgs/trie"
  5. "gitlink.org.cn/cloudream/storage/common/pkgs/distlock/lockprovider"
  6. )
  7. type Service = distlock.Service
  8. func NewService(cfg *distlock.Config) (*distlock.Service, error) {
  9. srv, err := distlock.NewService(cfg, initProviders())
  10. if err != nil {
  11. return nil, err
  12. }
  13. return srv, nil
  14. }
  15. func initProviders() []distlock.PathProvider {
  16. var provs []distlock.PathProvider
  17. provs = append(provs, initMetadataLockProviders()...)
  18. provs = append(provs, initIPFSLockProviders()...)
  19. provs = append(provs, initStorageLockProviders()...)
  20. return provs
  21. }
  22. func initMetadataLockProviders() []distlock.PathProvider {
  23. return []distlock.PathProvider{
  24. distlock.NewPathProvider(lockprovider.NewMetadataLock(), lockprovider.MetadataLockPathPrefix, "Node"),
  25. distlock.NewPathProvider(lockprovider.NewMetadataLock(), lockprovider.MetadataLockPathPrefix, "Storage"),
  26. distlock.NewPathProvider(lockprovider.NewMetadataLock(), lockprovider.MetadataLockPathPrefix, "User"),
  27. distlock.NewPathProvider(lockprovider.NewMetadataLock(), lockprovider.MetadataLockPathPrefix, "UserBucket"),
  28. distlock.NewPathProvider(lockprovider.NewMetadataLock(), lockprovider.MetadataLockPathPrefix, "UserNode"),
  29. distlock.NewPathProvider(lockprovider.NewMetadataLock(), lockprovider.MetadataLockPathPrefix, "UserStorage"),
  30. distlock.NewPathProvider(lockprovider.NewMetadataLock(), lockprovider.MetadataLockPathPrefix, "Bucket"),
  31. distlock.NewPathProvider(lockprovider.NewMetadataLock(), lockprovider.MetadataLockPathPrefix, "Object"),
  32. distlock.NewPathProvider(lockprovider.NewMetadataLock(), lockprovider.MetadataLockPathPrefix, "Package"),
  33. distlock.NewPathProvider(lockprovider.NewMetadataLock(), lockprovider.MetadataLockPathPrefix, "ObjectRep"),
  34. distlock.NewPathProvider(lockprovider.NewMetadataLock(), lockprovider.MetadataLockPathPrefix, "ObjectBlock"),
  35. distlock.NewPathProvider(lockprovider.NewMetadataLock(), lockprovider.MetadataLockPathPrefix, "Cache"),
  36. distlock.NewPathProvider(lockprovider.NewMetadataLock(), lockprovider.MetadataLockPathPrefix, "StoragePackage"),
  37. distlock.NewPathProvider(lockprovider.NewMetadataLock(), lockprovider.MetadataLockPathPrefix, "Location"),
  38. }
  39. }
  40. func initIPFSLockProviders() []distlock.PathProvider {
  41. return []distlock.PathProvider{
  42. distlock.NewPathProvider(lockprovider.NewIPFSLock(), lockprovider.IPFSLockPathPrefix, trie.WORD_ANY),
  43. }
  44. }
  45. func initStorageLockProviders() []distlock.PathProvider {
  46. return []distlock.PathProvider{
  47. distlock.NewPathProvider(lockprovider.NewStorageLock(), lockprovider.StorageLockPathPrefix, trie.WORD_ANY),
  48. }
  49. }

本项目旨在将云际存储公共基础设施化,使个人及企业可低门槛使用高效的云际存储服务(安装开箱即用云际存储客户端即可,无需关注其他组件的部署),同时支持用户灵活便捷定制云际存储的功能细节。