On 19 December 2014 at 15:45, Yichun Zhang (agentzh) <
age...@gmail.com> wrote:
> > Everything that doesn't already have one of these lower level fd + events
> > APIs, can simply be converted to one.
>
> Sorry, after years of playing with raw fd and events, I really doubt it :)
I hope I can prove you wrong on this one. Do you have a particular example in mind?
> > Not everything is written with luasocket; and nor should it be.
> > Furthermore, luasocket apis become a mess as soon as you add SSL;
>
> The cosocket API already supports SSL/TLS :)
>
> > or more
> > than a single socket at a time.
>
> Have you checked out the ngx.thread API?
I was referring to protocol specific libraries and the LuaSocket API.
ngx.thread is yet another (fine) solution on that pile.
However, it is not easily available in other environments, and hence makes any resty based lua modules unportable.
> > Nested epolls/kqueues/etc fix this (which is part of what cqueues use
> > internally)
> >
>
> OpenResty uses epolls/kqueues/etc via the nginx event model already.
> What's the point here?
The point was that it doesn't have to stop at the C level.
Let Lua modules have their own epoll 'trees' to abstract fds inside a library.
> Yes, serving as an HTTP endpoint is OpenResty's main focus. But we
> recently found that it can naturally extend to other use cases without
> much troubles. Have you checked out the resty-cli project and the
> TCP/UDP server support in ngx_lua's TODO list? See
>
>
https://github.com/openresty/resty-cli
That's an interesting project; I will certainly be using it as part of our test suite for ngx_lua code.
> I'd like to see such things happen naturally without upsetting our
> existing (OpenResty) users.
I'm not sure how anything we've discussed would upset anyone?
This was a request to expose a lower level abstraction.
> I can buy the idea of a portable and generic Lua APIs that various
> different Lua-based systems can agree on. But I hope it to be high
> level enough so that we can give enough room and freedom for the
> implementors to decide the best implementation strategies. I hope we
> can have the best abstraction level here. Low level APIs are certainly
> not good abstractions at all IMHO. And for your cqueue API proposal, I
> don't buy it as the OpenResty maintainer due to practical
> considerations.
What are the considerations here?
> I'm not sure if you're an OpenResty user who wants to migrate his
> OpenResty Lua code over to other contexts or just a Lua developer who
> wants to migrate his whatever existing Lua code (running for other
> contexts) over to OpenResty. For the former case, I think you can just
> implement the same high level APIs (our cosockets, light threads, and
> etc) in the other context, with exactly the same semantics, optimized
> for your exotic new contexts, where the high level APIs can shine
> again :)
I write Lua in a wide range of contexts every day:
- I use ngx_lua for some high traffic http endpoints
- I write prosody plugins and maintain a significant XMPP deployment
- I maintain several lua libraries for use by others
- I regulary write lua scripts to accomplish administrative tasks
- I use embedded lua interpreters (e.g. Redis)
One of the most annoying issues I face is that there is so little overlap in the ecosystems.
If I want to use (e.g.) postgres, I have to figure out the idiosyncrasies of the particular postgres library available in that particular event loop.
They're all of varying quality => some are blocking, some use callbacks, some use coroutines, some have iterators, .... etc.
It's a hodge-podge where nothing built on top of them is portable.
When some new database comes along, each of these environments takes time to gain a client for it.
But most of the changes are too nginx specific for me to take them upstream.
However, I've found that the lowest common denominator in most environments is being able to ask the mainloop to watch an fd for me;
Furthermore, I can build things on top of it, and be assured they will work everywhere!
==> I can distribute a library that will work for the server admins, openresty users, prosody plugin writers, etc.
I'm really hoping that next time I write a client library for something, I only have to write it once.