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.

node_connectivity.go 1.1 kB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package db
  2. /*
  3. import (
  4. "github.com/jmoiron/sqlx"
  5. cdssdk "gitlink.org.cn/cloudream/common/sdks/storage"
  6. "gitlink.org.cn/cloudream/storage/common/pkgs/db/model"
  7. )
  8. type NodeConnectivityDB struct {
  9. *DB
  10. }
  11. func (db *DB) NodeConnectivity() *NodeConnectivityDB {
  12. return &NodeConnectivityDB{DB: db}
  13. }
  14. func (db *NodeConnectivityDB) BatchGetByFromNode(ctx SQLContext, fromNodeIDs []cdssdk.NodeID) ([]model.NodeConnectivity, error) {
  15. if len(fromNodeIDs) == 0 {
  16. return nil, nil
  17. }
  18. var ret []model.NodeConnectivity
  19. sql, args, err := sqlx.In("select * from NodeConnectivity where FromNodeID in (?)", fromNodeIDs)
  20. if err != nil {
  21. return nil, err
  22. }
  23. return ret, sqlx.Select(ctx, &ret, sql, args...)
  24. }
  25. func (db *NodeConnectivityDB) BatchUpdateOrCreate(ctx SQLContext, cons []model.NodeConnectivity) error {
  26. if len(cons) == 0 {
  27. return nil
  28. }
  29. return BatchNamedExec(ctx,
  30. "insert into NodeConnectivity(FromNodeID, ToNodeID, Delay, TestTime) values(:FromNodeID, :ToNodeID, :Delay, :TestTime) as new"+
  31. " on duplicate key update Delay = new.Delay, TestTime = new.TestTime", 4, cons, nil)
  32. }
  33. */

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