ReplicatorConfiguration

public struct ReplicatorConfiguration

Replicator configuration.

  • The replication target to replicate with.

    Declaration

    Swift

    public let target: Endpoint
  • The collection configurations used for the replication. Each configuration specifies a collection and its configuration.

    Declaration

    Swift

    public var collections: [CollectionConfiguration] { get }
  • Replicator type indicating the direction of the replicator.

    Declaration

    Swift

    public var replicatorType: ReplicatorType
  • The continuous flag indicating whether the replicator should stay active indefinitely to replicate changed documents.

    Declaration

    Swift

    public var continuous: Bool { get set }
  • The Authenticator to authenticate with a remote target.

    Declaration

    Swift

    public var authenticator: Authenticator?
  • Specify the replicator to accept any and only self-signed certs. Any non-self-signed certs will be rejected to avoid accidentally using this mode with the non-self-signed certs in production. Default value is ReplicatorConfiguration.defaultSelfSignedCertificateOnly

    Declaration

    Swift

    public var acceptOnlySelfSignedServerCertificate: Bool
  • The remote target’s SSL certificate.

    Note

    The pinned cert will be evaluated against any certs in a cert chain, and the cert chain will be valid only if the cert chain contains the pinned cert.

    Declaration

    Swift

    public var pinnedServerCertificate: SecCertificate?
  • Extra HTTP headers to send in all requests to the remote target.

    Declaration

    Swift

    public var headers: Dictionary<String, String>?
  • Specific network interface for connecting to the remote target.

    Declaration

    Swift

    public var networkInterface: String?
  • The option to remove the restriction that does not allow the replicator to save the parent-domain cookies, the cookies whose domains are the parent domain of the remote host, from the HTTP response. For example, when the option is set to true, the cookies whose domain are “.foo.com” returned by “bar.foo.com” host will be permitted to save.

    This option is disabled by default (See ReplicatorConfiguration.defaultAcceptParentCookies) which means that the parent-domain cookies are not permitted to save by default.

    Declaration

    Swift

    public var acceptParentDomainCookie: Bool
  • Allows the replicator to continue replicating in the background. The default value is NO, which means that the replicator will suspend itself when the replicator detects that the application is running in the background.

    If setting the value to YES, please ensure that the application requests for extending the background task properly.

    Declaration

    Swift

    public var allowReplicatingInBackground: Bool
  • The heartbeat interval in second.

    The interval when the replicator sends the ping message to check whether the other peer is still alive. Default heartbeat is ReplicatorConfiguration.defaultHeartbeat secs.

    Note

    Setting the heartbeat to negative value will result in InvalidArgumentException being thrown. For backward compatibility, setting it to zero will result in default 300 secs internally.

    Declaration

    Swift

    public var heartbeat: TimeInterval { get set }
  • The maximum attempts to perform retry. The retry attempt will be reset when the replicator is able to connect and replicate with the remote server again.

    Default maxAttempts is ReplicatorConfiguration.defaultMaxAttemptsSingleShot times for single shot replicators and ReplicatorConfiguration.defaultMaxAttemptsContinuous times for continuous replicators.

    Settings the value to 1, will perform an initial request and if there is a transient error occurs, will stop without retry.

    Note

    For backward compatibility, setting it to zero will result in default 10 internally.

    Declaration

    Swift

    public var maxAttempts: UInt { get set }
  • Max wait time for the next attempt(retry).

    The exponential backoff for calculating the wait time will be used by default and cannot be customized. Default max attempts is ReplicatorConfiguration.defaultMaxAttemptsWaitTime secs.

    Set the maxAttemptWaitTime to negative value will result in InvalidArgumentException being thrown.

    Note

    For backward compatibility, setting it to zero will result in default secs internally.

    Declaration

    Swift

    public var maxAttemptWaitTime: TimeInterval { get set }
  • To enable/disable the auto purge feature

    The default value is true which means that the document will be automatically purged by the pull replicator when the user loses access to the document from both removed and revoked scenarios.

    When the property is set to false, this behavior is disabled and an access removed event will be sent to any document listeners that are active on the replicator. For performance reasons, the document listeners must be added before the replicator is started or they will not receive the events.

    Note

    Auto purge will not be performed when documentIDs filter is specified.

    Declaration

    Swift

    public var enableAutoPurge: Bool
  • Initializes a ReplicatorConfiguration with the specified collection configurations and target’s endpoint.

    Each CollectionConfiguration in the collections array must be initialized using init(collections:).

    Declaration

    Swift

    public init(collections: [CollectionConfiguration], target: Endpoint)

    Parameters

    collections

    An array of collection configurations to replicate

    target

    The target endpoint

  • Initializes a ReplicatorConfiguration’s builder with the given configuration.

    Declaration

    Swift

    public init(config: ReplicatorConfiguration)

    Parameters

    config

    The configuration object.

  • [ReplicatorType.pushAndPull] Perform bidirectional replication

    Declaration

    Swift

    static let defaultType: ReplicatorType
  • [false] One-shot replication is used, and will stop once all initial changes are processed

    Declaration

    Swift

    static let defaultContinuous: Bool
  • [false] Replication stops when an application enters background mode

    Declaration

    Swift

    static let defaultAllowReplicatingInBackground: Bool
  • [300] A heartbeat messages is sent every 300 seconds to keep the connection alive

    Declaration

    Swift

    static let defaultHeartbeat: TimeInterval
  • [10] When replicator is not continuous, after 10 failed attempts give up on the replication

    Declaration

    Swift

    static let defaultMaxAttemptsSingleShot: UInt
  • [UInt.max] When replicator is continuous, never give up unless explicitly stopped

    Declaration

    Swift

    static let defaultMaxAttemptsContinuous: UInt
  • [300] Max wait time between retry attempts in seconds

    Declaration

    Swift

    static let defaultMaxAttemptsWaitTime: TimeInterval
  • [true] Purge documents when a user loses access

    Declaration

    Swift

    static let defaultEnableAutoPurge: Bool
  • [false] Whether or not a replicator only accepts self-signed certificates from the remote

    Declaration

    Swift

    static let defaultSelfSignedCertificateOnly: Bool
  • [false] Whether or not a replicator only accepts cookies for the sender’s parent domains

    Declaration

    Swift

    static let defaultAcceptParentCookies: Bool