@dxos/client-services 0.1.54 → 0.1.55-main.0618d91

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2504,7 +2504,7 @@ var DataSpace = class DataSpace2 {
2504
2504
  await this.initializeDataPipeline();
2505
2505
  } catch (err) {
2506
2506
  if (err instanceof CancelledError) {
2507
- log9("Data pipeline initialization cancelled", err, {
2507
+ log9("data pipeline initialization cancelled", err, {
2508
2508
  F: __dxlog_file9,
2509
2509
  L: 193,
2510
2510
  S: this,
@@ -2538,7 +2538,7 @@ var DataSpace = class DataSpace2 {
2538
2538
  });
2539
2539
  this.metrics.controlPipelineReady = new Date();
2540
2540
  await this._createWritableFeeds();
2541
- log9("Writable feeds created", void 0, {
2541
+ log9("writable feeds created", void 0, {
2542
2542
  F: __dxlog_file9,
2543
2543
  L: 221,
2544
2544
  S: this,
@@ -2650,7 +2650,7 @@ var DataSpace = class DataSpace2 {
2650
2650
  }
2651
2651
  async activate() {
2652
2652
  if (this._state !== SpaceState.INACTIVE) {
2653
- throw new SystemError("Invalid operation");
2653
+ return;
2654
2654
  }
2655
2655
  await this._metadataStore.setSpaceState(this.key, SpaceState.ACTIVE);
2656
2656
  await this._open();
@@ -2658,7 +2658,7 @@ var DataSpace = class DataSpace2 {
2658
2658
  }
2659
2659
  async deactivate() {
2660
2660
  if (this._state === SpaceState.INACTIVE) {
2661
- throw new SystemError("Invalid operation");
2661
+ return;
2662
2662
  }
2663
2663
  await this._metadataStore.setSpaceState(this.key, SpaceState.INACTIVE);
2664
2664
  await this._close();
@@ -3738,7 +3738,7 @@ import { Event as Event7 } from "@dxos/async";
3738
3738
  import { Stream as Stream12 } from "@dxos/codec-protobuf";
3739
3739
  import { getContextFromEntry, log as log14 } from "@dxos/log";
3740
3740
  import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
3741
- import { jsonify } from "@dxos/util";
3741
+ import { jsonify, numericalValues, tracer } from "@dxos/util";
3742
3742
  var LoggingServiceImpl = class {
3743
3743
  constructor() {
3744
3744
  this._logs = new Event7();
@@ -3753,6 +3753,46 @@ var LoggingServiceImpl = class {
3753
3753
  const index = log14.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
3754
3754
  log14.runtimeConfig.processors.splice(index, 1);
3755
3755
  }
3756
+ async controlMetrics({ reset, record }) {
3757
+ if (reset) {
3758
+ tracer.clear();
3759
+ }
3760
+ if (record === true) {
3761
+ tracer.start();
3762
+ } else if (record === false) {
3763
+ tracer.stop();
3764
+ }
3765
+ return {
3766
+ recording: tracer.recording
3767
+ };
3768
+ }
3769
+ queryMetrics({ interval }) {
3770
+ const createNumericalValues = (key) => {
3771
+ var _a;
3772
+ const consume = (_a = tracer.get(key)) != null ? _a : [];
3773
+ return {
3774
+ key,
3775
+ stats: numericalValues(consume, "duration")
3776
+ };
3777
+ };
3778
+ return new Stream12(({ next }) => {
3779
+ const update = () => {
3780
+ const metrics = {
3781
+ timestamp: new Date(),
3782
+ values: [
3783
+ createNumericalValues("dxos.echo.pipeline.control"),
3784
+ createNumericalValues("dxos.echo.pipeline.data")
3785
+ ]
3786
+ };
3787
+ next(metrics);
3788
+ };
3789
+ update();
3790
+ const i = setInterval(update, interval);
3791
+ return () => {
3792
+ clearInterval(i);
3793
+ };
3794
+ });
3795
+ }
3756
3796
  queryLogs(request) {
3757
3797
  return new Stream12(({ ctx, next }) => {
3758
3798
  const handler = (entry2) => {
@@ -3858,7 +3898,8 @@ var SystemServiceImpl = class {
3858
3898
  async updateStatus({ status }) {
3859
3899
  await this._onUpdateStatus(status);
3860
3900
  }
3861
- queryStatus() {
3901
+ // TODO(burdon): Standardize interval option in stream request?
3902
+ queryStatus({ interval = 3e3 } = {}) {
3862
3903
  return new Stream14(({ next }) => {
3863
3904
  const update = () => {
3864
3905
  next({
@@ -3867,9 +3908,9 @@ var SystemServiceImpl = class {
3867
3908
  };
3868
3909
  update();
3869
3910
  const unsubscribe = this._statusUpdate.on(() => update());
3870
- const interval = setInterval(update, 3e3);
3911
+ const i = setInterval(update, interval);
3871
3912
  return () => {
3872
- clearInterval(interval);
3913
+ clearInterval(i);
3873
3914
  unsubscribe();
3874
3915
  };
3875
3916
  });
@@ -4166,4 +4207,4 @@ export {
4166
4207
  createDefaultModelFactory,
4167
4208
  ClientServicesHost
4168
4209
  };
4169
- //# sourceMappingURL=chunk-F4BHRFH4.mjs.map
4210
+ //# sourceMappingURL=chunk-CSJSC47N.mjs.map