ReplicatorConfiguration

public struct ReplicatorConfiguration

Replicator configuration.

  • The local database to replicate with the replication target.

    Declaration

    Swift

    @available(*, deprecated, message: "Use config.collections instead.")
    public var database: Database { get }
  • The replication target to replicate with.

    Declaration

    Swift

    public let target: Endpoint
  • 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
  • A set of Sync Gateway channel names to pull from. Ignored for push replication. If unset, all accessible channels will be pulled. Note: channels that are not accessible to the user will be ignored by Sync Gateway.

    Note

    Note:Channels are not supported in Peer-to-Peer and Database-to-Database replication.

    Declaration

    Swift

    @available(*, deprecated, message: "Use init(target:﹚ and config.addCollection(config:﹚ with a CollectionConfiguration\nobject instead")
    public var channels: [String]? { get set }
  • A set of document IDs to filter by: if given, only documents with these IDs will be pushed and/or pulled.

    Declaration

    Swift

    @available(*, deprecated, message: "Use init(target:﹚ and config.addCollection(config:﹚ with a CollectionConfiguration\nobject instead")
    public var documentIDs: [String]? { get set }
  • Filter closure for validating whether the documents can be pushed to the remote endpoint. Only documents for which the closure returns true are replicated.

    Declaration

    Swift

    @available(*, deprecated, message: "Use init(target:﹚ and config.addCollection(config:﹚ with a CollectionConfiguration\nobject instead")
    public var pushFilter: ReplicationFilter? { get set }
  • Filter closure for validating whether the documents can be pulled from the remote endpoint. Only documents for which the closure returns true are replicated.

    Declaration

    Swift

    @available(*, deprecated, message: "Use init(target:﹚ and config.addCollection(config:﹚ with a CollectionConfiguration\nobject instead")
    public var pullFilter: ReplicationFilter? { get set }
  • The custom conflict resolver object can be set here. If this value is not set, or set to nil, the default conflict resolver will be applied.

    Declaration

    Swift

    @available(*, deprecated, message: "Use init(target:﹚ and config.addCollection(config:﹚ with a CollectionConfiguration\nobject instead")
    public var conflictResolver: ConflictResolverProtocol? { get set }
  • 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.defaultMaxAttemptWaitTime 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
  • The collections used for the replication.

    Declaration

    Swift

    public var collections: [Collection] { get }
  • Initializes a ReplicatorConfiguration’s builder with the given local database and the replication target.

    Declaration

    Swift

    @available(*, deprecated, message: " Use init(target:﹚ instead. ")
    public init(database: Database, target: Endpoint)

    Parameters

    database

    The local database.

    target

    The replication target.

  • Create a ReplicatorConfiguration object with the target’s endpoint. After the ReplicatorConfiguration object is created, use addCollection(_ collection:, config:) or addCollections(_ collections:, config:) to specify and configure the collections used for replicating with the target. If there are no collections specified, the replicator will fail to start with a no collections specified error.

    Declaration

    Swift

    public init(target: Endpoint)
  • Add a collection used for the replication with an optional collection configuration. If the collection has been added before, the previous added and its configuration if specified will be replaced. If a nil configuration is specified, a default empty configuration will be applied.

    Declaration

    Swift

    @discardableResult
    public mutating func addCollection(_ collection: Collection,
                              config: CollectionConfiguration? = nil) -> ReplicatorConfiguration
  • Add multiple collections used for the replication with an optional shared collection configuration. If any of the collections have been added before, the previously added collections and their configuration if specified will be replaced. Adding an empty collection array will be no-ops. if specified will be replaced. If a nil configuration is specified, a default empty configuration will be applied.

    Declaration

    Swift

    @discardableResult
    public mutating func addCollections(_ collections: Array<Collection>,
                                        config: CollectionConfiguration? = nil) -> ReplicatorConfiguration
  • Remove the collection. If the collection doesn’t exist, this operation will be no ops.

    Declaration

    Swift

    @discardableResult
    public mutating func removeCollection(_ collection: Collection) -> ReplicatorConfiguration
  • Get a copy of the collection’s config. If the config needs to be changed for the collection, the collection will need to be re-added with the updated config.

    Declaration

    Swift

    public func collectionConfig(_ collection: Collection) -> CollectionConfiguration?
  • Initializes a ReplicatorConfiguration’s builder with the given configuration object.

    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 seconds] 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 seconds] Max wait time between retry attempts in seconds

    Declaration

    Swift

    static let defaultMaxAttemptWaitTime: 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