isomorphic kotlin - jetbrainsheroku platform-as-a-service (paas) • supports php, python, node.js,...

53
@therockncoder Troy Miles Isomorphic Kotlin

Upload: others

Post on 21-May-2020

24 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •

@therockncoder Troy Miles

Isomorphic Kotlin

Page 2: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •

Troy Miles@therockncoderTroy Miles, aka the Rockncoder, began writing computer games in assembly language for early computers like the Apple II, Commodore C64, and the IBM PC over 38 years ago. Nowadays he writes web & mobile apps for a Southern California based automotive valuation and information company. Troy is fluent in JavaScript, C#, C++, Kotlin, and Clojure. Check out my Kotlin video:

https://www.lynda.com/Java-tutorials/Kotlin-Java-Developers/562926-2.html

He can be reached at: [email protected]

Page 3: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •

https://github.com/Rockncoder/rk1

The source code

Page 4: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •

FuelEconomy.govSource of the example data

Page 5: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •

the official government source for fuel economy information

Page 6: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •

FuelEconomy.gov

• Free vehicle information

• Source of MPG information

• Web service

• Download data in either XML or CSV

Page 7: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •
Page 8: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •

mongoimportImports data to MongoDBmongoimport -h dsXXXXXX.mlab.com:XXXXX -d users -c vehicle -u admin --file vehicles-1997.csv --type csv --columnsHaveTypes --fields "barrels08.double(),city08.double(),comb08.double(),cylinders.int32(),displ.double(),drive.string(),engId.int32(),eng_dscr.string(),fuelCost08.double(),fuelType.string(),highway08.double(),id.int32(),make.string(),model.string(),mpgData.string(),trany.string(),UCity.double(),UHighway.double(),VClass.string(),year.int32(),youSaveSpend.double(),guzzler.string(),trans_dscr.string(),createdOn.string(),modifiedOn.string()" --parseGrace skipField -p

Page 9: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •
Page 10: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •
Page 11: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •

Microservice

Page 12: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •

A service with one and only one, very narrowly focused capability

that a remote API exposes to the rest of the system.

Page 13: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •

MicroserviceKey ideas

• Runs in its own process

• Owns its data store

• Can be deployed on its own

• Can be written in different languages

Page 14: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •

Java Web FrameworksWhat do these all have in common?

• Spring MVC

• Struts 2

• JavaServer Faces (JSF)

• Play!

Page 15: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •

Java Microservice Frameworks

Source Info

• Spark aka. SparkJava

• Ratpack

Page 16: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •

Sparkaka SparkJava

Page 17: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •

A micro framework for creating web applications in Kotlin and

Java 8 with minimal effort

Page 18: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •

Spark aka SparkJava

http://sparkjava.com/

• Supports Java and Kotlin

• First released Feb 7, 2013

• Latest May 13, 2017, version 2.6.0

• Lots of docs and tutorials

Page 19: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •

Ratpack

Page 20: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •

Ratpack

https://ratpack.io/

Lean & powerful HTTP apps

• Supports Groovy, Java and Kotlin

• First released Jul 21, 2012

• Latest release Sept. 3, 2017, version 1.5.0

• Lots of docs but not a lot of examples

Page 21: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •

RESTful API

• Defined by RFC 2616 protocol

• Preferred over SOAP since it uses less bandwidth

• Breaks down a transaction into a series of HTTP methods

• Stateless by design

Page 22: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •

GET MethodGET /resource

Request has body No

Successful response has body Yes

Safe Yes

Idempotent Yes

Cacheable Yes

Page 23: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •

HEAD MethodHEAD /resource (HEAD * )

Request has body No

Successful response has body No

Safe Yes

Idempotent Yes

Cacheable Yes

Page 24: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •

POST MethodPOST /resource

Request has body Yes

Successful response has body Yes

Safe No

Idempotent No

Cacheable No*

Page 25: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •

PUT MethodPUT /new-resource

Request has body Yes

Successful response has body No

Safe No

Idempotent Yes

Cacheable No

Page 26: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •

PATCH MethodPATCH /resource

Request has body Yes

Successful response has body No

Safe No

Idempotent No

Cacheable No

Page 27: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •

DELETE MethodDELETE /resource

Request has body No

Successful response has body No

Safe No

Idempotent Yes

Cacheable No

Page 28: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •

OPTIONS MethodOPTIONS /resource

Request has body No

Successful response has body Yes

Safe Yes

Idempotent No

Cacheable No

Page 29: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •
Page 30: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •
Page 31: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •
Page 32: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •
Page 33: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •
Page 34: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •
Page 35: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •
Page 36: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •
Page 37: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •
Page 38: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •

MongoDB

Page 39: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •

MongoDB

• Document Database

• High Performance

• High Availability

• Easy Scalability

• Geospatial Data

Page 40: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •

Top DB Engines

https://db-engines.com/en/ranking

October 2017

1. Oracle

2. MySQL

3. MS SQL Server

4. PostgreSQL

5. MongoDB

Page 41: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •

SQL to MongoDB

SQL MongoDB

column field

row document

table collection

database database

joins none

transactions none

Page 42: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •

CRUD Operations

https://db-engines.com/en/ranking

• Create: insert()

• Read: find()

• Update: update()

• Delete: remove(<query>)

Page 43: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •

Query Modifiers

https://db-engines.com/en/ranking

• db.<collection name>.find(<query>)

• skip()

• take()

• sort()

• pretty()

Page 44: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •

KMongo

http://litote.org/kmongo/

A Kotlin toolkit for Mongo

• Wraps the MongoDB Java driver

• Converts objects from JSON to KOJO

Page 45: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •

mLab

Page 46: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •

mLabthe leading Database-as-a-Service for MongoDB• Database as a Service (DaaS) provider

• Supports AWS, Azure, App Engine

• Used by Fox, New York Times, Lyft, Toyota, SAP

Page 47: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •

Heroku

Page 48: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •

HerokuPlatform-as-a-Service (PaaS)

• Supports PHP, Python, Node.js, Java, Scala, and Go

• Runs on top of AWS

• Bought by Salesforce in 2010

• Runs instances which require very little configuration

• heroic + haiku = heroku

Page 49: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •

Setupfree developer account

• Have Git installed

• Create a free Heroku account

• Install the Heroku CLI

• brew install heroku/brew/heroku

Page 50: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •

Deployment

• heroku login

• heroku create <app-name> (must be unique)

• git push heroku master

• heroku open

Page 51: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •
Page 52: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •

Live DemoCross your fingers…

Page 53: Isomorphic Kotlin - JetBrainsHeroku Platform-as-a-Service (PaaS) • Supports PHP, Python, Node.js, Java, Scala, and Go • Runs on top of AWS • Bought by Salesforce in 2010 •

#kotlinconf17

@therockncoderTroy Miles

Thank you!