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

Dropwizard - Production Ready Web Services

0b2600a627d0af06ca6bbf9abe4067af?s=47 James Hughes
November 06, 2013

Dropwizard - Production Ready Web Services

Dropwizard is a tool for building RESTful web services using mature and well understood libraries and technologies for the JVM. It not only provides a stack that enables rapid development of services but also actively encourages production-ready solutions with inclusion of ops focused technologies such as metrics, logging and configuration baked in.

0b2600a627d0af06ca6bbf9abe4067af?s=128

James Hughes

November 06, 2013
Tweet

More Decks by James Hughes

Other Decks in Programming

Transcript

  1. Dropwizard production ready restful web services…

  2. ... for java … for java

  3. preamble … the case for dropwizard

  4. Dropwizard is an exemplar for ops-friendly, self contained, high performing,

    framework-less web service building technologies
  5. … written in java

  6. The concepts, principles & patterns contained herein can and should

    be applied to any services you build irrespective of technology or language
  7. “micro service architecture” bit.ly/187C3Le

  8. The rise of real service oriented architecture has meant that

    services are now an acceptable level of abstraction for defining system features
  9. “ the world needs devops”

  10. develop ⇝ deploy ⇝ disaster a typical release pipeline

  11. When things go smoothly our initial reaction is one of

    surprise followed by suspicion
  12. develop ⇝ deploy ⇝ disaster its their fault! they don’t

    get it! what the hell is this
  13. news flash!

  14. You are not writing code for your own gratification

  15. You are trying to make others lives better

  16. Your code and infrastructure will fail a lot

  17. You are not in competition with other departments

  18. You need a shared understanding of system behaviour

  19. DEAL WITH IT!

  20. Dropwizard provides a set of features that enable you to

    build systems capable of adapting to, both, a changing business and operational domain
  21. Dropwizard the actual topic of the talk

  22. Dropwizard is a Java framework for developing ops-friendly, high- performance,

    RESTful web services. http://dropwizard.io
  23. A damn simple library for building production-ready RESTful web services

    github.com/dropwizard/dropwizard
  24. It's a little bit of opinionated glue code which bangs

    together a set of libraries which have historically not sucked github.com/dropwizard/dropwizard
  25. Jetty Jersey Jackson Metrics HTTP Library REST Library JSON Processor

    Instrumentation
  26. Guava Immutable Collections & Utils Logback Freemarker & Mustache JodaTime

    Hibernate Validator JDBI & Liquibase Logging Validation Data Access & Migration Templating Non-Terrible Time
  27. - Java is Java - Annotations are awful - Documentation

    is dispersed The “Nobody’s Perfect”
  28. 1. Create Configuration YML & Class 2. Create the Service

    3. Create the Representation 4. Create & Register the Resource 5. Build & Run Lets Build a Service!!!
  29. I could have done this with Rails, Sinatra, Spring, Play,

    Finagle, Express, Nancy.… So What?
  30. The Admin Server Metrics Healthchecks

  31. class DBManager implements Managed { public void start() { …

    } public void stop() { … } } // register in Service.initialize() environment.manage(myDBManager) Managed Objects
  32. 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) { … } }
  33. Tasks // register in Service.run() environment.addTask(myTask) > curl -X POST

    http://server/tasks/dingus class DingusTask implements Task { public void execute(params, out) { … } }
  34. Bundles @Override public void initialize(bootstrap) { bootstrap.addBundle( new AssetsBundle("/assets/", "/"));

    } Reusable modules of functionality
  35. import static com.yammer.dropwizard .testing.JsonHelpers.*; Testing (Fixtures) ! jsonFixture(“fixtures/person.json”) ! fromJson(myFixture,

    Person.class) ! asJson(person)
  36. Testing (Resources) client().resource(“user/1”).get(User.class) public class MyTest extends ResourceTest { !

    @Override protected void setUpResources() { addResource(...); } }
  37. Views Data Access Authentication Migrations Banners etc… More Other Things

    & Stuff
  38. Dropwizard production ready restful web services…