Module: AWS::Flow::Activities
Overview
Methods and constants related to activities.
Defined Under Namespace
Modules: InstanceMethods
Instance Attribute Summary collapse
-
#activities ⇒ Object
Gets the list of ActivityType objects that were created by the #activity method.
-
#activity_client ⇒ Object
Gets the ActivityClient contained by the class.
Attributes included from Utilities::UpwardLookups
Class Method Summary collapse
Instance Method Summary collapse
- #_options ⇒ Object private
-
#activity(*activity_names, &block) ⇒ Object
Defines one or more activities with ActivityOptions provided in the supplied block.
- #look_upwards(variable) ⇒ Object private
Methods included from Utilities::UpwardLookups
held_properties, properties, property
Instance Attribute Details
#activities ⇒ Object
Gets the list of AWS::Flow::ActivityType objects that were created by the #activity method.
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 |
# File 'lib/aws/decider/activity.rb', line 352 module Activities @precursors ||= [] attr_accessor :activity_client, :activities def self.extended(base) base.send :include, InstanceMethods end module InstanceMethods # Sets the {ActivityExecutionContext} instance for the activity task. attr_writer :_activity_execution_context # Gets the activity execution context for the activity task. Raises an `IllegalStateException` if the activity # has no context. # # @return [ActivityExecutionContext] The execution context for this activity. # def activity_execution_context raise IllegalStateException.new("No activity execution context") unless @_activity_execution_context @_activity_execution_context end # Records a heartbeat for the activity, indicating to Amazon SWF that the activity is still making progress. # # @param [String] details # If specified, contains details about the progress of the activity task. Up to 2048 # characters can be provided. # def record_activity_heartbeat(details) @_activity_execution_context.record_activity_heartbeat(details) end end # @api private extend Utilities::UpwardLookups # @api private def look_upwards(variable) precursors = self.ancestors.dup precursors.delete(self) results = precursors.map { |x| x.send(variable) if x.methods.map(&:to_sym).include? variable }.compact.flatten.uniq end property(:activities, []) # @api private def ; @activities.map(&:options); end # Defines one or more activities with {ActivityOptions} provided in the # supplied block. # # @param [Array] activity_names # The names of the activities to define. These names will be used to # create {ActivityType} objects, one per name. # # Each activity type is named as *prefix.activity_name*, where the # *prefix* is specified in the options block, and each *activity_name* # comes from the list passed to this parameter. # # @param [Hash] block # {ActivityOptions} to use on the defined activities. # # The following options are *required* when registering an activity: # # * `version` - The version of the activity type. # * `task_list` - The task list used to poll for activity tasks. # # @example Defining an activity # new_activity_class = Class.new(MyActivity) do # extend Activities # # activity :activity1 do # { # :default_task_heartbeat_timeout => "3600", # :default_task_list => task_list, # :default_task_schedule_to_close_timeout => "20", # :default_task_schedule_to_start_timeout => "20", # :default_task_start_to_close_timeout => "20", # :version => "1", # :prefix_name => "ExampleActivity" # } # end # # def activity1 # puts "Hello!" # end # end def activity(*activity_names, &block) = Utilities::(ActivityOptions, block) activity_names.each do |activity_name| prefix_name = .prefix_name || self.to_s activity_type = ActivityType.new(prefix_name + "." + activity_name.to_s, .version, ) @activities ||= [] @activities << activity_type end end end |
#activity_client ⇒ Object
Gets the AWS::Flow::ActivityClient contained by the class.
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 |
# File 'lib/aws/decider/activity.rb', line 352 module Activities @precursors ||= [] attr_accessor :activity_client, :activities def self.extended(base) base.send :include, InstanceMethods end module InstanceMethods # Sets the {ActivityExecutionContext} instance for the activity task. attr_writer :_activity_execution_context # Gets the activity execution context for the activity task. Raises an `IllegalStateException` if the activity # has no context. # # @return [ActivityExecutionContext] The execution context for this activity. # def activity_execution_context raise IllegalStateException.new("No activity execution context") unless @_activity_execution_context @_activity_execution_context end # Records a heartbeat for the activity, indicating to Amazon SWF that the activity is still making progress. # # @param [String] details # If specified, contains details about the progress of the activity task. Up to 2048 # characters can be provided. # def record_activity_heartbeat(details) @_activity_execution_context.record_activity_heartbeat(details) end end # @api private extend Utilities::UpwardLookups # @api private def look_upwards(variable) precursors = self.ancestors.dup precursors.delete(self) results = precursors.map { |x| x.send(variable) if x.methods.map(&:to_sym).include? variable }.compact.flatten.uniq end property(:activities, []) # @api private def ; @activities.map(&:options); end # Defines one or more activities with {ActivityOptions} provided in the # supplied block. # # @param [Array] activity_names # The names of the activities to define. These names will be used to # create {ActivityType} objects, one per name. # # Each activity type is named as *prefix.activity_name*, where the # *prefix* is specified in the options block, and each *activity_name* # comes from the list passed to this parameter. # # @param [Hash] block # {ActivityOptions} to use on the defined activities. # # The following options are *required* when registering an activity: # # * `version` - The version of the activity type. # * `task_list` - The task list used to poll for activity tasks. # # @example Defining an activity # new_activity_class = Class.new(MyActivity) do # extend Activities # # activity :activity1 do # { # :default_task_heartbeat_timeout => "3600", # :default_task_list => task_list, # :default_task_schedule_to_close_timeout => "20", # :default_task_schedule_to_start_timeout => "20", # :default_task_start_to_close_timeout => "20", # :version => "1", # :prefix_name => "ExampleActivity" # } # end # # def activity1 # puts "Hello!" # end # end def activity(*activity_names, &block) = Utilities::(ActivityOptions, block) activity_names.each do |activity_name| prefix_name = .prefix_name || self.to_s activity_type = ActivityType.new(prefix_name + "." + activity_name.to_s, .version, ) @activities ||= [] @activities << activity_type end end end |
Class Method Details
.extended(base) ⇒ Object
355 356 357 |
# File 'lib/aws/decider/activity.rb', line 355 def self.extended(base) base.send :include, InstanceMethods end |
Instance Method Details
#_options ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
395 |
# File 'lib/aws/decider/activity.rb', line 395 def ; @activities.map(&:options); end |
#activity(*activity_names, &block) ⇒ Object
Defines one or more activities with AWS::Flow::ActivityOptions provided in the supplied block.
436 437 438 439 440 441 442 443 444 |
# File 'lib/aws/decider/activity.rb', line 436 def activity(*activity_names, &block) = Utilities::(ActivityOptions, block) activity_names.each do |activity_name| prefix_name = .prefix_name || self.to_s activity_type = ActivityType.new(prefix_name + "." + activity_name.to_s, .version, ) @activities ||= [] @activities << activity_type end end |
#look_upwards(variable) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
387 388 389 390 391 |
# File 'lib/aws/decider/activity.rb', line 387 def look_upwards(variable) precursors = self.ancestors.dup precursors.delete(self) results = precursors.map { |x| x.send(variable) if x.methods.map(&:to_sym).include? variable }.compact.flatten.uniq end |