salesforce / runway-compiler

Parses and executes Runway models of distributed systems
https://runway.systems
MIT License
50 stars 11 forks source link

Add `network` basic type to language? #13

Open dgryski opened 8 years ago

dgryski commented 8 years ago

Most people modelling distributed systems are going to want to have some sort of communication channel. Already in the raft and bookkeeper specification, there's a network set, with the sendMessage primitive, some code for dropping messages, and the handleMessage() main loop.

As I was starting to model https://en.wikipedia.org/wiki/Two-phase_commit_protocol , I realized I was going to want these exact same routines so my Coordinator could talk to the Cohorts.

Should this type be somehow integrated into the main language to allow these sorts of models to be created more easily?

(Promela, for example, based on https://en.wikipedia.org/wiki/Communicating_sequential_processes , has a channel type http://spinroot.com/spin/Man/chan.html )

ongardie-sfdc commented 8 years ago

(Sorry for the delay.)

It does seem silly to not have some reusable network. I wonder if the network really needs to be special, or if it's a common instance of a need for reusable modules. Is 2PC's need for a network different than X's need for a 2PC component?

dgryski commented 8 years ago

I would assume the basic API for a network would be the same, and you might want parameters for maximum delay / packet loss.

A reusable module would also work. My thought for making it a language builtin would only make sense if it turned out we wanted to use it in with special syntax.

ongardie-sfdc commented 8 years ago

A reusable module would also work. My thought for making it a language builtin would only make sense if it turned out we wanted to use it in with special syntax.

Even then, we might want a regular module with unpleasant syntax, plus some black magic baked into the compiler for syntactic sugar.

ongardie commented 8 years ago

Slightly relevant: Backpack proposal for Haskell https://github.com/ghc-proposals/ghc-proposals/pull/5