bastion-rs / artillery

Fire-forged cluster management & Distributed data protocol
https://artillery.bastion-rs.com
Apache License 2.0
73 stars 10 forks source link

Replaced JSON & strings with bincode #53

Closed Dherse closed 9 months ago

Dherse commented 2 years ago

Update to message and packet content

This PR changes the way messages are sent between nodes, it replaces the usage of JSON and String-based payload with bincode based payloads. The ultimate goal of this change is to allow bastion to exchange serialized messages instead of text between cluster members.

Impact

This fairly simple change has a few positive and negative impacts:

The pros

The cons

Tests

Currently, I have not written additional tests for this, however, with the additional work I have done on bastion and the showcase repos (forks on my account), it works as expected. And existing tests seem to run fine.

User facing changes

The breaking changes that appear are the following:

This changes do have consequences for people using these features as they completely change the responsability of the user. Instead of having to "prepare"/serialize the data externally, it is now done internally. I belive this change is logical as serde is a very widely used crate. However, this could be changed by adding a Cluster::send_raw_payload that takes a Vec<u8> instead of a message and sends that instead.

Checklist
o0Ignition0o commented 2 years ago

This is looking good! Is there a chance we can use Bytes instead of Vec ?

Dherse commented 2 years ago

This is looking good! Is there a chance we can use Bytes instead of Vec ?

I think this should be doable. Ideally, we wouldn't need to allocate that Vec or any other underlying data structure but I am unsure how one would go about implementing that. I will have a look at it when I get back home :)

My understanding is that Bytes (I am assuming from the bytes crate) should implement Read & Write. Worst case scenario, a simple shim can be written on top of it to implement that.

Dherse commented 2 years ago

First and foremost, sorry for taking so long, I only had time to look at it today in the end.

I have done a couple of commits changing the implementation and here are a few takeaways:

Therefore, the only way of making bytes worth it would be to do some manual (de)serializing and using bytes through there allowing more re-use.

Tell me what you think, this can be things that are worked on but I'm fairly limited on time lately :(

o0Ignition0o commented 2 years ago

Hey, no worries at all really, this is OSS and we do it when we have time, no pressure at all :)

Let's keep it as is, i m ready to review as soon as it looks good to you :)

vertexclique commented 2 years ago

I am interested in this. FYI. Looking for a gated bincode impl.

Dherse commented 2 years ago

I am interested in this. FYI. Looking for a gated bincode impl.

Hey, I am sorry for not coming back to this sooner, I had been busy and I should have finished this instead of letting this inactive for months. For this I apologize. I am currently on holiday and I will try and do two things:

Again, sorry for the delay, I hope to finish this in a timely matter to both improve artillery and finish the work I started.