-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve Streams IO docs #3127
Improve Streams IO docs #3127
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this is missing pictures, I think, that in general original doc is missing few things (i.e. BindAndHandle
method is very useful IMO, but totally ignored here, similarly JsonFraming
).
Also regarding example tests - have you actually tried to connect to a TCP server? I think that those scenarios should be verifiable using i.e. telnet command. This was the reason, why I haven't published this doc earlier.
{ | ||
|
||
#region echo-server-simple-bind | ||
var tcp = new TcpExt(Sys.AsInstanceOf<ExtendedActorSystem>()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is ugly API (it should be hidden IMHO). Sys.TcpStream()
looks a lot better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok :)
@Horusiath We also missed .NET Streams (MemoryStream, FileStream, etc) |
@Horusiath I've added images added an example with Still working on the rest two examples |
@@ -144,6 +145,7 @@ public class TcpExt : IExtension | |||
/// TBD | |||
/// </summary> | |||
/// <param name="system">TBD</param> | |||
[InternalApi] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made it internal
|
||
We can then test the TCP server by sending data to the TCP Socket using `netcat` (on Windows it is possible to use Linux Subsystem for Windows): | ||
``` | ||
echo -n "Hello World" | netcat 127.0.0.1 8888 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
netcat is not available on Windows by default (or by Git bash). Have you tried to use it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
|
||
string ReadLine(string prompt) | ||
{ | ||
// TODO: implement it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have no idea how to convert it to C#
val input = new AtomicReference("Hello world" :: "What a lovely day" :: Nil)
def readLine(prompt: String): String = {
input.get() match {
case all @ cmd :: tail if input.compareAndSet(all, tail) => cmd
case _ => "q"
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a very convoluted way of having concurrent queue with 2 elements in it ("Hello world", "What a lovely day") and dequeueing those elements in thread safe fashion. Once a readLine
hits an empty queue a "q"
string is returned instead of normal content.
More or less the code would be:
var input = new ConcurrentQueue<string>(new[] { "Hello world", "What a lovely day" });
string ReadLine(string prompt) => input.TryDequeue(out var cmd) ? cmd : "q";
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, It works now
Approvals API needs to be updated. |
72a939b
to
8e8a842
Compare
still missing API approval |
Fixed: #3109