Skip to content
Newer
Older
100644 155 lines (87 sloc) 2.23 KB
276ae9f @substack slides mostly fleshed out
authored
1 # harnessing streams
2
3 ![harnessing streams](images/harnessing_streams.png)
4
5 # the way of IO
6
7 "We should have some ways of connecting programs like garden hose--screw in
8 another segment when it becomes when it becomes necessary to massage data in
9 another way. This is the way of IO also."
10
11 Doug McIlroy. October 11, 1964
12 http://cm.bell-labs.com/who/dmr/mdmpipe.html
13
14 ![garden hose](images/garden_hose.png)
15
16 # readable
17
18 * fs.createReadStream()
19
c74690c @substack example navigator
authored
20 ![readable](images/readable.png)
21
276ae9f @substack slides mostly fleshed out
authored
22 `example/readable`
23
24 # writable
25
26 * fs.createWriteStream()
27 * concat-stream
28 * delta-stream
29
c74690c @substack example navigator
authored
30 ![writable](images/writable.png)
31
276ae9f @substack slides mostly fleshed out
authored
32 `example/writable`
33
34 # through streams
35
36 input to output
37
38 filters, buffering
39
40 * zlib.createGzip()
41 * through
42
c74690c @substack example navigator
authored
43 ![through](images/through.png)
44
276ae9f @substack slides mostly fleshed out
authored
45 `example/through`
46
47 ## buffering
48
49 * pause-stream
50
51 ![pause-stream](images/pause_stream.png)
52
53 `example/buffering`
54
55 ## throttling
56
57 * (throttling lib)
58
59 ## parser/serialization streams
60
61 * JSONStream
62 * stream-serializer
63 * trumpet
64 * tap
65
66 `example/JSONStream`
67
68 # duplex streams
69
70 Back and forth, like a telephone.
71
72 ![duplex streams](images/duplex_streams.png)
73
74 When you see `a.pipe(b).pipe(a)` you've probably got a duplex stream.
75
76 ![a.pipe(b).pipe(a)](images/a_pipe_b_pipe_a.png)
77
78 * duplexer
79
80 `example/duplexer`
81
82 ![duplexer](images/duplexer.png)
83
84 * http-duplexer
85
86 ## rpc
87
88 * dnode
89
90 ![dnode](images/dnode.png)
91
92 `example/dnode`
93
94 ## state synchronization
95
96 * scuttlebutt
97
98 ![scuttlebutt](images/scuttlebutt.png)
99
100 ![gossip protocol](images/gossip_protocol.png)
101
c74690c @substack example navigator
authored
102 (use case: web server peering)
103
276ae9f @substack slides mostly fleshed out
authored
104 `example/scuttlebutt`
105
106 # event streams
107
108 * emit-stream
109
c74690c @substack example navigator
authored
110 ![emit-stream](images/emit_stream.gif)
276ae9f @substack slides mostly fleshed out
authored
111
112 `example/emit-stream`
113
114 # streams inside streams
115
116 * mux-demux
117
118 ![mux-demux](images/mux-demux.png)
119
120 `example/mux-demux`
121
122 # streams in the browser
123
124 * browserify
125 * shoe
126 * domnode
127 * sorta
128 * graph-stream
129
c74690c @substack example navigator
authored
130 ![shoe](images/shoe.png)
131
276ae9f @substack slides mostly fleshed out
authored
132 `example/shoe`
133
134 # freestyle stream livecoding demo
135
136 let's build a streaming webapp that:
137 * synchronizes state across all users
138 * listens on a server-side event emitter
139 * has an rpc control interface
e759252 @substack emit stream example
authored
140 * all as streams over mux-demux
141 * in node and the browser
c77950a @substack up to synced box movement in the freestyle example
authored
142 * across multiple servers
276ae9f @substack slides mostly fleshed out
authored
143
e759252 @substack emit stream example
authored
144 ![eof](images/freestyle.png)
c74690c @substack example navigator
authored
145
276ae9f @substack slides mostly fleshed out
authored
146 `example/freestyle`
147
148 1. npm install all the things
149
150 2. write the code
151
152 3. the third step is you're done
c74690c @substack example navigator
authored
153
154 ![eof](images/process_exit.png)
Something went wrong with that request. Please try again.