Class: Sidekiq::Web

Inherits:
Object
  • Object
show all
Defined in:
lib/sidekiq/web.rb,
lib/sidekiq/web/action.rb,
lib/sidekiq/web/config.rb,
lib/sidekiq/web/router.rb,
lib/sidekiq/web/application.rb,
lib/sidekiq/web/csrf_protection.rb

Defined Under Namespace

Modules: Router Classes: Action, Application, Config, CsrfProtection, Route

Constant Summary collapse

ROOT =
File.expand_path("#{File.dirname(__FILE__)}/../../web")
VIEWS =
"#{ROOT}/views"
LOCALES =
["#{ROOT}/locales"]
LAYOUT =
"#{VIEWS}/layout.erb"
ASSETS =
"#{ROOT}/assets"
DEFAULT_TABS =
{
  "Dashboard" => "",
  "Busy" => "busy",
  "Queues" => "queues",
  "Retries" => "retries",
  "Scheduled" => "scheduled",
  "Dead" => "morgue",
  "Metrics" => "metrics",
  "Profiles" => "profiles"
}
@@config =
Sidekiq::Web::Config.new

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.app_url=(url) ⇒ Object



41
42
43
# File 'lib/sidekiq/web.rb', line 41

def app_url=(url)
  @@config.app_url = url
end

.call(env) ⇒ Object

Allow user to say

run Sidekiq::Web

rather than:

run Sidekiq::Web.new


75
76
77
78
# File 'lib/sidekiq/web.rb', line 75

def self.call(env)
  @inst ||= new
  @inst.call(env)
end

.configureObject



33
34
35
36
37
38
39
# File 'lib/sidekiq/web.rb', line 33

def configure
  if block_given?
    yield @@config
  else
    @@config
  end
end

.custom_job_info_rowsObject



51
# File 'lib/sidekiq/web.rb', line 51

def custom_job_info_rows = @@config.custom_job_info_rows

.localesObject



47
# File 'lib/sidekiq/web.rb', line 47

def locales = @@config.locales

.middlewaresObject



61
# File 'lib/sidekiq/web.rb', line 61

def middlewares = @@config.middlewares

.redis_poolObject



53
54
55
# File 'lib/sidekiq/web.rb', line 53

def redis_pool
  @pool || Sidekiq.default_configuration.redis_pool
end

.redis_pool=(pool) ⇒ Object



57
58
59
# File 'lib/sidekiq/web.rb', line 57

def redis_pool=(pool)
  @pool = pool
end

.register(*args, **kw, &block) ⇒ Object



65
66
67
68
# File 'lib/sidekiq/web.rb', line 65

def register(*args, **kw, &block)
  Sidekiq.logger.warn { "`Sidekiq::Web.register` is deprecated, use `Sidekiq::Web.configure {|cfg| cfg.register(...) }`" }
  @@config.register(*args, **kw, &block)
end

.reset!Object

testing, internal use only



81
82
83
84
# File 'lib/sidekiq/web.rb', line 81

def self.reset!
  @@config.reset!
  @inst = nil
end

.tabsObject



45
# File 'lib/sidekiq/web.rb', line 45

def tabs = @@config.tabs

.use(*args, &block) ⇒ Object



63
# File 'lib/sidekiq/web.rb', line 63

def use(*args, &block) = @@config.middlewares << [args, block]

.viewsObject



49
# File 'lib/sidekiq/web.rb', line 49

def views = @@config.views

Instance Method Details

#appObject



93
94
95
# File 'lib/sidekiq/web.rb', line 93

def app
  @app ||= build(@@config)
end

#call(env) ⇒ Object



86
87
88
89
90
91
# File 'lib/sidekiq/web.rb', line 86

def call(env)
  env[:web_config] = Sidekiq::Web.configure
  env[:csp_nonce] = SecureRandom.hex(8)
  env[:redis_pool] = self.class.redis_pool
  app.call(env)
end