load method

Future<McpBundle> load(
  1. BundleRef ref
)

FR-BUNDLE-001

Implementation

Future<McpBundle> load(BundleRef ref) async {
  final stopwatch = Stopwatch()..start();
  _logger.debug('bundle.load.start', {'refType': ref.runtimeType.toString()});
  try {
    final bundle = await _loadInner(ref);
    stopwatch.stop();
    _metrics.recordLatency(
      'bundle_load',
      stopwatch.elapsed,
      tags: {'result': 'success', 'type': bundle.manifest.type.name},
    );
    _logger.info('bundle.load.success', {
      'bundleId': bundle.manifest.id,
      'version': bundle.manifest.version,
      'type': bundle.manifest.type.name,
      'latencyMs': stopwatch.elapsedMilliseconds,
    });
    return bundle;
  } catch (e, st) {
    stopwatch.stop();
    _metrics.recordLatency(
      'bundle_load',
      stopwatch.elapsed,
      tags: {'result': 'fail'},
    );
    _logger.logError('bundle.load.fail', e, st);
    rethrow;
  }
}