Milvus.ts 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import { WS_EVENTS, WS_EVENTS_TYPE } from '../consts/Http';
  2. import BaseModel from './BaseModel';
  3. export class MilvusHttp extends BaseModel {
  4. static CONNECT_URL = '/milvus/connect';
  5. static DISCONNECT_URL = '/milvus/disconnect';
  6. static CHECK_URL = '/milvus/check';
  7. static FLUSH_URL = '/milvus/flush';
  8. static METRICS_URL = '/milvus/metrics';
  9. static VERSION_URL = '/milvus/version';
  10. static TIGGER_CRON_URL = '/crons';
  11. constructor(props: {}) {
  12. super(props);
  13. Object.assign(this, props);
  14. }
  15. static connect(data: {
  16. address: string;
  17. username?: string;
  18. password?: string;
  19. }) {
  20. return super.create({ path: this.CONNECT_URL, data });
  21. }
  22. static closeConnection() {
  23. return super.create({ path: this.DISCONNECT_URL });
  24. }
  25. static getVersion() {
  26. return super.search({ path: this.VERSION_URL, params: {} });
  27. }
  28. static check(address: string) {
  29. return super.search({ path: this.CHECK_URL, params: { address } });
  30. }
  31. static flush(collectionName: string) {
  32. return super.update({
  33. path: this.FLUSH_URL,
  34. data: {
  35. collection_names: [collectionName],
  36. },
  37. });
  38. }
  39. static getMetrics() {
  40. return super.search({
  41. path: this.METRICS_URL,
  42. params: {},
  43. });
  44. }
  45. static triggerCron(data: { name: WS_EVENTS; type: WS_EVENTS_TYPE }) {
  46. return super.update({
  47. path: this.TIGGER_CRON_URL,
  48. data,
  49. });
  50. }
  51. }