Module: Aspera::Plugins::Xfer::SyncActions::ClassMethods

Defined in:
lib/aspera/plugins/xfer/sync_actions.rb

Overview

Class-level DSL methods added to the plugin class that includes SyncActions.

Instance Method Summary collapse

Instance Method Details

#sync_admin_commands(parent) ⇒ Object

DSL class method: declare the sync admin node and its 7 leaf commands.

Parameters:

  • parent (Symbol, Array<Symbol>) —

    path relative to current scope, e.g. :admin



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/aspera/plugins/xfer/sync_actions.rb', line 53

def sync_admin_commands(parent)
  commands_under(parent, description: 'Manage sync database (admin operations)') do
    command(
      :find, description: 'Find sync database files', arguments: [{name: :path, complete: :folder, access: :read}],
      action: lambda do |path:, **|
        dbs = readable_db_files(path)
        Cli::Result::ObjectList.new(dbs.keys.map { |n| {name: n, path: dbs[n]} })
      end
    )
    command(
      :status, description: 'Show sync session status', arguments: ADMIN_PATH_AND_INFO_ARGS,
      action: ->(path:, sync_info: {}, **) { Cli::Result::SingleObject.new(Sync::Operations.admin_status(admin_sync_info(path: path, sync_info: sync_info))) }
    )
    command(
      :meta, description: 'Show sync session metadata', arguments: ADMIN_PATH_AND_INFO_ARGS,
      action: lambda do |path:, sync_info: {}, **|
        require_relative '../../sync/database'
        Cli::Result::SingleObject.new(db_from_args(path: path, sync_info: sync_info).meta(options.get_option(:sql)))
      end
    )
    command(
      :counters, description: 'Show sync counters', arguments: ADMIN_PATH_AND_INFO_ARGS,
      action: lambda do |path:, sync_info: {}, **|
        require_relative '../../sync/database'
        Cli::Result::SingleObject.new(db_from_args(path: path, sync_info: sync_info).counters(options.get_option(:sql)))
      end
    )
    command(:file_info, description: 'Show per-file sync state', arguments: ADMIN_PATH_AND_INFO_ARGS, action: :action_sync_admin_file_info)
    command(
      :overview, description: 'Show sync database overview', arguments: ADMIN_PATH_AND_INFO_ARGS,
      action: lambda do |path:, sync_info: {}, **|
        require_relative '../../sync/database'
        Cli::Result::ObjectList.new(db_from_args(path: path, sync_info: sync_info).overview, fields: %w[table name type])
      end
    )
    command(
      :query, description: 'Execute a raw SQL query', arguments: ADMIN_PATH_AND_INFO_ARGS,
      action: lambda do |path:, sync_info: {}, **|
        require_relative '../../sync/database'
        Cli::Result.auto(db_from_args(path: path, sync_info: sync_info).execute(options.get_option(:sql, mandatory: true)))
      end
    )
  end
end

#sync_logs_command(name) ⇒ Object

DSL class method: declare the sync logs command (analysis of async log files).

Parameters:

  • name (Symbol, Array<Symbol>) —

    command path relative to current scope, e.g. :logs



100
101
102
# File 'lib/aspera/plugins/xfer/sync_actions.rb', line 100

def sync_logs_command(name)
  command(name, description: 'Analyze async log files: conflicts, errors, and session lifecycle', arguments: SYNC_LOG_ARGS, action: :action_sync_logs)
end