You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[...]
These are the tell-tale signs of a sans-IO design. Instead of sending and receiving bytes via a socket in multiple places, our protocols are implemented as pure state machines. Even time is abstracted away: every function that needs to know the current time receives an Instant parameter instead of calling Instant::now itself.
[...]
The dependency inversion principle says that policies (what to do) should not depend on implementation details (how to do it). Instead, both components should depend and communicate via abstractions. In other words, the piece of code that decides to send a message on the network (i.e. the policy) should not depend on the code that actually sends the message (i.e. the implementation).
[...]
sans-IO code is essentially side-effect free and thus lends itself extremely well for (unit) tests. Due to sockets and time being abstracted away, it becomes a breeze to write tests that advance time by 5 minutes in an instant. All we need to do is pass a modified Instant to our function and assert, how the code behaves. [...] n a sans-IO world, "sending data" in a test is as simple as taking a Transmit from party B and calling handle_input on the state of party A. No need to go through a network socket!
[...]
We implemented a reference state machine that describes how we want connlib to work. This reference state machine is used as the source of truth in our tests. We then leverage proptest's support for state machine testing to deterministically sample and execute thousands of scenarios on every CI run and compare the reference state machine with connlib's actual state.
I think using such architecture would help resolve issues like #2410 .
It also contains my 2 favorite elements: state machines and dependency injection ;)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi! Long time time no see :)
I have something worth reading: https://www.firezone.dev/blog/sans-io
Few quotes:
I think using such architecture would help resolve issues like #2410 .
It also contains my 2 favorite elements: state machines and dependency injection ;)
Beta Was this translation helpful? Give feedback.
All reactions