Skip to content

Commit

Permalink
back to ascii diagrams
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Feb 28, 2012
1 parent 58ffda4 commit 8cb0db9
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 67 deletions.
20 changes: 9 additions & 11 deletions lib/Mojo/Server/Hypnotoad.pm
Expand Up @@ -389,8 +389,6 @@ sub _stop {
1;
__END__
=encoding utf8
=head1 NAME
Mojo::Server::Hypnotoad - ALL GLORY TO THE HYPNOTOAD!
Expand Down Expand Up @@ -460,15 +458,15 @@ Attempt zero downtime software upgrade (hot deployment) without losing any
incoming connections.
Manager (old)
├─ Worker [1]
├─ Worker [2]
├─ Worker [3]
├─ Worker [4]
└─ Manager (new)
├─ Worker [1]
├─ Worker [2]
├─ Worker [3]
└─ Worker [4]
|- Worker [1]
|- Worker [2]
|- Worker [3]
|- Worker [4]
`- Manager (new)
|- Worker [1]
|- Worker [2]
|- Worker [3]
`- Worker [4]
The new manager will automatically send a C<QUIT> signal to the old manager
and take over serving requests after starting up successfully.
Expand Down
12 changes: 5 additions & 7 deletions lib/Mojolicious/Guides/Cookbook.pod
@@ -1,6 +1,4 @@

=encoding utf8

=head1 NAME

Mojolicious::Guides::Cookbook - Cookbook
Expand Down Expand Up @@ -46,7 +44,7 @@ After reading the L<Mojolicious::Lite> tutorial, you should already be
familiar with L<Mojo::Server::Morbo>.

Mojo::Server::Morbo
└─ Mojo::Server::Daemon
`- Mojo::Server::Daemon

It is basically a restarter that forks a new L<Mojo::Server::Daemon> web
server whenever a file in your project changes, and should therefore only be
Expand All @@ -62,10 +60,10 @@ web server L<Mojo::Server::Hypnotoad> that will allow you to take advantage
of multiple cpu cores and copy-on-write.

Mojo::Server::Hypnotoad
├─ Mojo::Server::Daemon [1]
├─ Mojo::Server::Daemon [2]
├─ Mojo::Server::Daemon [3]
└─ Mojo::Server::Daemon [4]
|- Mojo::Server::Daemon [1]
|- Mojo::Server::Daemon [2]
|- Mojo::Server::Daemon [3]
`- Mojo::Server::Daemon [4]

It is also based on the L<Mojo::Server::Daemon> web server, but optimized
specifically for production environments out of the box.
Expand Down
96 changes: 47 additions & 49 deletions lib/Mojolicious/Guides/Growing.pod
@@ -1,6 +1,4 @@

=encoding utf8

=head1 NAME

Mojolicious::Guides::Growing - Growing
Expand All @@ -21,21 +19,21 @@ MVC is a software architectural pattern for graphical user interface
programming originating in Smalltalk-80, that separates application logic,
presentation and input.

┌────────────┐ ┌───────┐ ┌──────┐
Input -> Controller -> Model -> View -> Output
└────────────┘ └───────┘ └──────┘
.------------. .-------. .------.
Input -> | Controller | -> | Model | -> | View | -> Output
'------------' '-------' '------'

A slightly modified version of the pattern moving some application logic into
the C<controller> is the foundation of pretty much every web framework these
days, including L<Mojolicious>.

┌────────────────┐ ┌───────┐
Request -> <-> Model
└───────┘
Controller
┌───────┐
Response <- <-> View
└────────────────┘ └───────┘
.----------------. .-------.
Request -> | | <-> | Model |
| | '-------'
| Controller |
| | .-------.
Response <- | | <-> | View |
'----------------' '-------'

The C<controller> receives a request from a user, passes incoming data to the
C<model> and retrieves data from it, which then gets turned into an actual
Expand All @@ -52,32 +50,32 @@ like C<http://mojolicio.us/foo> with your browser, you are basically asking
the web server for the HTML C<representation> of the
C<http://mojolicio.us/foo> C<resource>.

┌────────┐ ┌────────┐
-> http://mojolicio.us/foo ->
Client Server
<- <html>Mojo rocks!</html> <-
└────────┘ └────────┘
.--------. .--------.
| | -> http://mojolicio.us/foo -> | |
| Client | | Server |
| | <- <html>Mojo rocks!</html> <- | |
'--------' '--------'

The fundamental idea here is that all resources are uniquely addressable with
URLs and every resource can have different representations such as HTML, RSS
or JSON. User interface concerns are separated from data storage concerns and
all session state is kept client-side.

┌─────────┐ ┌────────────┐
-> PUT /foo ->
-> Hello world! ->
<- 201 CREATED <-
-> GET /foo ->
Browser Web Server
<- 200 OK <-
<- Hello world! <-
-> DELETE /foo ->
<- 200 OK <-
└─────────┘ └────────────┘
.---------. .------------.
| | -> PUT /foo -> | |
| | -> Hello world! -> | |
| | | |
| | <- 201 CREATED <- | |
| | | |
| | -> GET /foo -> | |
| Browser | | Web Server |
| | <- 200 OK <- | |
| | <- Hello world! <- | |
| | | |
| | -> DELETE /foo -> | |
| | | |
| | <- 200 OK <- | |
'---------' '------------'

While HTTP methods such as C<PUT>, C<GET> and C<DELETE> are not directly part
of REST they go very well with it and are commonly used to manipulate
Expand Down Expand Up @@ -144,23 +142,23 @@ Full L<Mojolicious> applications on the other hand are much closer to a well
organized CPAN distribution to maximize maintainability.

myapp # Application directory
├─ script # Script directory
│ └─ myapp # Application script
├─ lib # Library directory
│ ├─ MyApp.pm # Application class
│ └─ MyApp # Application namespace
└─ Example.pm # Controller class
├─ t # Test directory
│ └─ basic.t # Random test
├─ log # Log directory
│ └─ development.log # Development mode log file
├─ public # Static file directory (served automatically)
│ └─ index.html # Static HTML file
└─ templates # Template directory
├─ layouts # Template directory for layouts
│ └─ default.html.ep # Layout template
└─ example # Template directory for "Example" controller
└─ welcome.html.ep # Template for "welcome" action
|- script # Script directory
| `- myapp # Application script
|- lib # Library directory
| |- MyApp.pm # Application class
| `- MyApp # Application namespace
| `- Example.pm # Controller class
|- t # Test directory
| `- basic.t # Random test
|- log # Log directory
| `- development.log # Development mode log file
|- public # Static file directory (served automatically)
| `- index.html # Static HTML file
`- templates # Template directory
|- layouts # Template directory for layouts
| `- default.html.ep # Layout template
`- example # Template directory for "Example" controller
`- welcome.html.ep # Template for "welcome" action

Both application skeletons can be automatically generated.

Expand Down

0 comments on commit 8cb0db9

Please sign in to comment.