sozu icon indicating copy to clipboard operation
sozu copied to clipboard

API clients in other languages

Open Geal opened this issue 7 years ago • 10 comments

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?

  • [X] Elixir client
  • [ ] Python client
  • [ ] Ruby client
  • [ ] Go client
  • [ ] NodeJS client
  • [ ] Java client
  • [ ] bash commands (because why not)

Geal avatar Apr 20 '17 13:04 Geal

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

clarenced avatar May 16 '17 09:05 clarenced

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 avatar May 21 '17 08:05 Geal

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

Geal avatar Jul 20 '17 15:07 Geal

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 🙂)

evuez avatar Jul 22 '17 09:07 evuez

@evuez great news!

Geal avatar Jul 24 '17 09:07 Geal

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.

NotBad4U avatar Sep 28 '17 13:09 NotBad4U

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 ?

rizrmd avatar Mar 26 '20 06:03 rizrmd

@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?

BlackYoup avatar Mar 31 '20 23:03 BlackYoup

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!

davidmaceachern avatar Nov 18 '20 13:11 davidmaceachern

@davidmaceachern this is great, thanks!

Geal avatar Nov 27 '20 09:11 Geal