Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document the unix.socket communication protocol #1155

Open
shanduur opened this issue Nov 15, 2024 · 1 comment
Open

Document the unix.socket communication protocol #1155

shanduur opened this issue Nov 15, 2024 · 1 comment

Comments

@shanduur
Copy link

Hi! So I wanted to understand better how the comms between configuration server and e.g. CLI is supposed to work.

There is no documentation about this. I suppose right now it should work something like:

# 1. Open connection to the UNIX socket
connection = open_unix_socket("unix:///path/to/sozu.sock")

try:
    # 2. Serialize protobuf message
    #    - Object to Byte Array via protobuf libs?
    protobuf_message = create_protobuf_message()
    serialized_message = serialize_protobuf(protobuf_message)

    # 3. Write serialized message to the connection
    connection.write(serialized_message)

    # 4. Read response from the connection
    #    - How is it delimited? Just EOF?
    response_data = connection.read()

    # 5. Deserialize the protobuf message
    #    - Byte Array to Object via protobuf libs?
    deserialized_response = deserialize_protobuf(response_data)

    # Use the deserialized response as needed
    process_response(deserialized_response)

finally:
    # 6. Close the connection
    connection.close()
@Keksoj
Copy link
Member

Keksoj commented Nov 15, 2024

Hi, and firstly thank you for the PR on docker publication, we will look into it ;-)

Your insights on how to write to Sōzu are absolutely valid. Sōzu is thought to function as an API that takes protobuf-serialized messages on a UNIX socket, and returns protobuf-serialized messages on the same socket. The messages are defined in the command_lib

I think the best answer to your need will be the library sozu-client, a library we wrote at Clever Cloud to create side cars to Sōzu. It establishes a connection on the UNIX socket, serializes messages in protobuf, and awaits answers. See the send function

We have not documented an example to use sozu-client. But if you are familiar with Rust, you could create a PR on the sozu-client repository to create a simple client example in a new examples directory.

However, if you wish to use another language than Rust to implement a UNIX+protobuf communication with Sōzu, you would have to do so yourself.

Another idea would be to create a web side-car to Sōzu, by combining sozu-client and a web server in Rust, that would translate between UNIX-protobuf and HTTP-JSON for instance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants