SlideShare uma empresa Scribd logo
1 de 68
Baixar para ler offline
RUBYCONF 2015 MARCIO MANGARMICROSERVICES on RAILS
Microserviceson Rails
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
Agradecimento
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
Agenda
Microservices
Ruby on Rails
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
Apresentação
Marcio Mangar
@mangar
github.com/mangar
marcio.mangar [at] gmail.com
http://rga.com
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
Microserviços
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
O que são
Microserviços
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
Service Oriented Architecture
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
Aplicação Monolítica
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
Clientes Pedidos
Banco de Dados
def make()
Aplicação Monolitica
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
Clientes Pedidos
Banco de Dados
def make()
www.sistema
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
Clientes Pedidos
Banco de Dados
def make()
www.sistema cart.sistema search.sistema
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
Escalabilidade
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
X
Escalabilidade X
Clientes
Pedidos
Load Balancer
Clientes
Pedidos
Clientes
Pedidos
. . . . .
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
Aplicação com
Microserviços
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
Clientes
admin.clientes.
api.clientes.
www.clientes.
Pedidos
admin.pedidos.
api.pedidos.
www.pedidos.
Aplicação com Microserviços
Banco de Dados
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
Comunicação
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
Clientes Pedidos
Comunicação
Síncrona Assíncrona
REST
SOAP
WS
ActiveMQ
RabbitMQ
Notificação
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
Comunicação entre
módulos via API
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
Delivery de
conteúdo web
estático
via CDN
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
Clientes
api.clientes.
Servidor Web
api.admin.clientes.
www.clientes.
CDN
admin.clientes.
CDN
Delivery de estático via CDN
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
Clientes consumindo
APIs
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
api.orders.
api.clientes.
Servidor Web
api.admin.clientes.
API
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
Escalabilidade X e Y
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
X
Y
Clientes
Load Balancer
Clientes
Pedidos
Load Balancer
Pedidos Pedidos Pedidos Pedidos
Escalabilidade X e Y
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
Ruby on Rails
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
Routes
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
only / except
resources :customers
resources :orders
GET (index, new, edit, show)
POST (create)
PATH,PUT (update)
DELETE (destroy)
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
only / except
resources :customers, only: [:index]
GET (index)
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
only / except
resources :orders, except: [:destroy, :edit, update]
GET (index, new, edit, show)
POST (create)
PATH,PUT (update)
DELETE (destroy)
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
with_options
resources :customers, only: [:index]
resources :orders, only: [:index]
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
with_options
with_options only: :index do |option|
option.resources :customers
option.resources :orders
end
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
constraints
http://clientes.sistema
http://pedidos.sistema
http://www.sistema
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
constraints
resources :customers, contraints: { subdomain: 'clientes'}
resources :orders, contraints: { subdomain: 'pedidos'}
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
constraints
constraints subdomain: 'api' do
resources :customers
resources :orders
end
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
constraints
http://pow.cx/
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
namespaces
constraints subdomain: 'api' do
resources :customers
resources :orders
end
http://api.sistema/customers
http://api.sistemas/orders
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
namespaces
constraints subdomain: 'api' do
resources :customers
resources :orders
end
controllers/customer_controller
controllers/order_controller
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
namespaces
constraints subdomain: 'api' do
namespace :api do
resources :customers
resources :orders
end
end
http://api.sistema/api/customers
http://api.sistemas/api/orders
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
namespaces
constraints subdomain: 'api' do
namespace :api, path: '/' do
resources :customers
resources :orders
end
end
controllers/api/customer_controller
controllers/api/order_controller
http://api.sistema/customers
http://api.sistemas/orders
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
Formatos
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
content negotiation
http://api.sistema/clientes.json
http://api.sistema/clientes.xml
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
content negotiation
http://api.sistema/clientes.json
http://api.sistema/clientes.xml
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
content negotiation
{ 'Accept' => Mime::JSON }
{ 'Accept' => Mime::XML }
HEADER
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
respond_to
respond_to do |format|
format.json { render json: customers, status: 200 }
format.xml { render xml: customers, status: 200 }
end
HTTP/1.1 200 OK
Content-Type: application/json
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
Accept-Language
{ 'Accept-Language' => 'en' }
{ 'Accept-Language' => 'pt-BR' }
HEADER
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
Accept-Language
I18n.locale = request.headers['Accept-Language']
Controller
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
Accept-Language
gem 'http_accept_language'
locales = I18n.available_locales
I18n.locale = http_accept_language.compatible_language_from(locales)
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
HTTP
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
Verbos HTTP
GET
POST
PUT
PATCH
DELETE
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
Verbos HTTP
GET
POST
PUT
PATCH
DELETE
Obter dados sem
efeito colateral.
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
Verbos HTTP
GET
POST
PUT
PATCH
DELETE
Criar Registro.
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
Verbos HTTP
GET
POST
PUT
PATCH
DELETE
Atualizar Registro
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
Verbos HTTP
GET
POST
PUT
PATCH
DELETE Remover Registro
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
Verbos HTTP
http://api.sistema/customers/delete/123.json
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
Verbos HTTP
http://api.sistema/customers/delete/123
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
Retorno sem body
render nothing: true, status: 204
head 204
POST
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
Versionamento de API
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
URI
/v1/customers/1
/v2/customers/1
http://api.sistema/
{
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
URI
namespace :v1 do
resources :customers
end
namespace :v2 do
resources :customers
end
/v1/customers/1
/v2/customers/1
http://api.sistema/
{
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
Header
application/vnd.apocalypse[.version]+json
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
URI
/v1/customers/1
/customers/1
http://api.sistema/
{
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
Autenticação
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
Basic Authentication
Base64.encode64(username:senha)
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
Basic Authentication
Base64.encode64(username:senha)
{ 'Authorization' => 'Basic XXXXXXXXXX'}
HEADER
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
Basic Authentication
Base64.encode64(username:senha)
{ 'Authorization' => 'Basic XXXXXXXXXX'}
HEADER
authenticate_or_request_with_http_basic
Decode
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
Token
Token gerado pelo server
Utilizado na comunicação com o cliente
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
Referencia
RUBYCONF 2015 MARCIO MANGAR
MICROSERVICES on RAILS
Obrigado
@mangar
github.com/mangar
marcio.mangar [at] gmail.com

Mais conteúdo relacionado

Semelhante a Microservice on Rails - RubyConfBR 2015

IoT Smart APIs using Nomos RuleX
IoT Smart APIs using Nomos RuleXIoT Smart APIs using Nomos RuleX
IoT Smart APIs using Nomos RuleXCliff Faurer
 
IoT and Microservice
IoT and MicroserviceIoT and Microservice
IoT and Microservicekgshukla
 
Microservices & Containers - Docker Bangalore Meetup #12
Microservices & Containers - Docker Bangalore Meetup #12Microservices & Containers - Docker Bangalore Meetup #12
Microservices & Containers - Docker Bangalore Meetup #12Aravind Ajad
 
To Microservices and Beyond
To Microservices and BeyondTo Microservices and Beyond
To Microservices and BeyondMatt Stine
 
Hands-On Lab: Managing and Monitoring Node.js Made Easy with CA Application P...
Hands-On Lab: Managing and Monitoring Node.js Made Easy with CA Application P...Hands-On Lab: Managing and Monitoring Node.js Made Easy with CA Application P...
Hands-On Lab: Managing and Monitoring Node.js Made Easy with CA Application P...CA Technologies
 
Building BMW Group's Customer Engagement Platform on AWS (AMT305) - AWS re:In...
Building BMW Group's Customer Engagement Platform on AWS (AMT305) - AWS re:In...Building BMW Group's Customer Engagement Platform on AWS (AMT305) - AWS re:In...
Building BMW Group's Customer Engagement Platform on AWS (AMT305) - AWS re:In...Amazon Web Services
 
Pre-Con Education: Building ITSM Reports and Dashboards with CA Business In...
Pre-Con Education: Building ITSM Reports and Dashboards with CA Business In...Pre-Con Education: Building ITSM Reports and Dashboards with CA Business In...
Pre-Con Education: Building ITSM Reports and Dashboards with CA Business In...CA Technologies
 
アドテク×Scala @Dynalyst
アドテク×Scala @Dynalystアドテク×Scala @Dynalyst
アドテク×Scala @DynalystSangwon Han
 
Dynamically Testing Individual Microservice Releases In Production
  Dynamically Testing Individual Microservice Releases In Production  Dynamically Testing Individual Microservice Releases In Production
Dynamically Testing Individual Microservice Releases In ProductionMatt Turner
 
Hands-On Lab: Using CA Mobile Application Analytics REST APIs
Hands-On Lab: Using CA Mobile Application Analytics REST APIsHands-On Lab: Using CA Mobile Application Analytics REST APIs
Hands-On Lab: Using CA Mobile Application Analytics REST APIsCA Technologies
 
Kranky Geek 2015 - Decisions & Considerations in building your WebRTC App
Kranky Geek 2015 - Decisions & Considerations in building your WebRTC AppKranky Geek 2015 - Decisions & Considerations in building your WebRTC App
Kranky Geek 2015 - Decisions & Considerations in building your WebRTC AppKranky Geek
 
C&CNR2019 - Cloud-Native Landscape Review
C&CNR2019 - Cloud-Native Landscape ReviewC&CNR2019 - Cloud-Native Landscape Review
C&CNR2019 - Cloud-Native Landscape ReviewPar-Tec S.p.A.
 
Technology Primer: Customize CA Application Performance Management With Tip...
Technology Primer: Customize CA Application Performance Management  With Tip...Technology Primer: Customize CA Application Performance Management  With Tip...
Technology Primer: Customize CA Application Performance Management With Tip...CA Technologies
 
Moving from a Monolith to distributed Monolith
Moving from a Monolith to distributed MonolithMoving from a Monolith to distributed Monolith
Moving from a Monolith to distributed MonolithNish Mahanty
 
How to Build Cloud-based Microservice Environments with Docker and VoltDB
How to Build Cloud-based Microservice Environments with Docker and VoltDBHow to Build Cloud-based Microservice Environments with Docker and VoltDB
How to Build Cloud-based Microservice Environments with Docker and VoltDBVoltDB
 
Bridging the Gap: Single-Page Apps and AEM
Bridging the Gap: Single-Page Apps and AEMBridging the Gap: Single-Page Apps and AEM
Bridging the Gap: Single-Page Apps and AEMrbl002
 
Metro Exhibits Capabilities Overview 2015
Metro Exhibits Capabilities Overview 2015Metro Exhibits Capabilities Overview 2015
Metro Exhibits Capabilities Overview 2015Ray Zamloot
 
Automatic Ingress in Kubernetes
Automatic Ingress in KubernetesAutomatic Ingress in Kubernetes
Automatic Ingress in KubernetesRodrigo Reis
 
apidays LIVE Paris - Multicluster Service Mesh in Action by Denis Jannot
apidays LIVE Paris - Multicluster Service Mesh in Action by Denis Jannotapidays LIVE Paris - Multicluster Service Mesh in Action by Denis Jannot
apidays LIVE Paris - Multicluster Service Mesh in Action by Denis Jannotapidays
 
Istio Service Mesh for Developers and Platform Engineers
Istio Service Mesh for Developers and Platform EngineersIstio Service Mesh for Developers and Platform Engineers
Istio Service Mesh for Developers and Platform EngineersSaiLinnThu2
 

Semelhante a Microservice on Rails - RubyConfBR 2015 (20)

IoT Smart APIs using Nomos RuleX
IoT Smart APIs using Nomos RuleXIoT Smart APIs using Nomos RuleX
IoT Smart APIs using Nomos RuleX
 
IoT and Microservice
IoT and MicroserviceIoT and Microservice
IoT and Microservice
 
Microservices & Containers - Docker Bangalore Meetup #12
Microservices & Containers - Docker Bangalore Meetup #12Microservices & Containers - Docker Bangalore Meetup #12
Microservices & Containers - Docker Bangalore Meetup #12
 
To Microservices and Beyond
To Microservices and BeyondTo Microservices and Beyond
To Microservices and Beyond
 
Hands-On Lab: Managing and Monitoring Node.js Made Easy with CA Application P...
Hands-On Lab: Managing and Monitoring Node.js Made Easy with CA Application P...Hands-On Lab: Managing and Monitoring Node.js Made Easy with CA Application P...
Hands-On Lab: Managing and Monitoring Node.js Made Easy with CA Application P...
 
Building BMW Group's Customer Engagement Platform on AWS (AMT305) - AWS re:In...
Building BMW Group's Customer Engagement Platform on AWS (AMT305) - AWS re:In...Building BMW Group's Customer Engagement Platform on AWS (AMT305) - AWS re:In...
Building BMW Group's Customer Engagement Platform on AWS (AMT305) - AWS re:In...
 
Pre-Con Education: Building ITSM Reports and Dashboards with CA Business In...
Pre-Con Education: Building ITSM Reports and Dashboards with CA Business In...Pre-Con Education: Building ITSM Reports and Dashboards with CA Business In...
Pre-Con Education: Building ITSM Reports and Dashboards with CA Business In...
 
アドテク×Scala @Dynalyst
アドテク×Scala @Dynalystアドテク×Scala @Dynalyst
アドテク×Scala @Dynalyst
 
Dynamically Testing Individual Microservice Releases In Production
  Dynamically Testing Individual Microservice Releases In Production  Dynamically Testing Individual Microservice Releases In Production
Dynamically Testing Individual Microservice Releases In Production
 
Hands-On Lab: Using CA Mobile Application Analytics REST APIs
Hands-On Lab: Using CA Mobile Application Analytics REST APIsHands-On Lab: Using CA Mobile Application Analytics REST APIs
Hands-On Lab: Using CA Mobile Application Analytics REST APIs
 
Kranky Geek 2015 - Decisions & Considerations in building your WebRTC App
Kranky Geek 2015 - Decisions & Considerations in building your WebRTC AppKranky Geek 2015 - Decisions & Considerations in building your WebRTC App
Kranky Geek 2015 - Decisions & Considerations in building your WebRTC App
 
C&CNR2019 - Cloud-Native Landscape Review
C&CNR2019 - Cloud-Native Landscape ReviewC&CNR2019 - Cloud-Native Landscape Review
C&CNR2019 - Cloud-Native Landscape Review
 
Technology Primer: Customize CA Application Performance Management With Tip...
Technology Primer: Customize CA Application Performance Management  With Tip...Technology Primer: Customize CA Application Performance Management  With Tip...
Technology Primer: Customize CA Application Performance Management With Tip...
 
Moving from a Monolith to distributed Monolith
Moving from a Monolith to distributed MonolithMoving from a Monolith to distributed Monolith
Moving from a Monolith to distributed Monolith
 
How to Build Cloud-based Microservice Environments with Docker and VoltDB
How to Build Cloud-based Microservice Environments with Docker and VoltDBHow to Build Cloud-based Microservice Environments with Docker and VoltDB
How to Build Cloud-based Microservice Environments with Docker and VoltDB
 
Bridging the Gap: Single-Page Apps and AEM
Bridging the Gap: Single-Page Apps and AEMBridging the Gap: Single-Page Apps and AEM
Bridging the Gap: Single-Page Apps and AEM
 
Metro Exhibits Capabilities Overview 2015
Metro Exhibits Capabilities Overview 2015Metro Exhibits Capabilities Overview 2015
Metro Exhibits Capabilities Overview 2015
 
Automatic Ingress in Kubernetes
Automatic Ingress in KubernetesAutomatic Ingress in Kubernetes
Automatic Ingress in Kubernetes
 
apidays LIVE Paris - Multicluster Service Mesh in Action by Denis Jannot
apidays LIVE Paris - Multicluster Service Mesh in Action by Denis Jannotapidays LIVE Paris - Multicluster Service Mesh in Action by Denis Jannot
apidays LIVE Paris - Multicluster Service Mesh in Action by Denis Jannot
 
Istio Service Mesh for Developers and Platform Engineers
Istio Service Mesh for Developers and Platform EngineersIstio Service Mesh for Developers and Platform Engineers
Istio Service Mesh for Developers and Platform Engineers
 

Último

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdfChristopherTHyatt
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 

Último (20)

From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 

Microservice on Rails - RubyConfBR 2015

  • 1. RUBYCONF 2015 MARCIO MANGARMICROSERVICES on RAILS Microserviceson Rails
  • 2. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS Agradecimento
  • 3. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS Agenda Microservices Ruby on Rails
  • 4. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS Apresentação Marcio Mangar @mangar github.com/mangar marcio.mangar [at] gmail.com http://rga.com
  • 5. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS Microserviços
  • 6. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS O que são Microserviços
  • 7. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS Service Oriented Architecture
  • 8. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS Aplicação Monolítica
  • 9. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS Clientes Pedidos Banco de Dados def make() Aplicação Monolitica
  • 10. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS Clientes Pedidos Banco de Dados def make() www.sistema
  • 11. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS Clientes Pedidos Banco de Dados def make() www.sistema cart.sistema search.sistema
  • 12. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS Escalabilidade
  • 13. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS X Escalabilidade X Clientes Pedidos Load Balancer Clientes Pedidos Clientes Pedidos . . . . .
  • 14. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS Aplicação com Microserviços
  • 15. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS Clientes admin.clientes. api.clientes. www.clientes. Pedidos admin.pedidos. api.pedidos. www.pedidos. Aplicação com Microserviços Banco de Dados
  • 16. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS Comunicação
  • 17. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS Clientes Pedidos Comunicação Síncrona Assíncrona REST SOAP WS ActiveMQ RabbitMQ Notificação
  • 18. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS Comunicação entre módulos via API
  • 19. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS Delivery de conteúdo web estático via CDN
  • 20. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS Clientes api.clientes. Servidor Web api.admin.clientes. www.clientes. CDN admin.clientes. CDN Delivery de estático via CDN
  • 21. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS Clientes consumindo APIs
  • 22. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS api.orders. api.clientes. Servidor Web api.admin.clientes. API
  • 23. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS Escalabilidade X e Y
  • 24. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS X Y Clientes Load Balancer Clientes Pedidos Load Balancer Pedidos Pedidos Pedidos Pedidos Escalabilidade X e Y
  • 25. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS Ruby on Rails
  • 26. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS Routes
  • 27. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS only / except resources :customers resources :orders GET (index, new, edit, show) POST (create) PATH,PUT (update) DELETE (destroy)
  • 28. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS only / except resources :customers, only: [:index] GET (index)
  • 29. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS only / except resources :orders, except: [:destroy, :edit, update] GET (index, new, edit, show) POST (create) PATH,PUT (update) DELETE (destroy)
  • 30. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS with_options resources :customers, only: [:index] resources :orders, only: [:index]
  • 31. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS with_options with_options only: :index do |option| option.resources :customers option.resources :orders end
  • 32. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS constraints http://clientes.sistema http://pedidos.sistema http://www.sistema
  • 33. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS constraints resources :customers, contraints: { subdomain: 'clientes'} resources :orders, contraints: { subdomain: 'pedidos'}
  • 34. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS constraints constraints subdomain: 'api' do resources :customers resources :orders end
  • 35. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS constraints http://pow.cx/
  • 36. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS namespaces constraints subdomain: 'api' do resources :customers resources :orders end http://api.sistema/customers http://api.sistemas/orders
  • 37. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS namespaces constraints subdomain: 'api' do resources :customers resources :orders end controllers/customer_controller controllers/order_controller
  • 38. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS namespaces constraints subdomain: 'api' do namespace :api do resources :customers resources :orders end end http://api.sistema/api/customers http://api.sistemas/api/orders
  • 39. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS namespaces constraints subdomain: 'api' do namespace :api, path: '/' do resources :customers resources :orders end end controllers/api/customer_controller controllers/api/order_controller http://api.sistema/customers http://api.sistemas/orders
  • 40. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS Formatos
  • 41. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS content negotiation http://api.sistema/clientes.json http://api.sistema/clientes.xml
  • 42. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS content negotiation http://api.sistema/clientes.json http://api.sistema/clientes.xml
  • 43. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS content negotiation { 'Accept' => Mime::JSON } { 'Accept' => Mime::XML } HEADER
  • 44. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS respond_to respond_to do |format| format.json { render json: customers, status: 200 } format.xml { render xml: customers, status: 200 } end HTTP/1.1 200 OK Content-Type: application/json
  • 45. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS Accept-Language { 'Accept-Language' => 'en' } { 'Accept-Language' => 'pt-BR' } HEADER
  • 46. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS Accept-Language I18n.locale = request.headers['Accept-Language'] Controller
  • 47. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS Accept-Language gem 'http_accept_language' locales = I18n.available_locales I18n.locale = http_accept_language.compatible_language_from(locales)
  • 48. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS HTTP
  • 49. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS Verbos HTTP GET POST PUT PATCH DELETE
  • 50. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS Verbos HTTP GET POST PUT PATCH DELETE Obter dados sem efeito colateral.
  • 51. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS Verbos HTTP GET POST PUT PATCH DELETE Criar Registro.
  • 52. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS Verbos HTTP GET POST PUT PATCH DELETE Atualizar Registro
  • 53. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS Verbos HTTP GET POST PUT PATCH DELETE Remover Registro
  • 54. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS Verbos HTTP http://api.sistema/customers/delete/123.json
  • 55. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS Verbos HTTP http://api.sistema/customers/delete/123
  • 56. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS Retorno sem body render nothing: true, status: 204 head 204 POST
  • 57. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS Versionamento de API
  • 58. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS URI /v1/customers/1 /v2/customers/1 http://api.sistema/ {
  • 59. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS URI namespace :v1 do resources :customers end namespace :v2 do resources :customers end /v1/customers/1 /v2/customers/1 http://api.sistema/ {
  • 60. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS Header application/vnd.apocalypse[.version]+json
  • 61. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS URI /v1/customers/1 /customers/1 http://api.sistema/ {
  • 62. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS Autenticação
  • 63. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS Basic Authentication Base64.encode64(username:senha)
  • 64. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS Basic Authentication Base64.encode64(username:senha) { 'Authorization' => 'Basic XXXXXXXXXX'} HEADER
  • 65. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS Basic Authentication Base64.encode64(username:senha) { 'Authorization' => 'Basic XXXXXXXXXX'} HEADER authenticate_or_request_with_http_basic Decode
  • 66. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS Token Token gerado pelo server Utilizado na comunicação com o cliente
  • 67. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS Referencia
  • 68. RUBYCONF 2015 MARCIO MANGAR MICROSERVICES on RAILS Obrigado @mangar github.com/mangar marcio.mangar [at] gmail.com