Module: Taskinator

Defined in:
lib/taskinator/logger.rb,
lib/taskinator.rb,
lib/taskinator/api.rb,
lib/taskinator/task.rb,
lib/taskinator/tasks.rb,
lib/taskinator/queues.rb,
lib/taskinator/process.rb,
lib/taskinator/version.rb,
lib/taskinator/visitor.rb,
lib/taskinator/executor.rb,
lib/taskinator/workflow.rb,
lib/taskinator/log_stats.rb,
lib/taskinator/definition.rb,
lib/taskinator/complete_on.rb,
lib/taskinator/persistence.rb,
lib/taskinator/task_worker.rb,
lib/taskinator/xml_visitor.rb,
lib/taskinator/queues/resque.rb,
lib/taskinator/process_worker.rb,
lib/taskinator/queues/sidekiq.rb,
lib/taskinator/instrumentation.rb,
lib/taskinator/redis_connection.rb,
lib/taskinator/queues/active_job.rb,
lib/taskinator/definition/builder.rb,
lib/taskinator/queues/delayed_job.rb,
lib/taskinator/create_process_worker.rb

Overview

:nocov:

Defined Under Namespace

Modules: Api, CompleteOn, Definition, Instrumentation, LogStats, Logging, Persistence, Queues, Visitor, Workflow Classes: ConsoleInstrumenter, CreateProcessWorker, Executor, NoOpInstrumenter, Process, ProcessWorker, RedisConnection, Task, TaskWorker, Tasks

Constant Summary collapse

NAME =
"Taskinator"
LICENSE =
'See LICENSE.txt for licensing details.'
DEFAULTS =
{
  # none for now...
}
VERSION =
"0.4.7"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.queue_adapterObject

the queue adapter to use supported adapters include :active_job, :delayed_job, :redis and :sidekiq NOTE: ensure that the respective gem is included



103
104
105
# File 'lib/taskinator.rb', line 103

def queue_adapter
  @queue_adapter
end

.queue_configObject

configuration, usually a hash, which will be passed to the configured queue adapter



112
113
114
# File 'lib/taskinator.rb', line 112

def queue_config
  @queue_config
end

Class Method Details

.configure {|_self| ... } ⇒ Object

Configuration for Taskinator client, use like:

Taskinator.configure do |config|
  config.redis = { :namespace => 'myapp', :pool_size => 1, :url => 'redis://myhost:8877/0' }
  config.queue_config = { :process_queue => 'processes', :task_queue => 'tasks' }
end

Yields:

  • (_self)

Yield Parameters:

  • _self (Taskinator)

    the object that the method was called on



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

def configure
  yield self if block_given?
end

.generate_uuidObject



54
55
56
# File 'lib/taskinator.rb', line 54

def generate_uuid
  SecureRandom.uuid
end

.instrumenterObject

set the instrumenter to use. can be ActiveSupport::Notifications



129
130
131
# File 'lib/taskinator.rb', line 129

def instrumenter
  @instrumenter ||= NoOpInstrumenter.new
end

.instrumenter=(value) ⇒ Object



132
133
134
# File 'lib/taskinator.rb', line 132

def instrumenter=(value)
  @instrumenter = value
end

.loggerObject



83
84
85
# File 'lib/taskinator.rb', line 83

def logger
  Taskinator::Logging.logger
end

.logger=(log) ⇒ Object



87
88
89
# File 'lib/taskinator.rb', line 87

def logger=(log)
  Taskinator::Logging.logger = log
end

.optionsObject



47
48
49
# File 'lib/taskinator.rb', line 47

def options
  @options ||= DEFAULTS.dup
end

.options=(opts) ⇒ Object



50
51
52
# File 'lib/taskinator.rb', line 50

def options=(opts)
  @options = opts
end

.queueObject



119
120
121
122
123
124
125
# File 'lib/taskinator.rb', line 119

def queue
  @queue ||= begin
    adapter = self.queue_adapter || :resque  # TODO: change default to :active_job
    config = queue_config || {}
    Taskinator::Queues.create_adapter(adapter, config)
  end
end

.redis(&block) ⇒ Object

Raises:

  • (ArgumentError)


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

def redis(&block)
  raise ArgumentError, "requires a block" unless block_given?
  redis_pool.with(&block)
end

.redis=(hash) ⇒ Object



79
80
81
# File 'lib/taskinator.rb', line 79

def redis=(hash)
  @redis = Taskinator::RedisConnection.create(hash)
end

.redis_poolObject



75
76
77
# File 'lib/taskinator.rb', line 75

def redis_pool
  @redis ||= Taskinator::RedisConnection.create
end

.statsd_clientObject



91
92
93
# File 'lib/taskinator.rb', line 91

def statsd_client
  Taskinator::LogStats.client
end

.statsd_client=(client) ⇒ Object



95
96
97
# File 'lib/taskinator.rb', line 95

def statsd_client=(client)
  Taskinator::LogStats.client = client
end