Cramp异步事件驱动的Ruby Web应用框架

联合创作 · 2023-09-20 18:55

Cramp是一种新的,处 理并发事件的Web应用程序框架,由37signals和Rails核心小组的Pratik Naik提供。它建立在Ruby的EventMachine库之上,主要用于处理一些大量的开放连接 (如Comet系统或streaming APIs),整个过程都使用event-driven I/O。

Cramp使用Rails 3.0的ActiveSupport 和 ActiveModel库, 它会显示两层用于开发:controllers 和 models。

示例代码:

require 'rubygems'
require 'cramp/controller'

class WelcomeAction < Cramp::Controller::Action
on_start :send_hello_world

def send_hello_world
render "Hello World"
finish
end
end

Rack::Handler::Thin.run WelcomeAction, :Port => 3000

安装方法:

gem install arel --pre
gem install activemodel --pre

And then,

gem install cramp

 

浏览 13
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报