File tree Expand file tree Collapse file tree 1 file changed +34
-1
lines changed
Expand file tree Collapse file tree 1 file changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,40 @@ Data only needs to be serialisable when explicitly send to other processes.
2525
2626# Code Example
2727
28- <<< @../../malstrom-core/examples/look_ma_im_streaming.rs
28+ ``` rust
29+ // ! Stream processing can be easy!
30+ use malstrom :: operators :: * ;
31+ use malstrom :: runtime :: MultiThreadRuntime ;
32+ use malstrom :: sinks :: {StatelessSink , StdOutSink };
33+ use malstrom :: snapshot :: NoPersistence ;
34+ use malstrom :: sources :: {SingleIteratorSource , StatelessSource };
35+ use malstrom :: worker :: StreamProvider ;
36+
37+ fn main () {
38+ MultiThreadRuntime :: builder ()
39+ . persistence (NoPersistence )
40+ . parrallelism (1 )
41+ . build (build_dataflow )
42+ . execute ()
43+ . unwrap ();
44+ }
45+
46+ fn build_dataflow (provider : & mut dyn StreamProvider ) {
47+ provider
48+ . new_stream ()
49+ . source (
50+ " words" ,
51+ StatelessSource :: new (SingleIteratorSource :: new ([
52+ " Look" ,
53+ " ma'" ,
54+ " I'm" ,
55+ " streaming" ,
56+ ])),
57+ )
58+ . map (" upper" , | x | x . to_uppercase ())
59+ . sink (" stdout" , StatelessSink :: new (StdOutSink ));
60+ }
61+ ```
2962
3063This outputs
3164
You can’t perform that action at this time.
0 commit comments