Cloud messages for Load81
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 25/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
调研方向
该 issue 定义了 listen()、unlisten()、receive() 和 send() 入口点,并描述了基于非阻塞套接字的 Redis pub/sub。首先定位这些入口点以及事件处理/套接字代码,然后验证所述的 API 行为和消息排队。完成的标准是 Load81 实例能够通过已订阅的 channel 交换序列化消息,同时不会接收到自己的消息。
由索引模型根据 Issue 内容生成。
描述
Load81 programs are currently self-contained into a box without the ability to talk with the external world.
Specifically they can't talk with other instances of the same program running in other Load81 instances around the world! What a shame. So what I'm proposing and implementing is a Cloud message service for Load81.
API
A Load81 program listen to channels using the listen() function. Multiple calls to listen are allowed in order to listen to multiple channels, and it is also possible to no longer listen to a given channel using unlisten(). Example:
listen("asteroids")
listen("foo","bar")
unlisten("asteroids")
Every time a message is received the function receive is called. It is important to understand how this works. The normal flow of a Load81 program is to call setup the first time, and then call draw. When the program is listening to one or more channels, the function receive is called before the function draw is called, and is called for all the pending messages currently in the queue, so for instance you may have 5 calls to receive, and finally the call to draw, and so forth.
This is how the function receive is defined in a program:
function receive(sender,channel,msg)
....
end
The three arguments are:
- sender: a 40 chars hex string that uniquely identifies the sender instance (this instance ID changes at every run).
- channel: the channel that received the message.
- msg: a Lua object (number, string, table, boolean, ...)
You don't receive messages that are sent by your instance.
In order to send messages you simply use:
send("channel",lua_object)
You can send messages to channels you are not listening without problems if you wish.
Implementation
The implementation using a Redis instance running at pubsub.load81.com, with only PUBLISH and SUBSCRIBE commands enabled. The instance is configured to drop clients that reached an output buffer of a few hundred kbytes so that it is not possible to abuse the instance just listening to channels without actually reading data.
Every Load81 instance creates a random identifier at startup, either reading from /dev/urandom or using a mix of time and rand() if urandom is not available.
Messages are send to Redis as <Instance ID>:<MessagePack representation of the Lua object sent>.
Messages are both sent and received using a non blocking socket. At every iteration we read what's new in the socket, and call a function that will put all the entire messages in the queue, parsing the Redis protocol.
From the point of view of sending, we'll try to send messages every time the user calls the send() function in order to minimize latency, but if there is no room on the kernel socket buffer we'll bufferize the write and send it when possible (at the next iteration of the event processor, that is, by default, 30 times per second).
Abuses
From the outside attacker this is a free message hub, but I think it's fine since for instance an IRC server has the same problem.... and I think no one will try to abuse this stuff, at least I hop.
- 主要语言
- C
- 星标
- 743
- 派生
- 65
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
antirez/load81 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 25/100
-
难度 3/5 1-2 天 新手友好度 35/100
-
难度 3/5 1-2 天 新手友好度 30/100
-
难度 4/5 3-5 天 新手友好度 35/100
-
难度 4/5 3-5 天 新手友好度 35/100
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 80/100
openziti/ziti-sdk-c#1254 ·
维护者通常 1 天内回复
-
http_fetch tests: the two no-child rows fail, not skip, where a task's children file does not exist可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭area:http kind:gate-defect
难度 2/5 1-3 小时 新手友好度 82/100
InauguralSystems/EigenScript#2397 ·
维护者通常 1 天内回复
-
Add SECURITY.md未关闭enhancement
难度 1/5 1-3 小时 新手友好度 65/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 74/100
-
modem: ppp: CMUX DLCI receive buffer overruns on large downlink packets可能已有人在做 @pedrohqr 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 84/100
zephyrproject-rtos/zephyr#126195 ·
维护者通常 3 天内回复