Skip to content

Instantly share code, notes, and snippets.

@marciojg
Last active August 15, 2021 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marciojg/c609d6abce02d9b8af2c0d0c5bb8943c to your computer and use it in GitHub Desktop.
Save marciojg/c609d6abce02d9b8af2c0d0c5bb8943c to your computer and use it in GitHub Desktop.

https://bearmetal.eu/theden/how-do-i-know-whether-my-rails-app-is-thread-safe-or-not/ https://stackoverflow.com/questions/9558192/thread-safety-class-variables-in-ruby

  • fazer artigo
    • sidekiq concurrently
    • job com 2 execuções
      • Exemplo1.execute(kwargs)
      • Exemplo2.new(kwargs).blabla
    • Zica de concontrencia pe o Exemplo 1 usava variável de classe que não é thread safed
class ExemploJob < ApplicationJob
  queue_as :queue

  def perform(**kwargs)
    kwargs.transform_values!(&:to_i)

    Exemplo1.execute(kwargs) # Esse que da zica ;)
    Exemplo2.new(kwargs).blabla
  end
end

class Exemplo1
  self << class
    def execute(kwargs)
      @kwargs = kwargs
	
      puts @kwargs
    end
  end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment