github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

miyagawa / Tatsumaki

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 87
    • 6
  • Source
  • Commits
  • Network (6)
  • Issues (11)
  • Downloads (9)
  • Wiki (1)
  • Graphs
  • Branch: master

click here to add a description

click here to add a homepage

  • Branches (3)
    • 0.2
    • master ✓
    • xmpp
  • Tags (9)
    • 0.1008
    • 0.1007
    • 0.1006
    • 0.1005
    • 0.1004
    • 0.1003
    • 0.1002
    • 0.1001
    • 0.1000
Sending Request…
Enable Donations

Pledgie Donations

Once activated, we'll place the following badge in your repository's detail box:
Pledgie_example
This service is courtesy of Pledgie.

Plack-based nonblocking Web framework for IO-bound delayed response, server push (streaming) and long-poll comet — Read more

  cancel

http://search.cpan.org/dist/Tatsumaki

  cancel
  • Private
  • Read-Only
  • HTTP Read-Only

This URL has Read+Write access

Only store writer when there's no body. This revealed a rare condition 
Tatsuhiko Miyagawa (author)
Wed Feb 03 23:51:21 -0800 2010
commit  5249c6b54b0ff5f463870ecd9c59cfdea04a6514
tree    1639a1b33b379bb79830d737b870dc3adf4bead4
parent  4b49c30ee0c0104a127d41cdef9e41ac3d5e45f0
Tatsumaki /
name age
history
message
file .gitignore Wed Oct 14 17:00:19 -0700 2009 initial commit [miyagawa]
file .shipit Wed Oct 14 17:00:19 -0700 2009 initial commit [miyagawa]
file Changes Wed Feb 03 23:51:08 -0800 2010 fix [miyagawa]
file MANIFEST Sun Jan 31 14:17:04 -0800 2010 Checking in changes prior to tagging of version... [miyagawa]
file MANIFEST.SKIP Wed Oct 14 17:00:19 -0700 2009 initial commit [miyagawa]
file Makefile.PL Tue Dec 08 07:24:48 -0800 2009 Test tweaks [miyagawa]
file README Sun Dec 13 11:43:42 -0800 2009 remove the link to tornado not to confuse peopl... [miyagawa]
directory eg/ Thu Nov 26 06:57:35 -0800 2009 use Tatsumaki to display VERSION [miyagawa]
directory lib/ Wed Feb 03 23:51:21 -0800 2010 Only store writer when there's no body. This re... [miyagawa]
directory t/ Sun Jan 31 14:15:47 -0800 2010 revert 3f31648 since it makes timer go away in ... [miyagawa]
directory xt/ Wed Oct 14 17:00:19 -0700 2009 initial commit [miyagawa]
README
NAME
    Tatsumaki - Non-blocking web framework based on Plack and AnyEvent

SYNOPSIS
      ### app.psgi
      use Tatsumaki::Error;
      use Tatsumaki::Application;
      use Tatsumaki::HTTPClient;
      use Tatsumaki::Server;

      package MainHandler;
      use parent qw(Tatsumaki::Handler);

      sub get {
          my $self = shift;
          $self->write("Hello World");
      }

      package FeedHandler;
      use parent qw(Tatsumaki::Handler);
      __PACKAGE__->asynchronous(1);

      use JSON;

      sub get {
          my($self, $query) = @_;
          my $client = Tatsumaki::HTTPClient->new;
          $client->get("http://friendfeed-api.com/v2/feed/$query", $self->async_cb(sub { $self->on_response(@_) }));
      }

      sub on_response {
          my($self, $res) = @_;
          if ($res->is_error) {
              Tatsumaki::Error::HTTP->throw(500);
          }
          my $json = JSON::decode_json($res->content);
          $self->write("Fetched " . scalar(@{$json->{entries}}) . " entries from API");
          $self->finish;
      }

      package StreamWriter;
      use parent qw(Tatsumaki::Handler);
      __PACKAGE__->asynchronous(1);

      use AnyEvent;

      sub get {
          my $self = shift;
          $self->response->content_type('text/plain');

          my $try = 0;
          my $t; $t = AE::timer 0, 0.1, sub {
              $self->stream_write("Current UNIX time is " . time . "\n");
              if ($try++ >= 10) {
                  undef $t;
                  $self->finish;
              }
          };
      }

      package main;

      my $app = Tatsumaki::Application->new([
          '/stream' => 'StreamWriter',
          '/feed/(\w+)' => 'FeedHandler',
          '/' => 'MainHandler',
      ]);
      return $app;

    And now run it with:

      plackup -s AnyEvent -a app.psgi

WARNINGS
    This is considered as alpha quality software. Most of the stuff are
    undocumented since it's considered unstable and will likely to change.
    You should sometimes look at the source code or example apps in *eg*
    directory to see how this thing works.

    Feel free to hack on it and ask me if you have questions or suggestions
    at IRC: #plack on irc.perl.org.

DESCRIPTION
    Tatsumaki is a toy port of Tornado for Perl using Plack (with
    non-blocking extensions) and AnyEvent.

    It allows you to write a web application that does a immediate response
    with template rendering, IO-bound delayed response (like fetching third
    party API or XML feeds), server push streaming and long-poll Comet in a
    clean unified API.

PSGI COMPATIBILITY
    When "asynchronous" is declared in your application, you need a PSGI
    server backend that supports "psgi.streaming" response style. If your
    application does server push with "stream_write", you need a server that
    supports "psgi.nonblocking" (and "psgi.streaming") as well.

    Currently Tatsumaki asynchronous application is supposed to run on
    Tatsumaki::Server, Plack::Server::AnyEvent, Plack::Server::Coro and
    Plack::Server::POE.

    If "asynchronous" is not used, your application is supposed to run in
    any PSGI standard environments, including blocking multiprocess
    environments like mod_perl2 and prefork.

TATSUMAKI?
    Tatsumaki is a Japanese for Tornado. Also, it might sound familiar from
    "Tatsumaki Senpuukyaku" of Ryu from Street Fighter II if you loved the
    Capcom videogame back in the day :)

AUTHOR
    Tatsuhiko Miyagawa <miyagawa@bulknews.net>

LICENSE
    This library is free software; you can redistribute it and/or modify it
    under the same terms as Perl itself.

SEE ALSO
    AnyEvent Plack PSGI

Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server