microservic’ing with sinatra
@linkedcare
Joaquim Adráz
and
mrbessa
joaquimadraz & croudcare
joaquim.adraz@linkedcare.com@
prolinkedcare & mylinkedcare
medic & patient
prolinkedcare app
• Electronic Prescription
• Video Consultation
• Electronic Health
Record
• Schedule
mylinkedcare app
• Physical Activity
Tracking
• Vital and Biometric Data
• Medication Alarms
• Appointment
Scheduling
Medic & Patient Link
• Shared Electronic Heath Record
• Automatic Medication Alarms on prescriptions
• Video Appointments ...
Pro My
Schedule
Bio &
Vital
Sensors
Medication
Prescription
Report
Analytics
Reference
Data
UID
Linkedcare Services
Service Oriented Design
Behind linkedcare’s micro services
!
“The goal of SOD is to split up the parts of an
application i...
Topologies
Service Oriented Design
Behind linkedcare’s micro services
Service Oriented Design
Behind linkedcare’s micro services
Client
Schedule
Bio &
Vital
SensorsUID
Pro
• Current topology;
...
Service Oriented Design
Behind linkedcare’s micro services
!
!
Schedule
Bio &
Vital
SensorsUID
Client
• Future topology;
P...
Service Oriented Design
Behind linkedcare’s micro services
!
3 rules to build a micro service @linkedcare
Service Oriented Design
Behind linkedcare’s micro services
!
• Small services with small tasks;
• Well defined boundaries;
...
Service Oriented Design
Behind linkedcare’s micro services
!
• Use well known standards and conventions;
• RESTful APIs:
•...
Service Oriented Design
Behind linkedcare’s micro services
!
• Use only the necessary tools for the job.
• We want MICRO S...
Service Oriented Design
Behind linkedcare’s micro services
!
• Isolation;
The goods
• Surviving lost of functionality;
• S...
Service Oriented Design
Behind linkedcare’s micro services
!
• Distributed system complexity;
The “not so” goods
• Dev Ops...
!
!
Sinatra rb
"Sinatra is a DSL for quickly creating web
applications in Ruby with minimal effort"
The right tool(s) for ...
1. gem install ‘sinatra’
Sinatra rb
Behind linkedcare’s micro services
3. ruby app.rb
require ‘sinatra’
!
get ‘/’ do
“Hell...
Sinatra rb
Behind linkedcare’s micro services
[2014-05-15 21:00:00] INFO WEBrick 1.3.1
[2014-05-15 21:00:00] INFO ruby 1.9...
Sinatra rb
Behind linkedcare’s micro services
• Sinatra is written over 2000 lines of code, it’s 1%
of Rails;
• Fast, flexi...
Sinatra rb
Behind linkedcare’s micro services
• It’s pure Ruby, all Rails magic its gone;
• Structuring an app can bring s...
Inside a Sinatra App
Behind linkedcare’s micro services
erb :index # renders ./views/index.erb
erb :"home/index" # renders...
Inside a Sinatra App
Behind linkedcare’s micro services
ROUTING
get '/hello/:name' do
# matches "GET /hello/foo" and "GET ...
Inside a Sinatra App
Behind linkedcare’s micro services
ROUTING
delete '/event/:id' do
# matches "DELETE /event/1"
end
put...
Inside a Sinatra App
Behind linkedcare’s micro services
HELPERS
require 'sinatra'
!
get '/:color' do
"<b>#{color_world(par...
Inside a Sinatra App
Behind linkedcare’s micro services
APP STRUCTURE
Classic Style vs Modular Style
Inside a Sinatra App
Behind linkedcare’s micro services
CLASSIC | APP STRUCTURE
• require ‘sinatra’
• Uses the TOP Level D...
Inside a Sinatra App
Behind linkedcare’s micro services
MODULAR | APP STRUCTURE
• require ‘sinatra/base’
• DSL it’s not in...
Sinatra rb
Behind linkedcare’s micro services
DEMO?
Microservic’ing and Sinatra
@linkedcare
The nice conclusion
Right now, it’s the best solution for our project!
Microservic’ing and Sinatra
@linkedcare
Some tips
LinkedBus => Ruby RabbitMQ Subscriber
https://github.com/tdantas/linkedb...
Backshops linkedcare
JOBS linkedcare
http://linkedcare.com/jobs.html
microservic’ing with sinatra
@linkedcare
Joaquim Adráz
mrbessa
joaquimadraz & croudcare
joaquim.adraz@linkedcare.com@
and
Upcoming SlideShare
Loading in …5
×

Coimbra rb | microservic'ing and sinatra

2,350 views

Published on

