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

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

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