Milvus.ts 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 CHECK_URL = '/milvus/check';
  6. static FLUSH_URL = '/milvus/flush';
  7. static METRICS_URL = '/milvus/metrics';
  8. static TIGGER_CRON_URL = '/crons';
  9. constructor(props: {}) {
  10. super(props);
  11. Object.assign(this, props);
  12. }
  13. static connect(address: string) {
  14. return super.create({ path: this.CONNECT_URL, data: { address } });
  15. }
  16. static check(address: string) {
  17. return super.search({ path: this.CHECK_URL, params: { address } });
  18. }
  19. static flush(collectionName: string) {
  20. return super.update({
  21. path: this.FLUSH_URL,
  22. data: {
  23. collection_names: [collectionName],
  24. },
  25. });
  26. }
  27. static getMetrics() {
  28. return super.search({
  29. path: this.METRICS_URL,
  30. params: {},
  31. });
  32. }
  33. static triggerCron(data: { name: WS_EVENTS; type: WS_EVENTS_TYPE }) {
  34. return super.update({
  35. path: this.TIGGER_CRON_URL,
  36. data,
  37. });
  38. }
  39. }