dropwizard - yo briefca › presentations › dropwizard.pdf · dropwizard is an exemplar for...

38
Dropwizard production ready restful web services…

Upload: others

Post on 07-Jul-2020

6 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: dropwizard - Yo Briefca › presentations › dropwizard.pdf · Dropwizard is an exemplar for ops-friendly, self contained, high performing, framework-less web service building technologies

Dropwizardproduction ready restful web services…

Page 2: dropwizard - Yo Briefca › presentations › dropwizard.pdf · Dropwizard is an exemplar for ops-friendly, self contained, high performing, framework-less web service building technologies

... for java… for java

Page 3: dropwizard - Yo Briefca › presentations › dropwizard.pdf · Dropwizard is an exemplar for ops-friendly, self contained, high performing, framework-less web service building technologies

preamble… the case for dropwizard

Page 4: dropwizard - Yo Briefca › presentations › dropwizard.pdf · Dropwizard is an exemplar for ops-friendly, self contained, high performing, framework-less web service building technologies

Dropwizard is an exemplar for ops-friendly, self contained, high performing, framework-less web service building technologies

Page 5: dropwizard - Yo Briefca › presentations › dropwizard.pdf · Dropwizard is an exemplar for ops-friendly, self contained, high performing, framework-less web service building technologies

… written in java

Page 6: dropwizard - Yo Briefca › presentations › dropwizard.pdf · Dropwizard is an exemplar for ops-friendly, self contained, high performing, framework-less web service building technologies

The concepts, principles & patterns contained herein can and should be applied to any services you build irrespective of technology or language

Page 7: dropwizard - Yo Briefca › presentations › dropwizard.pdf · Dropwizard is an exemplar for ops-friendly, self contained, high performing, framework-less web service building technologies

“micro service architecture”bit.ly/187C3Le

Page 8: dropwizard - Yo Briefca › presentations › dropwizard.pdf · Dropwizard is an exemplar for ops-friendly, self contained, high performing, framework-less web service building technologies

The rise of real service oriented architecture has meant that services are now an acceptable level of abstraction for defining system features

Page 9: dropwizard - Yo Briefca › presentations › dropwizard.pdf · Dropwizard is an exemplar for ops-friendly, self contained, high performing, framework-less web service building technologies

“ the world needs devops”

Page 10: dropwizard - Yo Briefca › presentations › dropwizard.pdf · Dropwizard is an exemplar for ops-friendly, self contained, high performing, framework-less web service building technologies

develop ⇝ deploy ⇝ disaster

a typical release pipeline

Page 11: dropwizard - Yo Briefca › presentations › dropwizard.pdf · Dropwizard is an exemplar for ops-friendly, self contained, high performing, framework-less web service building technologies

When things go smoothly our initial reaction is one of surprise followed by suspicion

Page 12: dropwizard - Yo Briefca › presentations › dropwizard.pdf · Dropwizard is an exemplar for ops-friendly, self contained, high performing, framework-less web service building technologies

develop ⇝ deploy ⇝ disasterits their fault!

they don’t get it!

what the hell is this

Page 13: dropwizard - Yo Briefca › presentations › dropwizard.pdf · Dropwizard is an exemplar for ops-friendly, self contained, high performing, framework-less web service building technologies

news flash!

Page 14: dropwizard - Yo Briefca › presentations › dropwizard.pdf · Dropwizard is an exemplar for ops-friendly, self contained, high performing, framework-less web service building technologies

You are not writing code for your own gratification

Page 15: dropwizard - Yo Briefca › presentations › dropwizard.pdf · Dropwizard is an exemplar for ops-friendly, self contained, high performing, framework-less web service building technologies

You are trying to make others lives better

Page 16: dropwizard - Yo Briefca › presentations › dropwizard.pdf · Dropwizard is an exemplar for ops-friendly, self contained, high performing, framework-less web service building technologies

Your code and infrastructure will fail a lot

Page 17: dropwizard - Yo Briefca › presentations › dropwizard.pdf · Dropwizard is an exemplar for ops-friendly, self contained, high performing, framework-less web service building technologies

You are not in competition with other departments

Page 18: dropwizard - Yo Briefca › presentations › dropwizard.pdf · Dropwizard is an exemplar for ops-friendly, self contained, high performing, framework-less web service building technologies

You need a shared understanding of system behaviour

Page 19: dropwizard - Yo Briefca › presentations › dropwizard.pdf · Dropwizard is an exemplar for ops-friendly, self contained, high performing, framework-less web service building technologies

DEAL WITH IT!

Page 20: dropwizard - Yo Briefca › presentations › dropwizard.pdf · Dropwizard is an exemplar for ops-friendly, self contained, high performing, framework-less web service building technologies

