码迷,mamicode.com
首页 > Web开发 > 详细

Faye,Simple pub/sub messaging for the web

时间:2014-09-23 12:12:24      阅读:192      评论:0      收藏:0      [点我收藏+]

标签:网络   node.js   pubsub   

参考资料

http://faye.jcoglan.com/

  

bubuko.com,布布扣

  

Faye is a publish-subscribe messaging system based on the Bayeux protocol/CometD. It provides message servers for Node.js and Ruby, and clients for use on the server and in all major web browsers.

  

  

系统架构

bubuko.com,布布扣

  

  

组件

功能

Storage

存储内容

  • 活跃client的id
  • 订阅信息
  • queued message to be delivered to clients

存储方式

  • memory engine
  • redis engine

Engine

Storage的抽象层,实现了Faye的所有服务

  • client registering
  • storing subscriptions
  • routing messages

Server

实现了Bayeus 协议,操作集

  • handshake
  • connect
  • disconnect
  • subscribe
  • unsubscribe
  • publish

Server无HTTP或其他任何网络传输技术有关

Server-side extendsions

扩展层,可以拦截incoming/outgoing message

Adapter

通过HTTP提供Server的服务,负责以JSON方式序列化和反序列化message;

连接处理

  • 基于WebSocket的持久连接
  • 基于HTTP POST的long polling
  • CORS(Cross Origin Resource sharing)
  • JSONP

两个实现:NodeAdapter, RackAdapter

Transport

客户端的network transport,负责通信和JSON的序列化和反序列化以及网络故障的检测和恢复

  • Websocket实时性强
  • long polling / JSONP只能依赖超时

client-side extensions

类似于Server-side extendsions

client

提供subscribe/unsubscribe, send/receive message的接口,实现了Bayeux protocol,用户不需要处理handshake 和 connect等底层操作

  

  

Cluster支持

bubuko.com,布布扣

这种结构中的Storage采用Redis。Server是无状态,方便水平扩展,简化路由(使用随机/rr策略即可)。

  

  

使用简单

bubuko.com,布布扣

  

使用类似socket.io

  

Faye,Simple pub/sub messaging for the web

标签:网络   node.js   pubsub   

原文地址:http://blog.csdn.net/icode0410/article/details/39494977

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!