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.2"

Class Method Summary collapse

Class Method Details

.activitiesObject



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

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

.assert_stubbedObject



78
79
80
# File 'lib/fluere.rb', line 78

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

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

Yields:



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

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

.default_activity_optionsObject



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

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

.default_workflow_optionsObject



35
36
37
38
39
40
41
# File 'lib/fluere.rb', line 35

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

.domainObject



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

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

.flush!Object



62
63
64
# File 'lib/fluere.rb', line 62

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

.ignore_executionsObject



90
91
92
93
94
95
96
# File 'lib/fluere.rb', line 90

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)


86
87
88
# File 'lib/fluere.rb', line 86

def self.ignore_executions?
  @ignore_executions
end

.perform_executions?Boolean

Returns:

  • (Boolean)


82
83
84
# File 'lib/fluere.rb', line 82

def self.perform_executions?
  !ignore_executions?
end

.prefixed_task_list(task_list) ⇒ Object



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

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

.start_execution(klass, *args) ⇒ Object



51
52
53
54
55
56
57
58
59
60
# File 'lib/fluere.rb', line 51

def self.start_execution(klass, *args)
  if stubbed?
    if perform_executions?
      method = klass.workflows.first.options.execution_method.to_sym
      klass.new.send(method, *args)
    end
  else
    klass.workflow_client.start_execution(*args)
  end
end

.stub!Object



70
71
72
# File 'lib/fluere.rb', line 70

def self.stub!
  @stubbed = true
end

.stubbed?Boolean

Returns:

  • (Boolean)


66
67
68
# File 'lib/fluere.rb', line 66

def self.stubbed?
  @stubbed
end

.swfObject



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

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

.unstub!Object



74
75
76
# File 'lib/fluere.rb', line 74

def self.unstub!
  @stubbed = false
end

.workflowsObject



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

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