sozu-proxy / sozu

Sōzu HTTP reverse proxy, configurable at runtime, fast and safe, built in Rust. It is awesome!
https://www.sozu.io/
GNU Affero General Public License v3.0
3.1k stars 191 forks source link

API clients in other languages #160

Open Geal opened 7 years ago

Geal commented 7 years ago

The command library allows easy communication with the proxy through its command unix socket.

The protocol is actually JSON messages separated by a null character, so it should be straightforward to make API clients in different languages. The protocol changed a lot lately, but it is stabilizing, and carries version information.

Those API clients would probably live in other repositories of this github organisation.

Who is up for it?

clarenced commented 7 years ago

Hello @Geal I want to contribute the java client version. Any idea how to start?

Geal commented 7 years ago

Hi! I'm the blocker here, since I should first export JSON messages with the new format. Or find a way to generate a JSON schema from configuration messages.

There's a good way to extract some config messages right now: launch a proxy with some static configuration like this: https://github.com/sozu-proxy/sozu/blob/master/bin/config.toml#L40-L49 then save the corresponding config messages with sozuctl -c config.toml state save -f state.json

You won't see the answers to config messages, but that's a good way to start and mess with the proxy.

I guess, to start, you should have a way to connect to a unix socket by its path, and send the JSON messages there. You can work with blocking or non blocking sockets, it should not be an issue.

Geal commented 7 years ago

There is a list of example messages and answers here: https://github.com/sozu-proxy/sozu/tree/master/command/assets It might change a bit before the release, but since those files are part of the unit tests, any change in the format will appear in those files

evuez commented 7 years ago

I just started an Elixir implementation, it's available here: https://github.com/evuez/exsozu (it's more of a draft for now so there isn't much to play with but I'm working on it 🙂)

Geal commented 7 years ago

@evuez great news!

NotBad4U commented 7 years ago

It's seem nodejs use SOCK_DGRAM to consume data for net.createConnection("pathto/command_folder/socket"). So we have to make a tiny library C/C++/Rust to make a SOCK_STREAM connection and call it in nodejs.

rizrmd commented 4 years ago

It's seem nodejs use SOCK_DGRAM to consume data for net.createConnection("pathto/command_folder/socket"). So we have to make a tiny library C/C++/Rust to make a SOCK_STREAM connection and call it in nodejs.

Hi, is there any progress about this ?

BlackYoup commented 4 years ago

@rizkyramadhan Hello, I'm pretty sure there was no progress on this one. Is this something in which you would be interested to jump-in?

davidmaceachern commented 3 years ago

The beginnings of a Nodejs client here .

From the manual testing I have done so far it appears to work, able to send and receive the status command to Sozu.

Interpreting the Nodejs documentation it has the following to say about the net module:

The net module provides an asynchronous network API for creating stream-based TCP or IPC servers ... The newly created socket can be either a TCP socket or a streaming IPC endpoint, depending on what it connect() to.

So we will see how this goes!

Geal commented 3 years ago

@davidmaceachern this is great, thanks!