Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for...
Transcript of Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for...
![Page 1: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/1.jpg)
Cro
Jonathan Worthington Edument
One Year Later
![Page 2: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/2.jpg)
At last year's Swiss Perl Workshop...
![Page 3: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/3.jpg)
At last year's Swiss Perl Workshop...
...I revealed Cro
![Page 4: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/4.jpg)
A set of libraries and tools for building distributed
systems in Perl 6
- Designed for Perl 6 - Async from the ground up
- Initial HTTP/WebSocket focus
![Page 5: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/5.jpg)
So, where are we
one year later?
![Page 6: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/6.jpg)
Well, we've got a logo now...
![Page 7: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/7.jpg)
releases
![Page 8: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/8.jpg)
commits (across all Cro project repositories in the last year)
![Page 9: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/9.jpg)
code contributors (people who committed or had a merged PR)
![Page 10: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/10.jpg)
sponsored features (excluding Edument's sponsorship)
![Page 11: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/11.jpg)
First usages in production
(we don't know how many; users survey?)
![Page 12: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/12.jpg)
So, what's new?
![Page 13: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/13.jpg)
cro web
A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs, etc.
![Page 14: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/14.jpg)
<demo>
![Page 15: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/15.jpg)
Cro::HTTP::Test
A library for writing automated tests for a HTTP service
Primarily for services built in Cro - but
can be used against any HTTP endpoint
![Page 16: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/16.jpg)
use Cro::HTTP::Router; sub routes() is export { route { get -> 'is-prime', Int $number { content 'application/json', { :$number, :prime($number.is-prime) } } } }
![Page 17: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/17.jpg)
use Routes; use Cro::HTTP::Test; test-service routes(), { test get('/is-prime/42'), json => { number => 42, prime => False } test get('/is-prime/71'), json => { number => 71, prime => True } } done-testing;
![Page 18: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/18.jpg)
use Routes; use Cro::HTTP::Test; test-service routes(), { test-given '/is-prime/', { test get('42'), json => { number => 42, prime => False } test get('71'), json => { number => 71, prime => True } } } done-testing;
![Page 19: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/19.jpg)
test post('/get-prime', json => { min => 1000, max => 2000 }), status => 200, json => { .<number>.is-prime }
![Page 20: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/20.jpg)
post -> 'get-prime' { request-body -> (:$min!, :$max!) { content 'application/json', { number => ($min..$max).grep(*.is-prime).pick } } }
![Page 21: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/21.jpg)
test post('/get-prime', json => { min => 1000, max => 2000 }), status => 200, json => { .<number>.is-prime } test post('/get-prime', json => { min => 20, max => 22 }), status => 404;
![Page 22: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/22.jpg)
post -> 'get-prime' { request-body -> (:$min!, :$max!) { with ($min..$max).grep(*.is-prime).pick -> $number { content 'application/json', { :$number } } else { not-found; } } }
![Page 23: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/23.jpg)
There's now support for implementing an OpenAPI
specification using Cro
![Page 24: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/24.jpg)
Cro::OpenAPI:: RoutesFromDefinition
- Avoids repeating path and method
- Enforces validation rules - Otherwise, just like a route block
![Page 25: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/25.jpg)
![Page 26: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/26.jpg)
openapi: "3.0.0" info: version: 1.0.0 title: Prime Service paths: /is-prime/{number}: get: ... /get-prime: post: ...
![Page 27: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/27.jpg)
/is-prime/{number}: get: summary: Checks if a number is prime operationId: is-prime parameters: - name: number in: path description: The number to check required: true schema: type: integer responses: ...
![Page 28: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/28.jpg)
/is-prime/{number}: get: ... responses: '200': description: Result of primality test content: application/json: schema: required: - number - prime properties: number: type: integer prime: type: boolean
![Page 29: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/29.jpg)
/get-prime: post: summary: Generate a prime number operationId: get-prime requestBody: required: true content: application/json: schema: required: - min - max properties: min: type: integer max: type: integer responses: ...
![Page 30: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/30.jpg)
/get-prime: post: ... responses: '200': description: Generated a prime in the range content: application/json: schema: required: - number properties: number: type: integer '400': description: No prime in the range specified
![Page 31: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/31.jpg)
openapi 'api.json'.IO, { ... }
![Page 32: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/32.jpg)
openapi 'api.json'.IO, { operation 'is-prime', -> Int $number { content 'application/json', { :$number, :prime($number.is-prime) } } ... }
![Page 33: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/33.jpg)
openapi 'api.json'.IO, { operation 'is-prime', -> Int $number { content 'application/json', { :$number, :prime($number.is-prime) } } operation 'get-prime', -> { request-body -> (:$min, :$max) { with ($min..$max).grep(*.is-prime).pick -> $number { content 'application/json', { :$number } } else { not-found; } } } }
![Page 34: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/34.jpg)
It's now much easier to create and consume
middleware
![Page 35: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/35.jpg)
HTTP Request Parser
HTTP Response Serializer
Application
TCP/TLS Connection
TCP/TLS Replier
Requests are pushed through an asynchronous
pipeline
![Page 36: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/36.jpg)
HTTP Request Parser
HTTP Response Serializer
Application
TCP/TLS Connection
TCP/TLS Replier
Server-level middleware
before-parse
before
after
after-serialize
![Page 37: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/37.jpg)
Could always just write transforms before now
However, new roles get rid
of the boilerplate
![Page 38: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/38.jpg)
HTTP Request Parser
HTTP Response Serializer
Application
TCP/TLS Connection
TCP/TLS Replier
Cro::HTTP::Middleware::Request
before
![Page 39: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/39.jpg)
HTTP Request Parser
HTTP Response Serializer
Application
TCP/TLS Connection
TCP/TLS Replier
Cro::HTTP::Middleware::Response
after
![Page 40: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/40.jpg)
class HSTS does Cro::HTTP::Middleware::Response { has Int $.max-age = 31536000; method process(Supply $responses) { supply whenever $responses -> $rep { $rep.append-header: 'Strict-transport-security', "max-age=$!max-age" emit $rep; } } }
![Page 41: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/41.jpg)
HTTP Request Parser
HTTP Response Serializer
Application
TCP/TLS Connection
TCP/TLS Replier
Cro::HTTP::Middleware::Conditional
before
after ?
![Page 42: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/42.jpg)
class LocalOnly does Cro::HTTP::Middleware::Conditional { method process(Supply $requests) { supply whenever $requests -> $request { if $request.connection.peer-host eq '127.0.0.1' | '::1' { # It's local, so continue processing. emit $req; } else { # It's not, so emit a 403 forbidden response. emit Cro::HTTP::Response.new(:$request, :403status); } } }
![Page 43: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/43.jpg)
HTTP Request Parser
HTTP Response Serializer
Application
TCP/TLS Connection
TCP/TLS Replier
Cro::HTTP::Middleware::RequestResponse
before
after ?
![Page 44: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/44.jpg)
Middleware can also be applied in route blocks
![Page 45: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/45.jpg)
my $app = route { before LocalOnly.new; after HSTS.new; ... }
Apply middleware written as a class
![Page 46: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/46.jpg)
my $app = route { before { forbidden unless .connection.peer-host eq '127.0.0.1' | '::1'; } after { header 'Strict-transport-security', 'max-age=31536000; includeSubDomains' } ... }
Write simple middleware inline
![Page 47: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/47.jpg)
before / after Composed around the route block
Run unconditionally
before-matched / after-matched
Wrap around a handler Run if a route was matched
(These are the Cro 0.8.0 semantics. Prior to that, before/after were used to mean
what before-matched and after-matched now mean, and there was no direct equivalent to the new before/after semantics.)
![Page 48: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/48.jpg)
Session handling and auth are implemented as
middleware
![Page 49: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/49.jpg)
class My::App::Session does Cro::HTTP::Auth { has $.is-logged-in; has $.is-admin; has @.recently-viewed-items; }
Declare a session/user object
![Page 50: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/50.jpg)
subset Admin of My::App::Session where .is-admin; subset LoggedIn of My::App::Session where .is-logged-in;
If needed, declare Perl 6 subset types to distinguish types of user
![Page 51: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/51.jpg)
my $app = route { get -> LoggedIn $user, 'my', 'profile' { # Use $user in some way } get -> Admin, 'system', 'log' { # Just use the type and don't name a variable, if # the session/user object is not needed } }
Match on them in routes
![Page 52: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/52.jpg)
my $app = route { before Cro::HTTP::Session::InMemory[My::App::Session].new( expiration => Duration.new(60 * 15), cookie-name => 'MY_SESSION_COOKIE_NAME' ); ... }
Apply session middleware
![Page 53: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/53.jpg)
Middleware included for:
Persistent sessions Basic authentication
JSON Web Tokens
![Page 54: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/54.jpg)
Web-based login/logout is left for the application to handle
Further assistance planned in the
future Cro::HTTP::WebApp
![Page 55: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/55.jpg)
Stubbed projects now include a Dockerfile
And we provide several Cro base
images, to give you quicker container builds
![Page 56: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/56.jpg)
All of our Cro applications at Edument are deployed in containers running on a
Kubernetes cluster
![Page 57: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/57.jpg)
Cro App 1
Cro App 2
Cro App 3
Apache Reverse Proxy
HTTPS Cert Caching Stateless
(so can scale out)
![Page 58: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/58.jpg)
Cro App 1
Cro App 2
Cro App 3
Apache Reverse Proxy
HTTPS Cert Caching Stateless
(so can scale out)
Only expose Apache to the outside world
![Page 59: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/59.jpg)
Place all static assets in a route block and apply middleware to
add a cache control header sub assets() { route { after-matched { cache-control :public, :max-age(180); } get -> 'css', *@path { static 'static-content/css', @path } get -> 'js', *@path { static 'static-content/js', @path } } }
![Page 60: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/60.jpg)
And where are we going
in the next year?
![Page 61: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/61.jpg)
Cro::HTTP::WebApp
If folks are going to use Cro as a web framework, we should serve them better
So far, we've a 6-y template engine in development (and, uh, production...)
Planning some login/logout plumbing, CSRF
protection, and so forth
![Page 62: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/62.jpg)
Reverse Proxy Support
Initial implementation coming in Cro 0.8.0
Makes the easy things easy:
Plus many features to make the harder things (request/response processing) possible
# /user/foo proxied to http://user-service/foo delegate <user *> => Cro::HTTP::ReverseProxy.new: to => 'http://user-service/';
![Page 63: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/63.jpg)
Reliability patterns
Timeouts
Retries
Throttling
Circuit breaker
![Page 64: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/64.jpg)
Portability
MacOS Windows
![Page 65: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/65.jpg)
Wherever our userbase leads us
When folks miss something, or stub their toe on something repeatedly, we look for ways to
make things better
![Page 66: Cro - Jonathan Worthingtonjnthn.net/papers/2018-spw-cro-one-year-later.pdf · cro web A web UI for stubbing Cro services, automatically restarting them on changes, viewing their logs,](https://reader034.fdocuments.net/reader034/viewer/2022052519/604c6e6538920833d9577342/html5/thumbnails/66.jpg)
Questions?
Web: http://cro.services/ Twitter: @croservices
IRC: #cro on freenode.org