Published in: Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
2,350
On SlideShare
0
From Embeds
0
Number of Embeds
18
Actions
Shares
0
Downloads
7
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Coimbra rb | microservic'ing and sinatra

  1. 1. microservic’ing with sinatra @linkedcare Joaquim Adráz and mrbessa joaquimadraz & croudcare joaquim.adraz@linkedcare.com@
  2. 2. prolinkedcare & mylinkedcare medic & patient
  3. 3. prolinkedcare app • Electronic Prescription • Video Consultation • Electronic Health Record • Schedule
  4. 4. mylinkedcare app • Physical Activity Tracking • Vital and Biometric Data • Medication Alarms • Appointment Scheduling
  5. 5. Medic & Patient Link • Shared Electronic Heath Record • Automatic Medication Alarms on prescriptions • Video Appointments between apps
  6. 6. Pro My Schedule Bio & Vital Sensors Medication Prescription Report Analytics Reference Data UID Linkedcare Services
  7. 7. Service Oriented Design Behind linkedcare’s micro services ! “The goal of SOD is to split up the parts of an application into components that can be iterated on, improved and fixed…” Service Oriented Design with ROR Book by Paul Dix
  8. 8. Topologies Service Oriented Design Behind linkedcare’s micro services
  9. 9. Service Oriented Design Behind linkedcare’s micro services Client Schedule Bio & Vital SensorsUID Pro • Current topology; • Micro services control well defined and secure; • Best for monolithic to service oriented design; • Single point of failure; • Latency.
  10. 10. Service Oriented Design Behind linkedcare’s micro services ! ! Schedule Bio & Vital SensorsUID Client • Future topology; Pro • Client controls micro services; • “There’s no more” a single point of failure; • Latency; • Exposed micro services.
  11. 11. Service Oriented Design Behind linkedcare’s micro services ! 3 rules to build a micro service @linkedcare
  12. 12. Service Oriented Design Behind linkedcare’s micro services ! • Small services with small tasks; • Well defined boundaries; • Business logic for who needs it;
  13. 13. Service Oriented Design Behind linkedcare’s micro services ! • Use well known standards and conventions; • RESTful APIs: • Standard HTTP methods; • One does not simply use POST /v1/events/1 to delete an event; • Use HTTP Status Codes, and everything will be 200.
  14. 14. Service Oriented Design Behind linkedcare’s micro services ! • Use only the necessary tools for the job. • We want MICRO Services; • Lightweight and flexible systems; • Sinatra is one of them..
  15. 15. Service Oriented Design Behind linkedcare’s micro services ! • Isolation; The goods • Surviving lost of functionality; • Scalability. • … Ruby doesn’t scale, but services do!
  16. 16. Service Oriented Design Behind linkedcare’s micro services ! • Distributed system complexity; The “not so” goods • Dev Ops overhead; • Synchronization; • …
  17. 17. ! ! Sinatra rb "Sinatra is a DSL for quickly creating web applications in Ruby with minimal effort" The right tool(s) for the job* Behind linkedcare’s micro services
  18. 18. 1. gem install ‘sinatra’ Sinatra rb Behind linkedcare’s micro services 3. ruby app.rb require ‘sinatra’ ! get ‘/’ do “Hello!” end 2.
  19. 19. Sinatra rb Behind linkedcare’s micro services [2014-05-15 21:00:00] INFO WEBrick 1.3.1 [2014-05-15 21:00:00] INFO ruby 1.9.3 (2013-06-27) [x86_64-darwin12.5.0] == Sinatra/1.4.4 has taken the stage on 4567 for development with backup from WEBrick [2014-05-15 21:00:00] INFO WEBrick::HTTPServer#start: pid=5343 port=4567
  20. 20. Sinatra rb Behind linkedcare’s micro services • Sinatra is written over 2000 lines of code, it’s 1% of Rails; • Fast, flexible and light… like our micro services should be; • Active Record, Rake tasks, Rspec, Bundler… it’s all available. The goods
  21. 21. Sinatra rb Behind linkedcare’s micro services • It’s pure Ruby, all Rails magic its gone; • Structuring an app can bring some pain; • There are some gems that only work well with Rails. The “not so” goods For Rails only devs
  22. 22. Inside a Sinatra App Behind linkedcare’s micro services erb :index # renders ./views/index.erb erb :"home/index" # renders ./views/home/index.erb VIEWS
  23. 23. Inside a Sinatra App Behind linkedcare’s micro services ROUTING get '/hello/:name' do # matches "GET /hello/foo" and "GET /hello/bar" # params[:name] is 'foo' or 'bar' "Hello #{params[:name]}!"! end post '/say/*/to/*' do # matches post /say/hello/to/world params[:splat] # => ["hello", "world"] end
  24. 24. Inside a Sinatra App Behind linkedcare’s micro services ROUTING delete '/event/:id' do # matches "DELETE /event/1" end put '/event/:id' do # matches "PUT /event/1" end
  25. 25. Inside a Sinatra App Behind linkedcare’s micro services HELPERS require 'sinatra' ! get '/:color' do "<b>#{color_world(params[:color])} world!</b>" end ! helpers do def color_world(red) red == "red" ? "red" : "yellow" end end
  26. 26. Inside a Sinatra App Behind linkedcare’s micro services APP STRUCTURE Classic Style vs Modular Style
  27. 27. Inside a Sinatra App Behind linkedcare’s micro services CLASSIC | APP STRUCTURE • require ‘sinatra’ • Uses the TOP Level DSL included when required; !
  28. 28. Inside a Sinatra App Behind linkedcare’s micro services MODULAR | APP STRUCTURE • require ‘sinatra/base’ • DSL it’s not included in Object. • class MyApp < Sinatra::Base • DSL available inside MyApp object. !
  29. 29. Sinatra rb Behind linkedcare’s micro services DEMO?
  30. 30. Microservic’ing and Sinatra @linkedcare The nice conclusion Right now, it’s the best solution for our project!
  31. 31. Microservic’ing and Sinatra @linkedcare Some tips LinkedBus => Ruby RabbitMQ Subscriber https://github.com/tdantas/linkedbus SmoothOperator => Lightweight and flexible alternative to ActiveResource, https://github.com/goncalvesjoao/smooth_operator UseCasing => Responsability Centric Design with use cases https://github.com/tdantas/usecasing
  32. 32. Backshops linkedcare
  33. 33. JOBS linkedcare http://linkedcare.com/jobs.html
  34. 34. microservic’ing with sinatra @linkedcare Joaquim Adráz mrbessa joaquimadraz & croudcare joaquim.adraz@linkedcare.com@ and

×