Module: Fluere

Defined in:
lib/fluere.rb,
lib/fluere/config.rb,
lib/fluere/worker.rb,
lib/fluere/version.rb,
lib/fluere/workflow.rb,
lib/fluere/exceptions.rb

Defined Under Namespace

Modules: Worker, Workflow Classes: Config, StubbedPathOnlyError

Constant Summary collapse

VERSION =
"0.0.4"

Class Method Summary collapse

Class Method Details

.activitiesObject



26
27
28
# File 'lib/fluere.rb', line 26

def self.activities
  @activities ||= []
end

.activities_task_listObject



22
23
24
# File 'lib/fluere.rb', line 22

def self.activities_task_list
  Fluere.prefixed_task_list('activities')
end

.assert_stubbedObject



92
93
94
# File 'lib/fluere.rb', line 92

def self.assert_stubbed
  raise StubbedPathOnlyError.new unless stubbed?
end

.configure {|Fluere::Config| ... } ⇒ Object

Yields:



10
11
12
# File 'lib/fluere.rb', line 10

def self.configure(&block)
  yield Fluere::Config
end

.decisions_task_listObject



18
19
20
# File 'lib/fluere.rb', line 18

def self.decisions_task_list
  Fluere.prefixed_task_list('decisions')
end

.default_activity_optionsObject



50
51
52
53
54
55
56
# File 'lib/fluere.rb', line 50

def self.default_activity_options
  {
    default_task_schedule_to_close_timeout: 60 * 60 * 2,
    default_task_schedule_to_start_timeout: 60 * 60 * 2,
    default_task_start_to_close_timeout: 60 * 60 * 2,
  }
end

.default_workflow_optionsObject



42
43
44
45
46
47
48
# File 'lib/fluere.rb', line 42

def self.default_workflow_options
  {
    default_execution_start_to_close_timeout: 60 * 60 * 2,
    default_task_start_to_close_timeout: 60 * 60 * 2,
    default_child_policy: :terminate,
  }
end

.domainObject



34
35
36
# File 'lib/fluere.rb', line 34

def self.domain
  swf.domains[Config.domain]
end

.flush!Object



76
77
78
# File 'lib/fluere.rb', line 76

def self.flush!
  domain.workflow_executions.with_status(:open).map { |we| we.terminate }
end

.ignore_executionsObject



104
105
106
107
108
109
110
# File 'lib/fluere.rb', line 104

def self.ignore_executions
  raise "only allowed to ignore executions when stubbed!" unless stubbed?
  @ignore_executions = true
  yield
ensure
  @ignore_executions = false
end

.ignore_executions?Boolean

Returns:

  • (Boolean)


100
101
102
# File 'lib/fluere.rb', line 100

def self.ignore_executions?
  @ignore_executions
end

.info(msg) ⇒ Object



72
73
74
# File 'lib/fluere.rb', line 72

def self.info(msg)
  Fluere::Config.logger.info(msg)
end

.perform_executions?Boolean

Returns:

  • (Boolean)


96
97
98
# File 'lib/fluere.rb', line 96

def self.perform_executions?
  !ignore_executions?
end

.prefixed_task_list(task_list) ⇒ Object



38
39
40
# File 'lib/fluere.rb', line 38

def self.prefixed_task_list(task_list)
  [Fluere::Config.task_list_prefix, task_list].join('-')
end

.start_execution(klass, *args) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/fluere.rb', line 58

def self.start_execution(klass, *args)
  if stubbed?
    if perform_executions?
      info("Performing a stubbed execution, calling #{klass} decider block with args: #{args.inspect}")
      klass.decider_class.new.send(Fluere::Workflow::EXECUTION_METHOD, *args)
    else
      info("Skipped workflow execution for #{klass}")
    end
  else
    info("Requesting a workflow execution for #{klass}")
    klass.workflow_client.start_execution(*args)
  end
end

.stub!Object



84
85
86
# File 'lib/fluere.rb', line 84

def self.stub!
  @stubbed = true
end

.stubbed?Boolean

Returns:

  • (Boolean)


80
81
82
# File 'lib/fluere.rb', line 80

def self.stubbed?
  @stubbed
end

.swfObject



30
31
32
# File 'lib/fluere.rb', line 30

def self.swf
  @swf ||= AWS::SimpleWorkflow.new
end

.unstub!Object



88
89
90
# File 'lib/fluere.rb', line 88

def self.unstub!
  @stubbed = false
end

.workflowsObject



14
15
16
# File 'lib/fluere.rb', line 14

def self.workflows
  @workflows ||= []
end