SlideShare uma empresa Scribd logo
1 de 41
Baixar para ler offline
Implementações paralelas
        Willian Molinari
         a.k.a PotHix
WTF
1996!!




John Carmack
https://github.com/id-Software
#AltDevBlogADay
Várias formas de
implementações paralelas
1. Substitution
Master
Código no branch principal
class VirtualMachine
 def name
   hypervisor_session.VM.get_name(uuid)
 end
 .
 .
 .
end
Código código no branch novo
class VirtualMachine
 def name
   on_hypervisor.VM.get_name(uuid)
 end
 .
 .
 .
end
Master    NewFeature




Feature
"Virar a chave"
Dá para evitar?
2. Feature Toggle
2. Feature Toggle
Para adição de funcionalidade
Martin Fowler



       http://martinfowler.com/bliki/FeatureToggle.html
Master



Feature1

           Merge   Release

Feature2



Feature3
Martin Fowler



       http://martinfowler.com/bliki/FeatureToggle.html
Nando Vieira



     http://simplesideias.com.br/usando-presenters-no-rails/
2. Feature Toggle
Para várias implementações
Fabio Kung

 http://fabiokung.com/2010/10/16/dsls-one-interface-multiple-implementations/
Qual a idéia?
module Resque
 class Consumer
  class << self
    def queue(name)
     @queue = name
    end

   def timeout(seconds=nil)
    @lock_timeout = seconds unless seconds
    @lock_timeout || 1.hour
   end

   def exclusive(param)
    @exclusive = param
    self.extend(Resque::Plugins::LockTimeout) if exclusive?
    @lock_timeout ||= 1.hour
   end
   def publish(message={})
    Resque.enqueue(self, message)
   end
   ...
  end
 end
end
module ActiveMQ
 class Consumer
  class << self
    attr_reader :queue_name, :queued_process, :headers, :timeout_value

   def queue(name)
    @queue_name = "/queue/#{name}"
   end

   def timeout(seconds)
    @timeout_value = seconds
   end

   def exclusive(param)
    @exclusive = param
   end

   def publish(message = {})
     client = Stomp::Client.new(NephelaeConfig[:broker].merge(:max_reconnect_attempts => 1))
     client.publish(queue_name, message.to_yaml, {
       :persistent => true, :suppress_content_length => true
     })
   end
   ...
  end
 end
end
require 'xmpp4r'
module XMPP
 class Consumer
  class << self
    attr_reader :queue_name, :queued_process, :timeout_value

   def queue(name)
    @queue_name = "#{name}@localhost"
   end

   def timeout(seconds)
    @timeout_value = seconds
   end

   def exclusive(param)
    @exclusive = param
   end

   def publish(message={})
    publisher_client.send(Jabber::Message.new(queue_name, message.to_yaml))
   end
   ...
  end
 end
end
app/consumers/consumer.rb
  Consumer = ActiveMQ::Consumer
app/consumers/consumer.rb
  Consumer = XMPP::Consumer
app/consumers/consumer.rb
  Consumer = Resque::Consumer
Injeção de dependencia
MyQueue.new(Resque::Consumer)
Por configuração
3. Feature versioning
Manager




Ver1             Ver2
module Network
 class Ver1
  def insert_filter_rule(filter_rule)
    filter_rule.firewalls.in_parallel do |firewall|
      ssh_executor = SSHExecutor.new(firewall.ip_address, 'sservice')
      result = ssh_executor.exec(
        :insert_filter_firewall_rules, :rule => filter_rule,
        :internal_address => filter_rule.ip_pair.private_ip,
        :firewall => firewall
      )
      raise "Insertion failed: #{result[:out]}" if result[:status] != 0
    end
    filter_rule.update_attribute(:status, :done)
  end
  def insert_dhcp_entry(vm)
    vm.zone.dhcps.in_parallel do |dhcp_server|
      result = dhcp_server.synchronize
      raise "DHCP failed: #{result[:out]}" if result[:status] != 0
    end
  end
 end
