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

I am altering the deal

I am altering the deal

Imagine your legacy production Ruby application is highly dependent on a third-party API — until you learn your vendor deprecates your current connection. What do you do when you’re forced to make a change? Accept the challenge by embracing abstractions, switching libraries, feature flags, edge-case testing while developing new features. Game on.

Focuses on: Famous example of third-party dependencies that have broken application; Abstracting the API interaction; Utilizing Ruby switching libraries; Feature flagging; Testing for edge cases (QA & customer service); and much more!

Brittany Martin

February 18, 2020
Tweet

More Decks by Brittany Martin

Other Decks in Technology

Transcript

  1. I AM ALTERING THE DEAL (PRAY I DON’T ALTER IT

    FURTHER) Brittany Martin parisRB 2020 Brittany Martin @BrittJMartin
  2. Host 5 B Y 5 R U B Y O

    N R A I L S P O D C A S T Brittany Martin @BrittJMartin
  3. Norma Skates L I T T L E S T

    E E L D E R B Y G I R L S Brittany Martin @BrittJMartin
  4. 3rd Party Dependencies C R E D I T :

    M e d i a c l i p Brittany Martin @BrittJMartin
  5. Do they always behave? C R E D I T

    : T H E F O U N D Brittany Martin @BrittJMartin
  6. C R E D I T : H i C

    l i p a r t S T R AT E G Y Brittany Martin @BrittJMartin
  7. Strong Customer Authentication C R E D I T :

    P Y M N T S . C O M Brittany Martin @BrittJMartin
  8. Payments Intent C R E D I T : M

    O L p a y Brittany Martin @BrittJMartin
  9. I N S TAG R A M C R E

    D I T : S e a r c h E n g i n e J o u r n a l Brittany Martin @BrittJMartin
  10. Graph API C R E D I T : S

    a n i t y Brittany Martin @BrittJMartin
  11. Rollback Hell C R E D I T : D

    e p l o y B o t Brittany Martin @BrittJMartin
  12. C R E D I T : S t a

    r W a r s Brittany Martin @BrittJMartin
  13. C R E D I T : A t l

    a s s i a n Brittany Martin @BrittJMartin
  14. AutomateTesting C R E D I T : C h

    a r u d e a l Brittany Martin @BrittJMartin
  15. Performance C R E D I T : A b

    d u l R a h m a n Brittany Martin @BrittJMartin
  16. Perform. C R E D I T : P i

    x a b a y Brittany Martin @BrittJMartin
  17. Ruby Community C R E D I T : J

    o n n y L e w Brittany Martin @BrittJMartin
  18. C R E D I T : G i t

    h u b , P i x a b a y Branch by Abstraction Brittany Martin @BrittJMartin
  19. Scientist G ITHU B C R E D I T

    : P i x a b a y Brittany Martin @BrittJMartin
  20. C R E D I T : G i t

    h u b Brittany Martin @BrittJMartin
  21. require "scientist" class MyWidget def allows?(user) experiment = Scientist::Default.new "widget-

    permissions" experiment.use { model.check_user? (user).valid? } # old way experiment.try { user.can?(:read, model) } # new way experiment.run end end C R E D I T : G i t h u b Brittany Martin @BrittJMartin
  22. VCR C R E D I T : B B

    C Brittany Martin @BrittJMartin
  23. C R E D I T : T e e

    P u b l i c Brittany Martin @BrittJMartin
  24. require 'rubygems' require 'test/unit' require 'vcr' VCR.configure do |config| config.cassette_library_dir

    = "fixtures/vcr_cassettes" config.hook_into :webmock end class VCRTest < Test::Unit::TestCase def test_example_dot_com VCR.use_cassette("synopsis") do response = Net::HTTP.get_response(URI('brittanymartin.dev")) assert end end end Brittany Martin @BrittJMartin
  25. B E N C H M A R K C

    R E D I T : S p r o u t S o c i a l Brittany Martin @BrittJMartin
  26. SOAP vs.Rest Brittany Martin @BrittJMartin Benchmark.bmbm(100) do |x| x.report("SOAP") {

    n.times do Webservices::Requests::GetNewSessionKeyRequest.new({:ip => '0.0.0.0'}).invoke.session_key end } x.report("REST") { n.times do Rest.new.create_session('0.0.0.0')['SessionKey'] end} end APIs called 100x each. Benchmark::Tms:0x00007ff17de18270 @label="SOAP", @real=3.547331999987364, @cstime=0.0, @cutime=0.0, @stime=0.09988699999999984, @utime=1.6087319999999998, @total=1.7086189999999997 Benchmark::Tms:0x00007ff17f596f50 @label="REST", @real=26.420482000001357, @cstime=0.0, @cutime=0.0, @stime=0.17270999999999992, @utime=1.5042220000000004, @total=1.6769320000000003 SOAP real-time = 3.547331999987364 REST real-time = 26.420482000001357 SOAP is 8x faster.
  27. C R E D I T : C o l

    l i s Brittany Martin @BrittJMartin
  28. Silver Linings. C R E D I T : 4

    D H u m a n B e i n g Brittany Martin @BrittJMartin
  29. C R E D I T : N Y T

    i m e s Brittany Martin @BrittJMartin
  30. B R E A K U P C R E

    D I T : V e r a A r s i c Brittany Martin @BrittJMartin
  31. Be Strong A V O I D N E G

    A T I V I T Y Brittany Martin @BrittJMartin
  32. C R E D I T : T e s

    T e a c h Brittany Martin @BrittJMartin