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

circuit_switch: small start to create gem

makicamel
October 10, 2021

circuit_switch: small start to create gem

at 2021.10.10. Kaigi on Rails _2021_ new

makicamel

October 10, 2021
Tweet

More Decks by makicamel

Other Decks in Programming

Transcript

  1. •ϦϦʔε͸िʹ 1 ճ •100ʙ200 Pull Requests •500ʙ1,000 commits •10Kʙ60K lines

    ˞ ϏοάόϯϦϦʔε 
 ˞Ұ൪ݹ͘ػೳ͕ଟ͍ϞϊϦγοΫϦϙδτϦʹ͓͚Δ਺ɻଟ͘ͷଞϦϙδτϦ͸΋ͬͱԺ΍͔Ͱ͢ 
 ˞ো֐ରԠΛআ͘ ˞
  2. circuit_switch  •CircuitSwitch ͕։͍͍ͯΔ࣌ do_something_experimental ΛݺͿ •CircuitSwitch ͕ด͡ΒΕͨ࣌ call_existing_codes ΛݺͿ

    if CircuitSwitch.open?(close_if_reach_limit: false) do_something_experimental else call_existing_codes end
  3. circuit_switch •CircuitSwitch ͷ։ด৚݅  if CircuitSwitch.open?(reach_limit: 100) do_something_experimental else call_existing_codes

    end نఆ্ݶճ਺ʹ౸ୡ ։์৚݅ͱҰக ด࠯৚݅ͱҰக ৗ࣮࣌ߦʴڧ੍ด࠯
  4. circuit_switch  if CircuitSwitch.open?(if: current_user.testing?) do_something_experimental else call_existing_codes end •CircuitSwitch

    ͷ։ด৚݅ نఆ্ݶճ਺ʹ౸ୡ ։์৚݅ͱҰக ด࠯৚݅ͱҰக ৗ࣮࣌ߦʴڧ੍ด࠯
  5. circuit_switch  if CircuitSwitch.open?( close_if: Date.today > some_period ) do_something_experimental

    else call_existing_codes end •CircuitSwitch ͷ։ด৚݅ نఆ্ݶճ਺ʹ౸ୡ ։์৚݅ͱҰக ด࠯৚݅ͱҰக ৗ࣮࣌ߦʴڧ੍ด࠯
  6. circuit_switch   rake circuit_switch:terminate_to_run 
 [/app/services/greetings_service:21 block 
 in

    validate] •CircuitSwitch ͷ։ด৚݅ if CircuitSwitch.open?(close_if_reach_limit: false) do_something_experimental else call_existing_codes end نఆ্ݶճ਺ʹ౸ୡ ։์৚݅ͱҰக ด࠯৚݅ͱҰக ৗ࣮࣌ߦʴڧ੍ด࠯
  7. circuit_switch  CircuitSwitch.report(if: unexpected_happen) •CircuitSwitch ͕։͍͍ͯΔ࣌ report ΛૹΔ •Slack ΍

    Bugsnag ͳͲ೚ҙͷϨϙʔτπʔϧΛࢦఆ •։ด৚݅͸ open? ͱྨࣅͷ৚݅Λࢦఆ
  8. Feature Toggles •৽ػೳΛಛఆϢʔβʹ҆શɾ଎΍͔ʹఏڙ͢ΔͨΊͷ࢓૊Έ •ؔ࿈ɿDark Launch •🙅 େن໛ feature ϒϥϯν্Ͱͷ։ൃ 


    🙆 master(main) ϒϥϯνʹ߹ྲྀͨ͠։ൃ 'FBUVSF5PHHMFTNBSUJOGPXMFSDPN 
 IUUQTNBSUJOGPXMFSDPNBSUJDMFTGFBUVSFUPHHMFTIUNM