Dropwizard provides a set of features that enable you to build systems capable of adapting to, both, a changing business and operational domain

Page 21: dropwizard - Yo Briefca › presentations › dropwizard.pdf · Dropwizard is an exemplar for ops-friendly, self contained, high performing, framework-less web service building technologies

Dropwizardthe actual topic of the talk

Page 25: dropwizard - Yo Briefca › presentations › dropwizard.pdf · Dropwizard is an exemplar for ops-friendly, self contained, high performing, framework-less web service building technologies

Jetty

Jersey

Jackson

Metrics

HTTP Library

REST Library

JSON Processor

Instrumentation

Page 26: dropwizard - Yo Briefca › presentations › dropwizard.pdf · Dropwizard is an exemplar for ops-friendly, self contained, high performing, framework-less web service building technologies

Guava Immutable Collections & Utils

Logback

Freemarker & Mustache

JodaTime

Hibernate Validator

JDBI & Liquibase

Logging

Validation

Data Access & Migration

Templating

Non-Terrible Time

Page 27: dropwizard - Yo Briefca › presentations › dropwizard.pdf · Dropwizard is an exemplar for ops-friendly, self contained, high performing, framework-less web service building technologies

- Java is Java - Annotations are awful - Documentation is dispersed

The “Nobody’s Perfect”

Page 28: dropwizard - Yo Briefca › presentations › dropwizard.pdf · Dropwizard is an exemplar for ops-friendly, self contained, high performing, framework-less web service building technologies

1. Create Configuration YML & Class

2. Create the Service3. Create the Representation

4. Create & Register the Resource

5. Build & Run

Lets Build a Service!!!

Page 29: dropwizard - Yo Briefca › presentations › dropwizard.pdf · Dropwizard is an exemplar for ops-friendly, self contained, high performing, framework-less web service building technologies

I could have done this with Rails, Sinatra, Spring, Play, Finagle, Express, Nancy.…

So What?

Page 30: dropwizard - Yo Briefca › presentations › dropwizard.pdf · Dropwizard is an exemplar for ops-friendly, self contained, high performing, framework-less web service building technologies

The Admin ServerMetrics

Healthchecks

Page 31: dropwizard - Yo Briefca › presentations › dropwizard.pdf · Dropwizard is an exemplar for ops-friendly, self contained, high performing, framework-less web service building technologies

class DBManager implements Managed { public void start() { … } public void stop() { … } }

// register in Service.initialize() environment.manage(myDBManager)

Managed Objects

Page 32: dropwizard - Yo Briefca › presentations › dropwizard.pdf · Dropwizard is an exemplar for ops-friendly, self contained, high performing, framework-less web service building technologies

Commands

// register in Service.initalize() bootstrap.addCommand(myCommand)

> java -jar app.jar dingus

class DingusCommand implements Command { public void configure(parser) { … } public void run(bootstrap, ns) { … } }

Page 33: dropwizard - Yo Briefca › presentations › dropwizard.pdf · Dropwizard is an exemplar for ops-friendly, self contained, high performing, framework-less web service building technologies

Tasks// register in Service.run() environment.addTask(myTask)

> curl -X POST http://server/tasks/dingus

class DingusTask implements Task { public void execute(params, out) { … } }

Page 34: dropwizard - Yo Briefca › presentations › dropwizard.pdf · Dropwizard is an exemplar for ops-friendly, self contained, high performing, framework-less web service building technologies

Bundles

@Override public void initialize(bootstrap) { bootstrap.addBundle( new AssetsBundle("/assets/", "/")); }

Reusable modules of functionality

Page 35: dropwizard - Yo Briefca › presentations › dropwizard.pdf · Dropwizard is an exemplar for ops-friendly, self contained, high performing, framework-less web service building technologies

import static com.yammer.dropwizard .testing.JsonHelpers.*;

Testing (Fixtures)

!jsonFixture(“fixtures/person.json”) !fromJson(myFixture, Person.class) !asJson(person)

Page 36: dropwizard - Yo Briefca › presentations › dropwizard.pdf · Dropwizard is an exemplar for ops-friendly, self contained, high performing, framework-less web service building technologies

Testing (Resources)

client().resource(“user/1”).get(User.class)

public class MyTest extends ResourceTest { ! @Override protected void setUpResources() { addResource(...); } }

Page 37: dropwizard - Yo Briefca › presentations › dropwizard.pdf · Dropwizard is an exemplar for ops-friendly, self contained, high performing, framework-less web service building technologies

ViewsData Access

Authentication

MigrationsBanners

etc…

More Other Things & Stuff

Page 38: dropwizard - Yo Briefca › presentations › dropwizard.pdf · Dropwizard is an exemplar for ops-friendly, self contained, high performing, framework-less web service building technologies

Dropwizardproduction ready restful web services…