2014-11-29

draw msgflow in reactive app





cpp_idioms.org



usually we got log like following:
[sys1] ---->   [sys2] 00001  MSG_0  0x00010002 0x00030004
[sys2] ---->   [sys3] 00002  MSG_1  0x00010002 0x00030004
[sys3] ---->   [sys1] 00003  MSG_2  0x00010002 0x00030004

but a diagram like following is more readable:
sys1   sys2   sys3   
  |----->|      |     MSG_0   [0x00010002 0x00030004]
  |      |----->|     MSG_1   [0x00010002 0x00030004]
  |<------------|     MSG_2   [0x00010002 0x00030004]

I implemented a simple app to draw this diagram: https://github.com/whunmr/msgflow

more complicated diagram generated from log:
ss3   kk3   zz1   qq1   qq2   kk1   bb1   aa1   ss1   
 |     |     |     |     |     |     |     |     *     MSG_0   [1] [0x00010002 0x00030004]
 |     |     |     |     |     |     |     |<----|     MSG_1   [2] [0x00010002 0x00030004]
 |     |     |     |     |     |     |     |---->|     MSG_2   [3] [0x00010002 0x00030004]
 |     |     |     |     |     |<----|     |     |     MSG_3   [4] [0x00010002 0x00030004]
 |     |     |     |     |     |---------------->|     MSG_4   [5] [0x00010002 0x00030004]
 |     |     |     |     |     |<----------------|     MSG_5   [6] [0x00010002 0x00030004]
 |     |     |     |     |     |     |     |<----|     MSG_6   [7] [0x00010002 0x00030004]
 |     |     |     |     |<----------------------|     MSG_7   [8] [0x00010002 0x00030004]
 |     |     |<----|     |     |     |     |     |     MSG_8   [9] [0x00010002 0x00030004]
 |     |     |---------------------------->|     |     MSG_9   [10] [0x00010002 0x00030004]
 |     |     |     |     |     |     |     |---->|     MSG_2   [11] [0x00010002 0x00030004]
 |     |<----------------------------|     |     |     MSG_3   [12] [0x00010002 0x00030004]
 |     |     |     |     |     |---------------->|     MSG_4   [13] [0x00010002 0x00030004]
 |     |<----------------------------------------|     MSG_5   [14] [0x00010002 0x00030004]
 |---------------------------------------->|     |     MSG_6   [15] [0x00010002 0x00030004]
 |---------------->|     |     |     |     |     |     MSG_7   [16] [0x00010002 0x00030004]
 |     |     |<----------------------------------|     MSG_8   [17] [0x00010002 0x00030004]
 |     |     |---------------------------------->|     MSG_9   [18] [0x00010002 0x00030004]

 


DSL for reactive application implementation in C++





cpp_idioms.org



def_mi(Basic_mi_x) {
                                         step(sync_call_1);
                                         step(sync_call_2);
        sysd<----------------------------async_step(async_call_1) {
                sysd-------------------->ack(msg_ack_1, on_msg_ack_1);
                sysd-------------------->ack(msg_ack_2, on_msg_ack_2);
                
                sysd-------------------->ack_ex(msg_ack_4)
                {
                                         step(sync_call_nested_1);
                        sysx<------------async_step(nested_async_call_1)
                        {
                                sysx---->ack(nested_msg_ack_1, on_nested_msg_ack_1);
                                sysx---->ack(nested_msg_ack_2, on_nested_msg_ack_2);
                                sysx---->ack(msg_ack_1, on_nested_msg_ack_3);            
                        } async_step_end;
                } on_msg_ack_ex_end;
        }async_step_end;
} def_mi_end;


https://github.com/whunmr/reactive_cpp