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.

main.go 2.3 kB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. package main
  2. import (
  3. "fmt"
  4. "os"
  5. _ "google.golang.org/grpc/balancer/grpclb"
  6. "gitlink.org.cn/cloudream/client/internal/cmdline"
  7. "gitlink.org.cn/cloudream/client/internal/config"
  8. "gitlink.org.cn/cloudream/client/internal/services"
  9. log "gitlink.org.cn/cloudream/common/pkg/logger"
  10. "gitlink.org.cn/cloudream/common/utils/ipfs"
  11. coorcli "gitlink.org.cn/cloudream/rabbitmq/client/coordinator"
  12. sccli "gitlink.org.cn/cloudream/rabbitmq/client/scanner"
  13. )
  14. func main() {
  15. err := config.Init()
  16. if err != nil {
  17. fmt.Printf("init config failed, err: %s", err.Error())
  18. os.Exit(1)
  19. }
  20. err = log.Init(&config.Cfg().Logger)
  21. if err != nil {
  22. fmt.Printf("init logger failed, err: %s", err.Error())
  23. os.Exit(1)
  24. }
  25. coorClient, err := coorcli.NewClient(&config.Cfg().RabbitMQ)
  26. if err != nil {
  27. log.Warnf("new coordinator client failed, err: %s", err.Error())
  28. os.Exit(1)
  29. }
  30. scanner, err := sccli.NewClient(&config.Cfg().RabbitMQ)
  31. if err != nil {
  32. log.Warnf("new scanner client failed, err: %s", err.Error())
  33. os.Exit(1)
  34. }
  35. var ipfsCli *ipfs.IPFS
  36. if config.Cfg().IPFS != nil {
  37. log.Infof("IPFS config is not empty, so create a ipfs client")
  38. ipfsCli, err = ipfs.NewIPFS(config.Cfg().IPFS)
  39. if err != nil {
  40. log.Warnf("new ipfs client failed, err: %s", err.Error())
  41. os.Exit(1)
  42. }
  43. }
  44. svc, err := services.NewService(coorClient, ipfsCli, scanner)
  45. if err != nil {
  46. log.Warnf("new services failed, err: %s", err.Error())
  47. os.Exit(1)
  48. }
  49. cmds, err := cmdline.NewCommandline(svc)
  50. if err != nil {
  51. log.Warnf("new command line failed, err: %s", err.Error())
  52. os.Exit(1)
  53. }
  54. cmds.DispatchCommand(os.Args[1:])
  55. /*
  56. TO DO future:
  57. 1. ls命令,显示用户指定桶下的所有对象,及相关的元数据
  58. 2. rm命令,用户指定bucket和object名,执行删除操作
  59. 3. update命令,用户发起对象更新命令,查询元数据,判断对象的冗余方式,删除旧对象(unpin所有的副本或编码块),写入新对象
  60. 4. ipfsStat命令,查看本地有无ipfsdaemon,ipfs目录的使用率
  61. 5. ipfsFlush命令,unpin本地ipfs目录中的所有cid(block)
  62. 6. 改为交互式client,输入用户名及秘钥后进入交互界面
  63. 7. 支持纯缓存类型的IPFS节点,数据一律存在后端存储服务中
  64. */
  65. }

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