ClientResetMode

@frozen
public enum ClientResetMode

클라이언트 재설정 이벤트에서 파일 복구 동작을 결정하는 데 사용되는 열거형입니다. 기본값은 .recoverUnsyncedChanges 입니다.

~를 참조하세요.

RLMClientResetMode
  • 동기화되지 않은 모든 로컬 변경 사항은 자동으로 삭제되고 로컬 상태는 서버의 가장 최근 상태로 자동 되돌아갑니다. 그런 다음 동기화되지 않은 변경 사항은 클라이언트 재설정 후 콜백 차단에서 복구할 수 있습니다.

    .discardLocal 가 활성화되었지만 클라이언트 재설정 작업을 완료할 수 없는 경우 클라이언트 재설정 프로세스는 수동 모드로 되돌아갑니다. 예: 파괴적인 스키마 변경 중에 이 모드는 실패하고 수동 클라이언트 재설정 처리기를 호출합니다.

    다음의 사항도 참조하세요.

    seeAlso RLMClientResetBeforeBlock 사용 예시

    user.configuration(partitionValue: "myPartition", clientResetMode: .discardUnsyncedChanges({ before in
    var recoveryConfig = Realm.Configuration()
    recoveryConfig.fileURL = myRecoveryPath
    do {
       before.writeCopy(configuration: recoveryConfig)
       // The copied realm could be used later for recovery, debugging, reporting, etc.
    } catch {
       // handle error
    }
    }, nil))
    

    다음의 사항도 참조하세요.

    다음의 사항도 참조하세요. RLMClientResetAfterBlock

    사용 예시

    user.configuration(partitionValue: "myPartition", clientResetMode: .discardUnsyncedChanges( nil, { before, after in
    // This block could be used to add custom recovery logic, back-up a realm file, send reporting, etc.
    for object in before.objects(myClass.self) {
        let res = after.objects(myClass.self)
        if (res.filter("primaryKey == %@", object.primaryKey).first != nil) {
            // ...custom recovery logic...
        } else {
            // ...custom recovery logic...
        }
    }
    }))
    

    선언

    Swift

    @preconcurrency
    case discardLocal(beforeReset: (@Sendable (_ before: Realm) -> Void)? = nil,
                      afterReset: (@Sendable (_ before: Realm, _ after: Realm) -> Void)? = nil)

    매개변수

    afterReset

    클라이언트 재설정 재설정 프로세스가 발생한 후에 호출되는 함수입니다.

    before

    클라이언트 재설정 전 로컬 Realm 상태의 동결 복사본입니다.

    after

    클라이언트 재설정 후 영역의 라이브 인스턴스입니다.

  • 동기화되지 않은 모든 로컬 변경 사항은 자동으로 삭제되고 로컬 상태는 서버의 가장 최근 상태로 자동 되돌아갑니다. 그런 다음 동기화되지 않은 변경 사항은 클라이언트 재설정 후 콜백 차단에서 복구할 수 있습니다.

    .discardUnsyncedChanges 가 활성화되었지만 클라이언트 재설정 작업을 완료할 수 없는 경우 클라이언트 재설정 프로세스는 수동 모드로 되돌아갑니다. 예: 파괴적인 스키마 변경 중에 이 모드는 실패하고 수동 클라이언트 재설정 처리기를 호출합니다.

    다음의 사항도 참조하세요.

    seeAlso RLMClientResetBeforeBlock 사용 예시

    user.configuration(partitionValue: "myPartition", clientResetMode: .discardUnsyncedChanges({ before in
    var recoveryConfig = Realm.Configuration()
    recoveryConfig.fileURL = myRecoveryPath
    do {
       before.writeCopy(configuration: recoveryConfig)
       // The copied realm could be used later for recovery, debugging, reporting, etc.
    } catch {
       // handle error
    }
    }, nil))
    

    다음의 사항도 참조하세요.

    다음의 사항도 참조하세요. RLMClientResetAfterBlock

    사용 예시

    user.configuration(partitionValue: "myPartition", clientResetMode: .discardUnsyncedChanges( nil, { before, after in
    // This block could be used to add custom recovery logic, back-up a realm file, send reporting, etc.
    for object in before.objects(myClass.self) {
        let res = after.objects(myClass.self)
        if (res.filter("primaryKey == %@", object.primaryKey).first != nil) {
            // ...custom recovery logic...
        } else {
            // ...custom recovery logic...
        }
    }
    }))
    

    선언

    Swift

    @preconcurrency
    case discardUnsyncedChanges(beforeReset: (@Sendable (_ before: Realm) -> Void)? = nil,
                                afterReset: (@Sendable (_ before: Realm, _ after: Realm) -> Void)? = nil)

    매개변수

    afterReset

    클라이언트 재설정 재설정 프로세스가 발생한 후에 호출되는 함수입니다.

    before

    클라이언트 재설정 전 로컬 Realm 상태의 동결 복사본입니다.

    after

    클라이언트 재설정 후 영역의 라이브 인스턴스입니다.

  • 클라이언트 장치는 클라이언트 재설정 후 서버의 최신 상태를 반영하는 영역 영역을 다운로드합니다. 클라이언트 재설정이 발생하기 전의 로컬 변경 사항과 서버 버전을 통합하기 위해 복구 프로세스가 로컬에서 실행됩니다.

    변경 사항은 다음 규칙과 통합됩니다:

    1. 로컬에서 생성되었지만 클라이언트 재설정 전에 동기화되지 않은 객체는 통합됩니다.
    2. 객체가 서버에서 삭제되었지만 클라이언트에서 수정된 경우 삭제가 우선되고 업데이트가 삭제됩니다.
    3. 객체가 클라이언트에서는 삭제되었지만 서버에서는 삭제되지 않은 경우 클라이언트 삭제 지침이 적용됩니다.
    4. 동일한 필드에 대한 업데이트가 충돌하는 경우 클라이언트 업데이트가 적용됩니다.

    복구 통합이 실패하면 클라이언트 재설정 프로세스는 ClientResetMode.manual 으로 돌아갑니다. 서버에서 '클라이언트 복구' 설정이 활성화되어 있지 않으면 복구 통합이 실패합니다. 호환되지 않는 스키마 변경이 발생하는 경우에도 통합이 실패할 수 있습니다.

    다음의 사항도 참조하세요.

    seeAlso RLMClientResetBeforeBlock 사용 예시

    user.configuration(partitionValue: "myPartition", clientResetMode: .discardUnsyncedChanges({ before in
    var recoveryConfig = Realm.Configuration()
    recoveryConfig.fileURL = myRecoveryPath
    do {
       before.writeCopy(configuration: recoveryConfig)
       // The copied realm could be used later for recovery, debugging, reporting, etc.
    } catch {
       // handle error
    }
    }, nil))
    

    다음의 사항도 참조하세요.

    다음의 사항도 참조하세요. RLMClientResetAfterBlock

    사용 예시

    user.configuration(partitionValue: "myPartition", clientResetMode: .discardUnsyncedChanges( nil, { before, after in
    // This block could be used to add custom recovery logic, back-up a realm file, send reporting, etc.
    for object in before.objects(myClass.self) {
        let res = after.objects(myClass.self)
        if (res.filter("primaryKey == %@", object.primaryKey).first != nil) {
            // ...custom recovery logic...
        } else {
            // ...custom recovery logic...
        }
    }
    }))
    

    선언

    Swift

    @preconcurrency
    case recoverUnsyncedChanges(beforeReset: (@Sendable (_ before: Realm) -> Void)? = nil,
                                afterReset: (@Sendable (_ before: Realm, _ after: Realm) -> Void)? = nil)

    매개변수

    afterReset

    클라이언트 재설정 재설정 프로세스가 발생한 후에 호출되는 함수입니다.

    before

    클라이언트 재설정 전 로컬 Realm 상태의 동결 복사본입니다.

    after

    클라이언트 재설정 후 영역의 라이브 인스턴스입니다.

  • 클라이언트 장치는 최신 버전의 서버를 반영하는 객체가 있는 영역을 다운로드합니다. 클라이언트 재설정이 발생하기 전의 로컬 변경 사항과 서버 버전을 통합하기 위해 복구 프로세스가 로컬에서 실행됩니다.

    변경 사항은 다음 규칙과 통합됩니다:

    1. 로컬에서 생성되었지만 클라이언트 재설정 전에 동기화되지 않은 객체는 통합됩니다.
    2. 객체가 서버에서 삭제되었지만 클라이언트에서 수정된 경우 삭제가 우선되고 업데이트가 삭제됩니다.
    3. 객체가 클라이언트에서는 삭제되었지만 서버에서는 삭제되지 않은 경우 클라이언트 삭제 지침이 적용됩니다.
    4. 동일한 필드에 대한 업데이트가 충돌하는 경우 클라이언트 업데이트가 적용됩니다.

    복구 통합이 실패하면 클라이언트 재설정 프로세스는 ClientResetMode.discardUnsyncedChanges 으로 돌아갑니다. 서버에서 '클라이언트 복구' 설정이 활성화되어 있지 않으면 복구 통합이 실패합니다. 호환되지 않는 스키마 변경이 발생하는 경우에도 통합이 실패할 수 있습니다.

    다음의 사항도 참조하세요.

    seeAlso RLMClientResetBeforeBlock 사용 예시

    user.configuration(partitionValue: "myPartition", clientResetMode: .discardUnsyncedChanges({ before in
    var recoveryConfig = Realm.Configuration()
    recoveryConfig.fileURL = myRecoveryPath
    do {
       before.writeCopy(configuration: recoveryConfig)
       // The copied realm could be used later for recovery, debugging, reporting, etc.
    } catch {
       // handle error
    }
    }, nil))
    

    다음의 사항도 참조하세요.

    다음의 사항도 참조하세요. RLMClientResetAfterBlock

    사용 예시

    user.configuration(partitionValue: "myPartition", clientResetMode: .discardUnsyncedChanges( nil, { before, after in
    // This block could be used to add custom recovery logic, back-up a realm file, send reporting, etc.
    for object in before.objects(myClass.self) {
        let res = after.objects(myClass.self)
        if (res.filter("primaryKey == %@", object.primaryKey).first != nil) {
            // ...custom recovery logic...
        } else {
            // ...custom recovery logic...
        }
    }
    }))
    

    선언

    Swift

    @preconcurrency
    case recoverOrDiscardUnsyncedChanges(beforeReset: (@Sendable (_ before: Realm) -> Void)? = nil,
                                         afterReset: (@Sendable (_ before: Realm, _ after: Realm) -> Void)? = nil)

    매개변수

    afterReset

    클라이언트 재설정 재설정 프로세스가 발생한 후에 호출되는 함수입니다.

    before

    클라이언트 재설정 전 로컬 Realm 상태의 동결 복사본입니다.

    after

    클라이언트 재설정 후 영역의 라이브 인스턴스입니다.

  • 다음의 사항도 참조하세요.

    RLMClientResetModeManual

    수동 클라이언트 재설정 모드 핸들러는 다음 두 위치에서 설정할 수 있습니다.

    1. ClientResetMode 열거형의 ErrorReportingBlock 인수로 사용됩니다(`ErrorReportingBlock? = nil`).
    2. SyncManager.errorHandler 속성의 ErrorReportingBlock으로 사용됩니다.
    3. 다음의 사항도 참조하세요.

      RLMSyncManager.errorHandler

    RLMSyncErrorClientResetError 동안 실행된 차단은 다음 규칙에 따라 결정됩니다.

    • 오류 보고 차단이 ClientResetModeSyncManager 에 설정되어 있으면 ClientResetMode 차단이 실행됩니다.
    • 오류 보고 차단이 ClientResetMode 또는 SyncManager 중 하나에 설정되고 둘 다 설정되지 않은 경우 단일 차단이 실행됩니다.
    • 어느 위치에도 차단이 설정되지 않으면 클라이언트 재설정이 처리되지 않습니다. 애플리케이션을 다시 시작해야 할 수 있으며 동기화되지 않은 로컬 변경 사항이 손실될 수 있습니다.

    참고

    SyncManager.errorHandler 는 여전히 RLMSyncErrorClientResetError 이외 의 모든 RLMSyncError아래에서 호출됩니다.

    다음의 사항도 참조하세요.

    전체 목록은 RLMSyncError 을(를) 참조하세요.

    선언

    Swift

    @preconcurrency
    case manual(errorHandler: ErrorReportingBlock? = nil)