Upgrade to Pro — share decks privately, control downloads, hide ads and more …

サーキットブレーカーを導入しようとしている話

 サーキットブレーカーを導入しようとしている話

第2回 Nikotama.rb登壇資料です

yusuke miyazaki

June 18, 2019
Tweet

More Decks by yusuke miyazaki

Other Decks in Technology

Transcript

  1. Re:valua t ion https://fril.jp/ L ead & Delight User F

    irst Ownership Fail Smart αʔΩοτϒϨʔΧʔΛಋೖ͠Α͏ͱ͍ͯ͠Δ࿩
  2.   αʔΩοτϒϨʔΧʔͷಋೖʙ(FNͷίΞ෦෼ def run if open? # ϩάग़ྗͳͲ else

    begin response = execution_timer.time(service, notifier, 'execution_time') do yield end success! # HALF-OPENͩͬͨ৔߹ɺCLOSEDʹ͢Δ rescue response = nil failure! # HALF_OPENͩͬͨ৔߹ɺOPENʹ / CLOSEDͩͬͨ৔߹ɺ৚݅ʹΑͬͯOPENʹ End end response end def http_get circuit.run do Zephyr.new('http://example.com').get('/api/messages') end end ˞͔ͳΓ؆ૉԽ͍ͯ͠·͢ɻࢀߟɿ(JU)VCͷ֘౰Օॴ
  3.   αʔΩοτϒϨʔΧʔͷಋೖʙ'BSBEBZͱ૊Έ߹Θ࣮ͤͨ૷ํ๏ require 'faraday' require 'circuitbox/faraday_middleware' conn = Faraday.new(:url

    => "http://example.com") do |c| c.use Circuitbox::FaradayMiddleware end response = conn.get("/api") if response.success? # success else # failure or open circuit end ˞3&"%.&͔Βͷൈਮ ˞'BSBEBZ͸ɺศརͳ)551ΫϥΠΞϯτϥΠϒϥϦʢ3VCZ,BJHJͰ΋঺հ͞Ε͍ͯ·ͨ͠ʣ
  4.   ิ଍ w ԿճΤϥʔͨ͠Β01&/ʹͳΔ͔ɺͳͲ͸ΧελϚΠ ζͰ͖Δ w σϑΥϧτ͸ɺ௚ۙϦΫΤετͰճҎ্Τϥʔ ͍ͯͨ͠Βɺ෼ؒ01&/ͱͳΔ w

    DJSDVJUCPYͷTUPSBHF Կճࣦഊ͔ͨ͠ͱ͔ ͸ɺ .POFUBͱ͍͏γϯϓϧͳLFZWBMVFTUPSFΛඪ४Ͱ ࢖༻͍ͯ͠Δ