end
Manager




Ver1             Ver2
module Network
 class Ver2
  def insert_filter_rule(filter_rule)
    quantum = Openstack::QuantumClient::L2l3.new(NephelaeConfig[:quantum])
    quantum_response = quantum.filter_rule.create(
      filter_rule.filter_address,
      filter_rule.ip_pair.public_ip.to_s,
      filter_rule.filter_port,
      filter_rule.filter_protocol
    )
    filter_rule.update_attribute(:quantum_uuid, quantum_response["filter_rule"]["id"])
  end

 def insert_dhcp_entry(vm)
   quantum = Openstack::QuantumClient::L2l3.new(NephelaeConfig[:quantum])
   quantum_response = quantum.dhcp_entry.create(vm.public_ip.to_s, vm.mac, vm.name)
  end
end
Manager


"1.0"             "2.0"


Ver1              Ver2
module Network
 module Manager
  extend self

  def for(versioning_object)
   versioning_object.version == "2.0" ? Network::Ver2.new : Network::Ver1.new
  end
 end
end
module Network
 module Manager
  extend self

  def for(versioning_object)
   versioning_object.version.constantize.new
  end
 end
end



Network::Manager.for(pool).insert_filter_rule(virtual_machine)
Várias formas de
                        atacar o problema
           r bu llet
 os ilve
N
               Resumindo
    Su                              bene fício
      an
         ec              Cu sto X
            es
               sida
                   de
Perguntas?

Mais conteúdo relacionado

Mais procurados

Node js presentation
Node js presentationNode js presentation
Node js presentation
martincabrera
 
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framewo...
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framewo...Yapc::Asia 2008 Tokyo - Easy system administration programming with a framewo...
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framewo...
Gosuke Miyashita
 
Europython 2011 - Playing tasks with Django & Celery
Europython 2011 - Playing tasks with Django & CeleryEuropython 2011 - Playing tasks with Django & Celery
Europython 2011 - Playing tasks with Django & Celery
Mauro Rocco
 

Mais procurados (20)

NodeJs
NodeJsNodeJs
NodeJs
 
Node.js API 서버 성능 개선기
Node.js API 서버 성능 개선기Node.js API 서버 성능 개선기
Node.js API 서버 성능 개선기
 
EventMachine for RubyFuZa 2012
EventMachine for RubyFuZa   2012EventMachine for RubyFuZa   2012
EventMachine for RubyFuZa 2012
 
DevOps(4) : Ansible(2) - (MOSG)
DevOps(4) : Ansible(2) - (MOSG)DevOps(4) : Ansible(2) - (MOSG)
DevOps(4) : Ansible(2) - (MOSG)
 
Ruby Concurrency and EventMachine
Ruby Concurrency and EventMachineRuby Concurrency and EventMachine
Ruby Concurrency and EventMachine
 
Cooking pies with Celery
Cooking pies with CeleryCooking pies with Celery
Cooking pies with Celery
 
Node js presentation
Node js presentationNode js presentation
Node js presentation
 
Django Celery
Django Celery Django Celery
Django Celery
 
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framewo...
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framewo...Yapc::Asia 2008 Tokyo - Easy system administration programming with a framewo...
Yapc::Asia 2008 Tokyo - Easy system administration programming with a framewo...
 
Future Decoded - Node.js per sviluppatori .NET
Future Decoded - Node.js per sviluppatori .NETFuture Decoded - Node.js per sviluppatori .NET
Future Decoded - Node.js per sviluppatori .NET
 
jRuby: The best of both worlds
jRuby: The best of both worldsjRuby: The best of both worlds
jRuby: The best of both worlds
 
Javascript Promises/Q Library
Javascript Promises/Q LibraryJavascript Promises/Q Library
Javascript Promises/Q Library
 
Building Distributed System with Celery on Docker Swarm - PyCon JP 2016
Building Distributed System with Celery on Docker Swarm - PyCon JP 2016Building Distributed System with Celery on Docker Swarm - PyCon JP 2016
Building Distributed System with Celery on Docker Swarm - PyCon JP 2016
 
Europython 2011 - Playing tasks with Django & Celery
Europython 2011 - Playing tasks with Django & CeleryEuropython 2011 - Playing tasks with Django & Celery
Europython 2011 - Playing tasks with Django & Celery
 
Celery
CeleryCelery
Celery
 
Gevent rabbit rpc
Gevent rabbit rpcGevent rabbit rpc
Gevent rabbit rpc
 
RDSDataSource: Мастер-класс по Dip
RDSDataSource: Мастер-класс по DipRDSDataSource: Мастер-класс по Dip
RDSDataSource: Мастер-класс по Dip
 
Preparation study of_docker - (MOSG)
Preparation study of_docker  - (MOSG)Preparation study of_docker  - (MOSG)
Preparation study of_docker - (MOSG)
 
DevOps(2) : Vagrant - (MOSG)
DevOps(2) : Vagrant  -  (MOSG)DevOps(2) : Vagrant  -  (MOSG)
DevOps(2) : Vagrant - (MOSG)
 
[232]TensorRT를 활용한 딥러닝 Inference 최적화
[232]TensorRT를 활용한 딥러닝 Inference 최적화[232]TensorRT를 활용한 딥러닝 Inference 최적화
[232]TensorRT를 활용한 딥러닝 Inference 최적화
 

Destaque (7)

Abertura do Ruby + Rails no Mundo Real
Abertura do Ruby + Rails no Mundo RealAbertura do Ruby + Rails no Mundo Real
Abertura do Ruby + Rails no Mundo Real
 
As escolhas do desenvolvedor
As escolhas do desenvolvedorAs escolhas do desenvolvedor
As escolhas do desenvolvedor
 
Desconstruindo a web
Desconstruindo a webDesconstruindo a web
Desconstruindo a web
 
Desenvolvimento de jogos com HTML5 e javascript
Desenvolvimento de jogos com HTML5 e javascriptDesenvolvimento de jogos com HTML5 e javascript
Desenvolvimento de jogos com HTML5 e javascript
 
Mesos
MesosMesos
Mesos
 
Ruby e xmpp
Ruby e xmppRuby e xmpp
Ruby e xmpp
 
Vim
VimVim
Vim
 

Semelhante a Implementações paralelas

Presentation Lfoppiano Pycon
Presentation Lfoppiano PyconPresentation Lfoppiano Pycon
Presentation Lfoppiano Pycon
Luca Foppiano
 

Semelhante a Implementações paralelas (20)

Presentation Lfoppiano Pycon
Presentation Lfoppiano PyconPresentation Lfoppiano Pycon
Presentation Lfoppiano Pycon
 
Review unknown code with static analysis - bredaphp
Review unknown code with static analysis - bredaphpReview unknown code with static analysis - bredaphp
Review unknown code with static analysis - bredaphp
 
Harmonious Development: Via Vagrant and Puppet
Harmonious Development: Via Vagrant and PuppetHarmonious Development: Via Vagrant and Puppet
Harmonious Development: Via Vagrant and Puppet
 
Our Puppet Story – Patterns and Learnings (sage@guug, March 2014)
Our Puppet Story – Patterns and Learnings (sage@guug, March 2014)Our Puppet Story – Patterns and Learnings (sage@guug, March 2014)
Our Puppet Story – Patterns and Learnings (sage@guug, March 2014)
 
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
 
Python twisted
Python twistedPython twisted
Python twisted
 
Magento 2 Development
Magento 2 DevelopmentMagento 2 Development
Magento 2 Development
 
Lean Php Presentation
Lean Php PresentationLean Php Presentation
Lean Php Presentation
 
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterSymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
 
Дмитрий Демчук. Кроссплатформенный краш-репорт
Дмитрий Демчук. Кроссплатформенный краш-репортДмитрий Демчук. Кроссплатформенный краш-репорт
Дмитрий Демчук. Кроссплатформенный краш-репорт
 
Effizientere WordPress-Plugin-Entwicklung mit Softwaretests
Effizientere WordPress-Plugin-Entwicklung mit SoftwaretestsEffizientere WordPress-Plugin-Entwicklung mit Softwaretests
Effizientere WordPress-Plugin-Entwicklung mit Softwaretests
 
Intro django
Intro djangoIntro django
Intro django
 
Building and Incredible Machine with Pipelines and Generators in PHP (IPC Ber...
Building and Incredible Machine with Pipelines and Generators in PHP (IPC Ber...Building and Incredible Machine with Pipelines and Generators in PHP (IPC Ber...
Building and Incredible Machine with Pipelines and Generators in PHP (IPC Ber...
 
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
Advanced Eclipse Workshop (held at IPC2010 -spring edition-)
 
The why and how of moving to PHP 5.4/5.5
The why and how of moving to PHP 5.4/5.5The why and how of moving to PHP 5.4/5.5
The why and how of moving to PHP 5.4/5.5
 
JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?
 
Silicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsSilicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM Mechanics
 
Is your code ready for PHP 7 ?
Is your code ready for PHP 7 ?Is your code ready for PHP 7 ?
Is your code ready for PHP 7 ?
 
Command pattern vs. MVC: Lean Beans (are made of this)
Command pattern vs. MVC: Lean Beans (are made of this)Command pattern vs. MVC: Lean Beans (are made of this)
Command pattern vs. MVC: Lean Beans (are made of this)
 
Automation with Ansible and Containers
Automation with Ansible and ContainersAutomation with Ansible and Containers
Automation with Ansible and Containers
 

Mais de Willian Molinari

Abertura do ruby_rails_no_mundo_real_guru_sp
Abertura do ruby_rails_no_mundo_real_guru_spAbertura do ruby_rails_no_mundo_real_guru_sp
Abertura do ruby_rails_no_mundo_real_guru_sp
Willian Molinari
 

Mais de Willian Molinari (10)

Javascript and browser games
Javascript and browser gamesJavascript and browser games
Javascript and browser games
 
How we used ruby to build locaweb's cloud (http://presentations.pothix.com/ru...
How we used ruby to build locaweb's cloud (http://presentations.pothix.com/ru...How we used ruby to build locaweb's cloud (http://presentations.pothix.com/ru...
How we used ruby to build locaweb's cloud (http://presentations.pothix.com/ru...
 
Html5, gamedev e o skeleton jigsaw
Html5, gamedev e o skeleton jigsawHtml5, gamedev e o skeleton jigsaw
Html5, gamedev e o skeleton jigsaw
 
Game network programming
Game network programmingGame network programming
Game network programming
 
Locasberos
LocasberosLocasberos
Locasberos
 
Simplestack
SimplestackSimplestack
Simplestack
 
TDC2011 - Desenvolvimento de jogos com Javascript e HTML5
TDC2011 - Desenvolvimento de jogos com Javascript e HTML5TDC2011 - Desenvolvimento de jogos com Javascript e HTML5
TDC2011 - Desenvolvimento de jogos com Javascript e HTML5
 
FLISOL SJC - Desenvolvimento de jogos com javascrit e HTML5
FLISOL SJC - Desenvolvimento de jogos com javascrit e HTML5FLISOL SJC - Desenvolvimento de jogos com javascrit e HTML5
FLISOL SJC - Desenvolvimento de jogos com javascrit e HTML5
 
Abertura do ruby_rails_no_mundo_real_guru_sp
Abertura do ruby_rails_no_mundo_real_guru_spAbertura do ruby_rails_no_mundo_real_guru_sp
Abertura do ruby_rails_no_mundo_real_guru_sp
 
What is and how does work RubyLearning.org
What is and how does work RubyLearning.orgWhat is and how does work RubyLearning.org
What is and how does work RubyLearning.org
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 

Implementações paralelas