Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

sidekiq_middlewares

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

sidekiq_middlewares

  • 0.3.3
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

sidekiq_middlewares

Build Status

Ruby Sidekiq Middlewares For common uses

Benchmarker

Optiosn
  • logger
    • required
    • this will be the object that must respond to :info method
  • formatter
    • optional
    • this proc will receive one argument, a message object which is a Hash type
    • If the logger can handle Hash messages, such as TwP's logging libary, than you don't need this

first you need a logger that respond to :info method, and format the message object into an expected format.

For simplicity, in the example this will be json.

require 'json'
require 'logger'
json_logger = Logger.new(STDOUT)
json_logger.formatter = proc do |severity, datetime, progname, msg|
  JSON.dump(msg) + "\n"
end

Than you can use it with the Benchmarker middleware like this:

Sidekiq.configure_server do |config|
  config.redis = sidekiq_redis_config

  config.server_middleware do |chain|
    chain.add SidekiqMiddlewares::Benchmarker, logger: json_logger
  end
end

Or if you don't want to provide logger who also know about how to format, you can give an optional formatter to the middleware.

Sidekiq.configure_server do |config|
  config.redis = sidekiq_redis_config

  config.server_middleware do |chain|
    chain.add SidekiqMiddlewares::Benchmarker, logger: Logger.new(STDOUT), formatter: proc { |m| JSON.dump(m) + "\n" }
  end
end

FAQs

Package last updated on 15 Sep 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc