Created
August 14, 2018 00:14
-
-
Save autodidaddict/799cef0fffce8d564a5b692233b799a6 to your computer and use it in GitHub Desktop.
Ballerina workers sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ballerina/io; | |
function main(string... args) { | |
stream<string> userInput; | |
fork { | |
worker stdin_read { | |
while(true) { | |
io:println("Type something:"); | |
string s = io:readln(()); | |
userInput.publish(s); | |
} | |
} | |
worker echo1 { | |
userInput.subscribe((string s) => { | |
string smod = "[ECHO 1] " + s; | |
io:println(smod); | |
}); | |
} | |
worker echo2 { | |
userInput.subscribe((string s) => { | |
string smod = "[ECHO 2] " + s; | |
io:println(smod); | |
}); | |
} | |
} join(all) (map results) { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment