RLMSyncManager.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. ////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2016 Realm Inc.
  4. //
  5. // Licensed under the Apache License, Version 2.0 (the "License");
  6. // you may not use this file except in compliance with the License.
  7. // You may obtain a copy of the License at
  8. //
  9. // http://www.apache.org/licenses/LICENSE-2.0
  10. //
  11. // Unless required by applicable law or agreed to in writing, software
  12. // distributed under the License is distributed on an "AS IS" BASIS,
  13. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. // See the License for the specific language governing permissions and
  15. // limitations under the License.
  16. //
  17. ////////////////////////////////////////////////////////////////////////////
  18. #import <Foundation/Foundation.h>
  19. #import "RLMSyncUtil.h"
  20. @class RLMSyncSession;
  21. /// An enum representing different levels of sync-related logging that can be configured.
  22. typedef NS_ENUM(NSUInteger, RLMSyncLogLevel) {
  23. /// Nothing will ever be logged.
  24. RLMSyncLogLevelOff,
  25. /// Only fatal errors will be logged.
  26. RLMSyncLogLevelFatal,
  27. /// Only errors will be logged.
  28. RLMSyncLogLevelError,
  29. /// Warnings and errors will be logged.
  30. RLMSyncLogLevelWarn,
  31. /// Information about sync events will be logged. Fewer events will be logged in order to avoid overhead.
  32. RLMSyncLogLevelInfo,
  33. /// Information about sync events will be logged. More events will be logged than with `RLMSyncLogLevelInfo`.
  34. RLMSyncLogLevelDetail,
  35. /// Log information that can aid in debugging.
  36. ///
  37. /// - warning: Will incur a measurable performance impact.
  38. RLMSyncLogLevelDebug,
  39. /// Log information that can aid in debugging. More events will be logged than with `RLMSyncLogLevelDebug`.
  40. ///
  41. /// - warning: Will incur a measurable performance impact.
  42. RLMSyncLogLevelTrace,
  43. /// Log information that can aid in debugging. More events will be logged than with `RLMSyncLogLevelTrace`.
  44. ///
  45. /// - warning: Will incur a measurable performance impact.
  46. RLMSyncLogLevelAll
  47. };
  48. NS_ASSUME_NONNULL_BEGIN
  49. /// A block type representing a block which can be used to report a sync-related error to the application. If the error
  50. /// pertains to a specific session, that session will also be passed into the block.
  51. typedef void(^RLMSyncErrorReportingBlock)(NSError *, RLMSyncSession * _Nullable);
  52. /**
  53. A singleton manager which serves as a central point for sync-related configuration.
  54. */
  55. @interface RLMSyncManager : NSObject
  56. /**
  57. A block which can optionally be set to report sync-related errors to your application.
  58. Any error reported through this block will be of the `RLMSyncError` type, and marked
  59. with the `RLMSyncErrorDomain` domain.
  60. Errors reported through this mechanism are fatal, with several exceptions. Please consult
  61. `RLMSyncError` for information about the types of errors that can be reported through
  62. the block, and for for suggestions on handling recoverable error codes.
  63. @see `RLMSyncError`
  64. */
  65. @property (nullable, nonatomic, copy) RLMSyncErrorReportingBlock errorHandler;
  66. /**
  67. A reverse-DNS string uniquely identifying this application. In most cases this is automatically set by the SDK, and
  68. does not have to be explicitly configured.
  69. */
  70. @property (nonatomic, copy) NSString *appID;
  71. /**
  72. The logging threshold which newly opened synced Realms will use. Defaults to
  73. `RLMSyncLogLevelInfo`.
  74. Logging strings are output to Apple System Logger.
  75. @warning This property must be set before any synced Realms are opened. Setting it after
  76. opening any synced Realm will do nothing.
  77. */
  78. @property (nonatomic) RLMSyncLogLevel logLevel;
  79. /**
  80. The name of the HTTP header to send authorization data in when making requests to a Realm Object Server which has
  81. been configured to expect a custom authorization header.
  82. */
  83. @property (nullable, nonatomic, copy) NSString *authorizationHeaderName;
  84. /**
  85. Extra HTTP headers to append to every request to a Realm Object Server.
  86. */
  87. @property (nullable, nonatomic, copy) NSDictionary<NSString *, NSString *> *customRequestHeaders;
  88. /// The sole instance of the singleton.
  89. + (instancetype)sharedManager NS_REFINED_FOR_SWIFT;
  90. /// :nodoc:
  91. - (instancetype)init __attribute__((unavailable("RLMSyncManager cannot be created directly")));
  92. /// :nodoc:
  93. + (instancetype)new __attribute__((unavailable("RLMSyncManager cannot be created directly")));
  94. NS_ASSUME_NONNULL_END
  95. @end