Download - Coimbra rb | microservic'ing and sinatra
![Page 2: Coimbra rb | microservic'ing and sinatra](https://reader033.vdocument.in/reader033/viewer/2022052504/548761fcb4af9f9b0d8b544d/html5/thumbnails/2.jpg)
prolinkedcare & mylinkedcare medic & patient
![Page 3: Coimbra rb | microservic'ing and sinatra](https://reader033.vdocument.in/reader033/viewer/2022052504/548761fcb4af9f9b0d8b544d/html5/thumbnails/3.jpg)
prolinkedcare app
• Electronic Prescription
• Video Consultation
• Electronic Health Record
• Schedule
![Page 4: Coimbra rb | microservic'ing and sinatra](https://reader033.vdocument.in/reader033/viewer/2022052504/548761fcb4af9f9b0d8b544d/html5/thumbnails/4.jpg)
mylinkedcare app
• Physical Activity Tracking
• Vital and Biometric Data
• Medication Alarms
• Appointment Scheduling
![Page 5: Coimbra rb | microservic'ing and sinatra](https://reader033.vdocument.in/reader033/viewer/2022052504/548761fcb4af9f9b0d8b544d/html5/thumbnails/5.jpg)
Medic & Patient Link
• Shared Electronic Heath Record
• Automatic Medication Alarms on prescriptions
• Video Appointments between apps
![Page 6: Coimbra rb | microservic'ing and sinatra](https://reader033.vdocument.in/reader033/viewer/2022052504/548761fcb4af9f9b0d8b544d/html5/thumbnails/6.jpg)
Pro My
Schedule
Bio & Vital
Sensors
Medication
Prescription Report
Analytics
Reference Data
UID
Linkedcare Services
![Page 7: Coimbra rb | microservic'ing and sinatra](https://reader033.vdocument.in/reader033/viewer/2022052504/548761fcb4af9f9b0d8b544d/html5/thumbnails/7.jpg)
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
![Page 8: Coimbra rb | microservic'ing and sinatra](https://reader033.vdocument.in/reader033/viewer/2022052504/548761fcb4af9f9b0d8b544d/html5/thumbnails/8.jpg)
Topologies
Service Oriented Design Behind linkedcare’s micro services
![Page 9: Coimbra rb | microservic'ing and sinatra](https://reader033.vdocument.in/reader033/viewer/2022052504/548761fcb4af9f9b0d8b544d/html5/thumbnails/9.jpg)
Service Oriented Design Behind linkedcare’s micro services
Client
ScheduleBio & Vital SensorsUID
Pro
• Current topology;
• Micro services control well defined and secure;
• Best for monolithic to service oriented design;
• Single point of failure;
• Latency.
![Page 10: Coimbra rb | microservic'ing and sinatra](https://reader033.vdocument.in/reader033/viewer/2022052504/548761fcb4af9f9b0d8b544d/html5/thumbnails/10.jpg)
Service Oriented Design Behind linkedcare’s micro services
!!
ScheduleBio & Vital SensorsUID
Client
• Future topology;
Pro
• Client controls micro services;
• “There’s no more” a single point of failure;
• Latency;
• Exposed micro services.
![Page 11: Coimbra rb | microservic'ing and sinatra](https://reader033.vdocument.in/reader033/viewer/2022052504/548761fcb4af9f9b0d8b544d/html5/thumbnails/11.jpg)
Service Oriented Design Behind linkedcare’s micro services
!
3 rules to build a micro service @linkedcare
![Page 12: Coimbra rb | microservic'ing and sinatra](https://reader033.vdocument.in/reader033/viewer/2022052504/548761fcb4af9f9b0d8b544d/html5/thumbnails/12.jpg)
Service Oriented Design Behind linkedcare’s micro services
!
• Small services with small tasks;• Well defined boundaries;
• Business logic for who needs it;
![Page 13: Coimbra rb | microservic'ing and sinatra](https://reader033.vdocument.in/reader033/viewer/2022052504/548761fcb4af9f9b0d8b544d/html5/thumbnails/13.jpg)
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.
![Page 14: Coimbra rb | microservic'ing and sinatra](https://reader033.vdocument.in/reader033/viewer/2022052504/548761fcb4af9f9b0d8b544d/html5/thumbnails/14.jpg)
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..
![Page 15: Coimbra rb | microservic'ing and sinatra](https://reader033.vdocument.in/reader033/viewer/2022052504/548761fcb4af9f9b0d8b544d/html5/thumbnails/15.jpg)
Service Oriented Design Behind linkedcare’s micro services
!
• Isolation;
The goods
• Surviving lost of functionality;
• Scalability.
• …
Ruby doesn’t scale, but services do!
![Page 16: Coimbra rb | microservic'ing and sinatra](https://reader033.vdocument.in/reader033/viewer/2022052504/548761fcb4af9f9b0d8b544d/html5/thumbnails/16.jpg)
Service Oriented Design Behind linkedcare’s micro services
!
• Distributed system complexity;
The “not so” goods
• Dev Ops overhead;
• Synchronization;
• …
![Page 17: Coimbra rb | microservic'ing and sinatra](https://reader033.vdocument.in/reader033/viewer/2022052504/548761fcb4af9f9b0d8b544d/html5/thumbnails/17.jpg)
!
!
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
![Page 18: Coimbra rb | microservic'ing and sinatra](https://reader033.vdocument.in/reader033/viewer/2022052504/548761fcb4af9f9b0d8b544d/html5/thumbnails/18.jpg)
1. gem install ‘sinatra’
Sinatra rb Behind linkedcare’s micro services
3. ruby app.rb
require ‘sinatra’ !get ‘/’ do “Hello!” end
2.
![Page 19: Coimbra rb | microservic'ing and sinatra](https://reader033.vdocument.in/reader033/viewer/2022052504/548761fcb4af9f9b0d8b544d/html5/thumbnails/19.jpg)
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
![Page 20: Coimbra rb | microservic'ing and sinatra](https://reader033.vdocument.in/reader033/viewer/2022052504/548761fcb4af9f9b0d8b544d/html5/thumbnails/20.jpg)
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
![Page 21: Coimbra rb | microservic'ing and sinatra](https://reader033.vdocument.in/reader033/viewer/2022052504/548761fcb4af9f9b0d8b544d/html5/thumbnails/21.jpg)
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” goodsFor Rails only devs
![Page 22: Coimbra rb | microservic'ing and sinatra](https://reader033.vdocument.in/reader033/viewer/2022052504/548761fcb4af9f9b0d8b544d/html5/thumbnails/22.jpg)
Inside a Sinatra App Behind linkedcare’s micro services
erb :index # renders ./views/index.erb
erb :"home/index" # renders ./views/home/index.erb
VIEWS
![Page 23: Coimbra rb | microservic'ing and sinatra](https://reader033.vdocument.in/reader033/viewer/2022052504/548761fcb4af9f9b0d8b544d/html5/thumbnails/23.jpg)
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
![Page 24: Coimbra rb | microservic'ing and sinatra](https://reader033.vdocument.in/reader033/viewer/2022052504/548761fcb4af9f9b0d8b544d/html5/thumbnails/24.jpg)
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
![Page 25: Coimbra rb | microservic'ing and sinatra](https://reader033.vdocument.in/reader033/viewer/2022052504/548761fcb4af9f9b0d8b544d/html5/thumbnails/25.jpg)
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
![Page 26: Coimbra rb | microservic'ing and sinatra](https://reader033.vdocument.in/reader033/viewer/2022052504/548761fcb4af9f9b0d8b544d/html5/thumbnails/26.jpg)
Inside a Sinatra App Behind linkedcare’s micro services
APP STRUCTURE
Classic Style vs Modular Style
![Page 27: Coimbra rb | microservic'ing and sinatra](https://reader033.vdocument.in/reader033/viewer/2022052504/548761fcb4af9f9b0d8b544d/html5/thumbnails/27.jpg)
Inside a Sinatra App Behind linkedcare’s micro services
CLASSIC | APP STRUCTURE
• require ‘sinatra’
• Uses the TOP Level DSL included when required;
!
![Page 28: Coimbra rb | microservic'ing and sinatra](https://reader033.vdocument.in/reader033/viewer/2022052504/548761fcb4af9f9b0d8b544d/html5/thumbnails/28.jpg)
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.
!
![Page 29: Coimbra rb | microservic'ing and sinatra](https://reader033.vdocument.in/reader033/viewer/2022052504/548761fcb4af9f9b0d8b544d/html5/thumbnails/29.jpg)
Sinatra rb Behind linkedcare’s micro services
DEMO?
![Page 30: Coimbra rb | microservic'ing and sinatra](https://reader033.vdocument.in/reader033/viewer/2022052504/548761fcb4af9f9b0d8b544d/html5/thumbnails/30.jpg)
Microservic’ing and Sinatra @linkedcare
The nice conclusion
Right now, it’s the best solution for our project!
![Page 31: Coimbra rb | microservic'ing and sinatra](https://reader033.vdocument.in/reader033/viewer/2022052504/548761fcb4af9f9b0d8b544d/html5/thumbnails/31.jpg)
Microservic’ing and Sinatra @linkedcareSome 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
![Page 32: Coimbra rb | microservic'ing and sinatra](https://reader033.vdocument.in/reader033/viewer/2022052504/548761fcb4af9f9b0d8b544d/html5/thumbnails/32.jpg)
Backshops linkedcare
![Page 33: Coimbra rb | microservic'ing and sinatra](https://reader033.vdocument.in/reader033/viewer/2022052504/548761fcb4af9f9b0d8b544d/html5/thumbnails/33.jpg)
JOBS linkedcare
http://linkedcare.com/jobs.html