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 994 B

1234567891011121314151617181920212223242526272829303132
  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. var ret []model.NodeConnectivity
  15. sql, args, err := sqlx.In("select * from NodeConnectivity where NodeID in (?)", nodeIDs)
  16. if err != nil {
  17. return nil, err
  18. }
  19. return ret, sqlx.Select(ctx, &ret, sql, args...)
  20. }
  21. func (db *NodeConnectivityDB) BatchUpdateOrCreate(ctx SQLContext, cons []model.NodeConnectivity) error {
  22. return BatchNamedExec(ctx,
  23. "insert into NodeConnectivity(FromNodeID, ToNodeID, Delay, TestTime) values(:FromNodeID, :ToNodeID, :Delay, :TestTime) as new"+
  24. " on duplicate key update Delay = new.Delay, TestTime = new.TestTime", 4, cons, nil)
  25. }

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