restore method

  1. @override
void restore({
  1. required int transactionId,
  2. required Object image,
  3. required bool quiescent,
})
override

Restores this participant from a validated image.

Implementation

@override
void restore({
  required int transactionId,
  required Object image,
  required bool quiescent,
}) {
  final compositeImage = image as CompositeStateSnapshotImage;
  if (compositeImage.records.length != children.length) {
    throw ArgumentError('Composite snapshot child count does not match.');
  }
  final recordsByPath = {
    for (final record in compositeImage.records) record.path: record,
  };
  for (var index = 0; index < children.length; index++) {
    final child = children[index];
    final record = recordsByPath[child.path];
    if (record == null ||
        record.schemaKind != child.schemaKind ||
        record.schemaVersion != child.schemaVersion ||
        record.configurationIdentity != child.configurationIdentity) {
      throw ArgumentError(
          'Composite snapshot manifest does not match ${child.path}.');
    }
    child.capabilities.validateRequest(
      StateTransactionOperation.restore,
      quiescent: quiescent,
    );
    child.restore(
      transactionId: transactionId + index,
      image: record.image,
      quiescent: quiescent,
    );
  }
}