Sha256: d20a581aa9a45c56e279ef54f2408dc0f67f3a5bc28e8f6545a314495d1e43a8

Contents?: true

Size: 1.56 KB

Versions: 31

Compression:

Stored size: 1.56 KB

Contents

module Flydata
  module Helper
    class ActionOwnership
      attr_accessor :action_name

      # Resource change flag
      # true -> action must be taken exclusively
      attr_accessor :resource_change

      # action_class has a actual logic
      attr_accessor :action_class

      # Owner should be nil(channel) or worker
      attr_accessor :owner

      # last processeed time should be updated when worker return
      # action ownership to channel
      attr_accessor :last_processed_time

      attr_accessor :retry_count

      def initialize(action_name, resource_change = false, action_class = nil)
        @action_name = action_name
        @resource_change = resource_change
        @action_class = action_class
        @owner = nil
        @last_processed_time = -1
        @retry_count = 0
      end

      def processing?
        !@owner.nil?
      end

      def reset_retry_count
        @retry_count = 0
      end

      def increment_retry_count
        @retry_count += 1
      end

      def self.action_ownership_map
        [
          self.new(:check_remote_actions, false, Action::CheckRemoteActions),
          self.new(:check_abnormal_shutdown, false, Action::CheckAbnormalShutdown),
          self.new(:send_logs, false, Action::SendLogs),
          self.new(:stop_agent, true, Action::StopAgent),
          self.new(:restart_agent, true, Action::RestartAgent),
          self.new(:update_helper_config, false, Action::UpdateHelperConfig),
        ].inject({}) do |h, action|
          h[action.action_name] = action
          h
        end
      end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
flydata-0.7.15 lib/flydata/helper/action_ownership.rb
flydata-0.7.14 lib/flydata/helper/action_ownership.rb
flydata-0.7.13 lib/flydata/helper/action_ownership.rb
flydata-0.7.12 lib/flydata/helper/action_ownership.rb
flydata-0.7.11 lib/flydata/helper/action_ownership.rb
flydata-0.7.10 lib/flydata/helper/action_ownership.rb
flydata-0.7.9 lib/flydata/helper/action_ownership.rb
flydata-0.7.8 lib/flydata/helper/action_ownership.rb
flydata-0.7.7 lib/flydata/helper/action_ownership.rb
flydata-0.7.6 lib/flydata/helper/action_ownership.rb
flydata-0.7.5 lib/flydata/helper/action_ownership.rb
flydata-0.7.4 lib/flydata/helper/action_ownership.rb
flydata-0.7.2.1 lib/flydata/helper/action_ownership.rb
flydata-0.7.2 lib/flydata/helper/action_ownership.rb
flydata-0.7.1 lib/flydata/helper/action_ownership.rb
flydata-0.7.0 lib/flydata/helper/action_ownership.rb
flydata-0.6.14 lib/flydata/helper/action_ownership.rb
flydata-0.6.13 lib/flydata/helper/action_ownership.rb
flydata-0.6.12 lib/flydata/helper/action_ownership.rb
flydata-0.6.11 lib/flydata/helper/action_ownership.rb