Date post: | 12-Apr-2017 |
Category: |
Software |
Upload: | pedro-j-molina |
View: | 405 times |
Download: | 0 times |
Sevilla Developer Conference
#SVQDC 2017.02.18
Pedro J. Molina@pmolinam
“Las organizaciones que diseñan sistemas están limitadasa producir diseños que copian las estructuras de comunicación de esas organizaciones”.
Melvin Conway, 1968
application/json text/xml text/html text/plain text/csv
GET /actors/42Accept: text/xml
200 OKContent-Type: text/xml
<actor id="42"><name>Jessica</name><lastname>Alba</lastname><filmography
url= "/films/42" /></actor>
GET /actors/42Accept: application/json
200 OKContent-Type: application/json
{ "id": 42"name": "Jessica""lastname": "Alba""filmography": "/films/42"
}
GET /factura/217
POST /factura/ 201 Created
<link rel=“lineas”
uri=“/factura/217/lineas” />
{
“id”: 1234
“name”: “Alice in Wonderland”
“_links”: {
“self”: { “href”: “/book/10”},
“prev”: { “href”: “/book/9”},
“next”: { “href”: “/book/11”},
“action-delete”: {
“verb”: “DELETE”,
“href”: “/book/10”
}
}
}
Dev
Local:27001
Local:5000
-
Navegador
Nube
db:27001
app:80
-
Navegador
Producción
cluster:27001
app :80
-
Navegador
lb: 443
Client ExpressJS BaucisJS Mongoose MongoDB
HTTP req
resourcequery/command
data
401 | 403
AuthN/AuthZ middleware
<req.user, res>
Microservice
var express = require('express');var app = express();
app.get('/hello', function(req, res) {res.status(200).send('hello world');
});
/helloreq res
public class SampleModule : Nancy.NancyModule{
public SampleModule(){
Get["/hello"] = _ => “hello world";}
}
/helloreq res
exports.handler = function(event, context) {switch (event.operation) {
case 'ping': context.succeed('pong'); return;
case 'getSample':event.customArgs = ["rose:", "/tmp/rose.png"];im.convert(event.customArgs, function(err, output) {
if (err) context.fail(err);else {
var resultImgBase64 = new Buffer(fs.readFileSync("/tmp/rose.png")).toString('base64');
try { fs.unlinkSync("/tmp/rose.png");} catch (e) {}context.succeed(resultImgBase64);
}});break;
default:return context.fail(new Error('Unrecognized operation "' +
event.operation + '"'));}};
connect-mongo
nginx haproxy, etc.
process.env.VAR1
git remote add heroku https://git.heroku.com/app1.git
/Procfile
git push heroku master
web: node app/server.js
db: image: dockerfile/mongodbports: - "27017"
app: build: . environment: NODE_ENV: productionPORT: 80 SERVICE_NAME: app
links: - "db:DB" ports: - "80"
lb: image: jasonwyatt/nginx-loadbalancerlinks: - appenvironment: APP_PATH: "/"
ports: - "80:80"
db
app
lb app
app
#0
#1
#2
80
80 27017
consul prometheus8500
8500autoregistro
8500autodescubre /metrics
/ping
@pmolinam