Sha256: c492b984ccf535cdf71dd2f6827d93eb57cb9d5cd5f91884c5edaca1009819f4

Contents?: true

Size: 1.41 KB

Versions: 18

Compression:

Stored size: 1.41 KB

Contents

module Snapsync
    # Exception thrown when performing sanity checks on the values returned by
    # the policy. Snapsync usually aborts in these cases, given how this is
    # critical
    class InvalidPolicy < RuntimeError; end

    # Default synchronization policy
    #
    # Synchronization policy objects are used by the synchronization passes to
    # decide which snapshots to copy and which to not copy. They have to provide
    # {#filter_snapshots}.
    #
    # This default policy is to copy everything but the snapsync-created
    # synchronization points that are not involving the current target
    class DefaultSyncPolicy
        def self.from_config(config)
            new
        end

        def to_config
            Array.new
        end

        # Returns the snapshots that should be synchronized according to this
        # policy
        #
        # @param [#uuid] target the target object
        # @param [Array<Snapshot>] the snapshot candidates
        # @return [Array<Snapshot>] the snapshots that should be copied
        def filter_snapshots(snapshots)
            # Filter out any snapsync-generated snapshot
            snapshots.find_all { |s| !s.synchronization_point? }
        end

        # Pretty prints this policy
        #
        # This is used by the CLI to give information about a target to the user
        def pretty_print(pp)
            pp.text "default policy"
        end
    end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
snapsync-0.5.0 lib/snapsync/default_sync_policy.rb
snapsync-0.4.2 lib/snapsync/default_sync_policy.rb
snapsync-0.4.1 lib/snapsync/default_sync_policy.rb
snapsync-0.4.0 lib/snapsync/default_sync_policy.rb
snapsync-0.3.8 lib/snapsync/default_sync_policy.rb
snapsync-0.3.7 lib/snapsync/default_sync_policy.rb
snapsync-0.3.6 lib/snapsync/default_sync_policy.rb
snapsync-0.3.5 lib/snapsync/default_sync_policy.rb
snapsync-0.3.4 lib/snapsync/default_sync_policy.rb
snapsync-0.3.3 lib/snapsync/default_sync_policy.rb
snapsync-0.3.2 lib/snapsync/default_sync_policy.rb
snapsync-0.3.1 lib/snapsync/default_sync_policy.rb
snapsync-0.3.0 lib/snapsync/default_sync_policy.rb
snapsync-0.2.1 lib/snapsync/default_sync_policy.rb
snapsync-0.2.0 lib/snapsync/default_sync_policy.rb
snapsync-0.1.8 lib/snapsync/default_sync_policy.rb
snapsync-0.1.7 lib/snapsync/default_sync_policy.rb
snapsync-0.1.6 lib/snapsync/default_sync_policy.rb