Module: Sneakers

Extended by:
Sneakers
Included in:
Sneakers
Defined in:
lib/sneakers/cli.rb,
lib/sneakers.rb,
lib/sneakers.rb,
lib/sneakers/errors.rb,
lib/sneakers/runner.rb,
lib/sneakers/worker.rb,
lib/sneakers/spawner.rb,
lib/sneakers/version.rb,
lib/sneakers/publisher.rb,
lib/sneakers/workergroup.rb,
lib/sneakers/content_type.rb,
lib/sneakers/configuration.rb,
lib/sneakers/error_reporter.rb,
lib/sneakers/concerns/logging.rb,
lib/sneakers/concerns/metrics.rb,
lib/sneakers/handlers/oneshot.rb,
lib/sneakers/handlers/maxretry.rb,
lib/sneakers/metrics/null_metrics.rb,
lib/sneakers/metrics/statsd_metrics.rb,
lib/sneakers/metrics/logging_metrics.rb,
lib/sneakers/metrics/newrelic_metrics.rb,
lib/sneakers/support/production_formatter.rb

Overview

Defined Under Namespace

Modules: Concerns, ErrorReporter, Handlers, Metrics, Support, Worker, WorkerGroup Classes: CLI, Configuration, ContentType, Publisher, Queue, Runner, RunnerConfig, Spawner, Utils

Constant Summary collapse

CONFIG =
Configuration.new
VERSION =
"2.10.0.pre1"

Instance Method Summary collapse

Instance Method Details

#clear!Object



38
39
40
41
42
43
# File 'lib/sneakers.rb', line 38

def clear!
  CONFIG.clear
  @logger = nil
  @publisher = nil
  @configured = false
end

#configure(opts = {}) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/sneakers.rb', line 29

def configure(opts={})
  # worker > userland > defaults
  CONFIG.merge!(opts)
  setup_general_logger!
  setup_worker_concerns!
  setup_general_publisher!
  @configured = true
end

#configure_server {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (Sneakers)

    the object that the method was called on



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

def configure_server
  yield self if server?
end

#configured?Boolean



64
65
66
# File 'lib/sneakers.rb', line 64

def configured?
  @configured
end

#daemonize!(loglevel = Logger::INFO) ⇒ Object



45
46
47
48
49
50
# File 'lib/sneakers.rb', line 45

def daemonize!(loglevel=Logger::INFO)
  CONFIG[:log] = 'sneakers.log'
  CONFIG[:daemonize] = true
  setup_general_logger!
  logger.level = loglevel
end

#error_reportersObject

Register a proc to handle any error which occurs within the Sneakers process.

Sneakers.error_reporters << proc { |exception, worker, context_hash| MyErrorService.notify(exception, context_hash) }

The default error handler logs errors to Sneakers.logger. Ripped off from github.com/mperham/sidekiq/blob/6ad6a3aa330deebd76c6cf0d353f66abd3bef93b/lib/sidekiq.rb#L165-L174



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

def error_reporters
  CONFIG[:error_reporters]
end

#loggerObject



56
57
58
# File 'lib/sneakers.rb', line 56

def logger
  @logger
end

#logger=(logger) ⇒ Object



52
53
54
# File 'lib/sneakers.rb', line 52

def logger=(logger)
  @logger = logger
end

#publish(msg, routing) ⇒ Object



60
61
62
# File 'lib/sneakers.rb', line 60

def publish(msg, routing)
  @publisher.publish(msg, routing)
end

#server=(server) ⇒ Object



68
69
70
# File 'lib/sneakers.rb', line 68

def server=(server)
  @server = server
end

#server?Boolean



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

def server?
  @server
end