是否有一套完整的mysql-proxy lua脚本文档?

发布于 2024-10-20 15:15:32 字数 1274 浏览 2 评论 0原文

我正在为 mysql-proxy 编写脚本。我想要完成的事情是无关紧要的。然而,我发现 lua 接口的某些元素似乎没有记录。我拥有的最大的“确凿证据”是 disconnect_client() 钩子。我在官方文档中找不到它的记录,尽管它在解释的示例中使用管理界面。它也在示例文档中广泛使用。快速 grep 显示了它在 5.5.8 发行版中包含的以下脚本中的用法:

active-queries.lua
活动交易.lua
加载multi.lua
ro-pooling.lua
rw-splitting.lua
教程-keepalive.lua

引起我注意的另一个示例是 proxy.global.backends 表中条目的属性列表。 文档列出了以下属性:

dst.name
dst.address
dst.port
connected_clients
state
type

然而,几个示例脚本引用了一个相当复杂的元素,称为池。以tutorial-keepalive.lua为例:

local s = proxy.global.backends[i]
local pool     = s.pool
local cur_idle = pool.users[proxy.connection.client.username].cur_idle_connections

起初我以为它被添加到lua中的其他地方,但我查看了一下,找不到任何分配到proxy.global.backends的代码[i].池。

所以,我想有两个问题:

  1. 我疯了吗?请随意演示我如何忽略了显而易见的事情,并且文档确实非常清晰。
  2. 假设我是正确的,有没有地方可以找到完整的文档?一个好的链接会很棒(虽然我无法通过谷歌搜索),但甚至“从定义接口的 mysql-proxy 发行版中查看这个 .c 文件”。至少这会给我一些东西可以戳。

谢谢

I am playing with scripting for mysql-proxy. What I am trying to accomplish is irrelevant. What I am finding, however, is that there appears to be elements of the lua interface that are undocumented. The big "smoking gun" I have is the disconnect_client() hook. I cannot find it documented anywhere in the official documentation, though it's used in an example on the explanation of the admin interface. It's also used extensively in the example docs. A quick grep shows its use in the following scripts included in the 5.5.8 distribution:

active-queries.lua
active-transactions.lua
load-multi.lua
ro-pooling.lua
rw-splitting.lua
tutorial-keepalive.lua

My other example that has caught my eye is the list of attributes for entries in the proxy.global.backends table. The documentation lists the following attributes:

dst.name
dst.address
dst.port
connected_clients
state
type

However, several of the example scripts reference a fairly complex element called pool. Take for instance tutorial-keepalive.lua:

local s = proxy.global.backends[i]
local pool     = s.pool
local cur_idle = pool.users[proxy.connection.client.username].cur_idle_connections

At first I thought it was being added somewhere else in the lua, but I've looked and I can't find any code assigning into proxy.global.backends[i].pool.

So, two questions I suppose:

  1. Am I nuts? Please feel free to demonstrate how I've overlooked the obvious and the documentation is really quite clear.
  2. Assuming I am correct, is there anywhere to find the complete documentation? A nice link would be great (though I couldn't google one up), but even "take a look at this .c file from the mysql-proxy distro that defines the interface". At least that would give me something to poke at.

Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

在风中等你 2024-10-27 15:15:32

自己刚刚打开Proxy/Lua。恐怕,就像 Mysql 的所有事情一样,一旦你深入了解,你就只能靠自己了。 LUA 也是如此。
您将需要 LUA 的其他插件来完成您想做的事情,我建议:
http://peterodding.com/code/lua/apr/docs/#shared_memory
对于 Apache Protable 库绑定...节省了我大量的时间。
至于 MySql 的内部结构,您可能需要查看 C 源文件,遗憾的是,因为我们处于未开发的领域。

我发现的一件事是Mysql中的LUA结构不是Lua表,而是Lua“用户数据”。这意味着它们实际上是共享内存,因此 Lua 无法更改它们,因为 Mysql 也使用它们。我将尝试 luaposix 库,看看是否可以获取它们,因为如果可能的话,我想更改一些元素。

祝你好运

[电子邮件受保护]

Just opened Proxy/Lua myself. I'm afraid, as with all things Mysql, once you dip under the covers you are on your own. The same goes for LUA.
You will need other addons to LUA to do what you want to do, I would like to suggest:
http://peterodding.com/code/lua/apr/docs/#shared_memory
for the Apache Protable library binding... saved me a shedload of time.
As for the internals of MySql, you will probably need to look in teh C source files, sadly, as we are in unexplored territory here.

One thing I have found is that the LUA structures in Mysql are not Lua tables, but Lua 'user data'. This means that they are effectively shared memory, so are not changeable by Lua, as Mysql uses them too. I am going to try the luaposix library to see if I can get inbto them, as there are elements I would like to change, if possible.

Good luck

[email protected]

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文