Slide 1

Slide 1 text

Sean Sullivan July 21, 2017 Scala Up North

Slide 2

Slide 2 text

• software engineer • 21 years on the JVM • back office systems @ HBC About me

Slide 3

Slide 3 text

https://en.wikipedia.org/wiki/Hudson%27s_Bay_Company

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

saksfifthavenue.com saksoff5th.com lordandtaylor.com gilt.com thebay.com

Slide 6

Slide 6 text

API driven development

Slide 7

Slide 7 text

API descriptors

Slide 8

Slide 8 text

API descriptors are not a new concept

Slide 9

Slide 9 text

• 2000: WSDL 1.0 (SOAP) • 2006: WADL (REST) • 2011: Swagger (REST) • 2014: ApiDoc (REST) • 2017: ApiDoc rebranded to ApiBuilder

Slide 10

Slide 10 text

www.apibuilder.io

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

describe REST API in a JSON file

Slide 13

Slide 13 text

1. start by describing your models 2. map your models to resources

Slide 14

Slide 14 text

"models": { "credit_card": { "fields": [ { "name": "guid", "type": "uuid" }, { "name": "user_guid", "type": "uuid" }, { "name": "type", "type": "credit_card_type" }, { "name": "issuer", "type": “string", “required": false }, { "name": "last_four", "type": "string" }, { "name": "expire_date", "type": "string" }, { "name": "billing_address", "type": "address" } ] } }

Slide 15

Slide 15 text

"resources": { "credit_card": { "operations": [ { "method": "GET", "path": "/:guid", "description": "Get a credit card.", "responses": { "200": { "type": "credit_card" }, "404": { "type": “unit”, "description": "Card not found." } } } }

Slide 16

Slide 16 text

gilt.com

Slide 17

Slide 17 text

www.gilt.com

Slide 18

Slide 18 text

• Rails app • one Git repo • monolith! Gilt: 2007 => 2008

Slide 19

Slide 19 text

• Rails app • JSP web framework • ~10 services (Java) • handcrafted Java clients • weak typing (java.util.HashMap) Gilt: 2009 => 2010

Slide 20

Slide 20 text

• JSP’s • 100+ services (Java, Scala) • strongly typed client libraries • Gilt “Commons” library Gilt: 2011 => 2013

Slide 21

Slide 21 text

• Gilt Commons library • 250+ services • binary coupling • dependency hell • ApiBuilder project started on Github Gilt: 2014

Slide 22

Slide 22 text

Dependency hell Java runtime hell

Slide 23

Slide 23 text

• java.lang.NoClassDefFoundError • java.lang.NoSuchFieldError • java.lang.NoSuchMethodError Java runtime hell

Slide 24

Slide 24 text

Dependency hell kills productivity

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

Mitigating dependency hell • API design must be first class • backwards and forward compatibility • accurate documentation • generated client libraries

Slide 27

Slide 27 text

• 350+ services • new services built with ApiBuilder + generated clients • Gilt Commons library is deprecated Gilt: 2015 => 2017

Slide 28

Slide 28 text

Web Checkout Android Checkout iPhone Checkout Checkout service api.json

Slide 29

Slide 29 text

Generating client libraries with ApiBuilder

Slide 30

Slide 30 text

Code generators

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

Scala client generators • Http4s + Circe JSON • Ning AsyncHttpClient {1.8, 1.9} • Play WS {2.2, 2.3, 2.4, 2.5, 2.6}

Slide 33

Slide 33 text

No content

Slide 34

Slide 34 text

Conclusion • API driven development • visit www.apibuilder.io

Slide 35

Slide 35 text

The end

Slide 36

Slide 36 text

No content

Slide 37

Slide 37 text

Bonus material

Slide 38

Slide 38 text

Gilt 2015