This is an automated email from the ASF dual-hosted git repository.
jensg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/thrift.git
The following commit(s) were added to refs/heads/master by this push:
new bee4f2f THRIFT-5053: Fix the netstd tutorial console logging and
README Client: netstd Patch: Kengo Seki
bee4f2f is described below
commit bee4f2fd69db32621addd9353ab0aa2e2ba94349
Author: Kengo Seki <[email protected]>
AuthorDate: Sun Dec 29 17:04:50 2019 +0900
THRIFT-5053: Fix the netstd tutorial console logging and README
Client: netstd
Patch: Kengo Seki
This closes #1970
---
tutorial/netstd/Client/Program.cs | 29 ++++++++++++++++-------------
tutorial/netstd/README.md | 26 +++++++++++---------------
tutorial/netstd/Server/Program.cs | 36 +++++++++++++++++++-----------------
tutorial/netstd/build.sh | 0
4 files changed, 46 insertions(+), 45 deletions(-)
diff --git a/tutorial/netstd/Client/Program.cs
b/tutorial/netstd/Client/Program.cs
index 857b3e8..eefccf7 100644
--- a/tutorial/netstd/Client/Program.cs
+++ b/tutorial/netstd/Client/Program.cs
@@ -46,10 +46,10 @@ namespace Client
{
Logger.LogInformation(@"
Usage:
- Client.exe -help
+ Client -help
will diplay help information
- Client.exe -tr:<transport> -bf:<buffering> -pr:<protocol> -mc:<numClients>
+ Client -tr:<transport> -bf:<buffering> -pr:<protocol> -mc:<numClients>
will run client with specified arguments (tcp transport and binary
protocol by default) and with 1 client
Options:
@@ -74,7 +74,7 @@ Options:
<numClients> - number of multiple clients to connect to server (max
100, default 1)
Sample:
- Client.exe -tr:tcp -p:binary
+ Client -tr:tcp -pr:binary
");
}
@@ -83,19 +83,22 @@ Sample:
args = args ?? new string[0];
ServiceCollection.AddLogging(logging => ConfigureLogging(logging));
- Logger =
ServiceCollection.BuildServiceProvider().GetService<ILoggerFactory>().CreateLogger(nameof(Client));
-
- if (args.Any(x => x.StartsWith("-help",
StringComparison.OrdinalIgnoreCase)))
+ using (var serviceProvider =
ServiceCollection.BuildServiceProvider())
{
- DisplayHelp();
- return;
- }
+ Logger =
serviceProvider.GetService<ILoggerFactory>().CreateLogger(nameof(Client));
+
+ if (args.Any(x => x.StartsWith("-help",
StringComparison.OrdinalIgnoreCase)))
+ {
+ DisplayHelp();
+ return;
+ }
- Logger.LogInformation("Starting client...");
+ Logger.LogInformation("Starting client...");
- using (var source = new CancellationTokenSource())
- {
- RunAsync(args, source.Token).GetAwaiter().GetResult();
+ using (var source = new CancellationTokenSource())
+ {
+ RunAsync(args, source.Token).GetAwaiter().GetResult();
+ }
}
}
diff --git a/tutorial/netstd/README.md b/tutorial/netstd/README.md
index 297f4ee..a49fb47 100644
--- a/tutorial/netstd/README.md
+++ b/tutorial/netstd/README.md
@@ -13,13 +13,13 @@
# How to run
-Depending on the platform, the name of the generated executables will vary. On
Linux, it is just "client" or "server", on Windows it is "Client.exe" and
"Server.exe". In the following, we use the abbreviated form "Client" and
"Server".
+Depending on the platform, the name of the generated executables will vary. On
Linux, it is just "Client" or "Server", on Windows it is "Client.exe" and
"Server.exe". In the following, we use the abbreviated form "Client" and
"Server".
- build
- go to folder (Client/Server)
- run the generated executables: server first, then client from a second
console
-#Known issues
+# Known issues
- In trace logging mode you can see some not important internal exceptions
# Running of samples
@@ -29,10 +29,10 @@ On machines that do not have the SDK installed, you need to
install the NET Core
Usage:
- Server -h
+ Server -help
will diplay help information
- Server -tr:<transport> -pr:<protocol>
+ Server -tr:<transport> -pr:<protocol>
will run server with specified arguments (tcp transport and binary
protocol by default)
Options:
@@ -52,7 +52,8 @@ Options:
binary - (default) binary protocol will be used
compact - compact protocol will be used
json - json protocol will be used
-
+ multiplexed - multiplexed protocol will be used
+
Sample:
Server -tr:tcp
@@ -68,7 +69,7 @@ Sample:
Usage:
- Client -h
+ Client -help
will diplay help information
Client -tr:<transport> -pr:<protocol> -mc:<numClients>
@@ -91,7 +92,8 @@ Options:
binary - (default) binary protocol will be used
compact - compact protocol will be used
json - json protocol will be used
-
+ multiplexed - multiplexed protocol will be used
+
-mc (multiple clients):
<numClients> - number of multiple clients to connect to server (max
100, default 1)
@@ -237,16 +239,10 @@ class CalculatorHandler:
val = work.Num1 * work.Num2
elif work.Op == Operation.Divide:
if work.Num2 == 0:
- x = InvalidOperation()
- x.WhatOp = work.Op
- x.Why = 'Cannot divide by 0'
- raise x
+ raise InvalidOperation(work.Op, 'Cannot divide by 0')
val = work.Num1 / work.Num2
else:
- x = InvalidOperation()
- x.WhatOp = work.Op
- x.Why = 'Invalid operation'
- raise x
+ raise InvalidOperation(work.Op, 'Invalid operation')
log = SharedStruct()
log.Key = logid
diff --git a/tutorial/netstd/Server/Program.cs
b/tutorial/netstd/Server/Program.cs
index c1e0cb3..3181e8e 100644
--- a/tutorial/netstd/Server/Program.cs
+++ b/tutorial/netstd/Server/Program.cs
@@ -51,26 +51,28 @@ namespace Server
args = args ?? new string[0];
ServiceCollection.AddLogging(logging => ConfigureLogging(logging));
- Logger =
ServiceCollection.BuildServiceProvider().GetService<ILoggerFactory>().CreateLogger(nameof(Server));
+ using (var serviceProvider =
ServiceCollection.BuildServiceProvider())
+ {
+ Logger =
serviceProvider.GetService<ILoggerFactory>().CreateLogger(nameof(Server));
+ if (args.Any(x => x.StartsWith("-help",
StringComparison.OrdinalIgnoreCase)))
+ {
+ DisplayHelp();
+ return;
+ }
- if (args.Any(x => x.StartsWith("-help",
StringComparison.OrdinalIgnoreCase)))
- {
- DisplayHelp();
- return;
- }
+ using (var source = new CancellationTokenSource())
+ {
+ RunAsync(args, source.Token).GetAwaiter().GetResult();
- using (var source = new CancellationTokenSource())
- {
- RunAsync(args, source.Token).GetAwaiter().GetResult();
+ Logger.LogInformation("Press any key to stop...");
- Logger.LogInformation("Press any key to stop...");
+ Console.ReadLine();
+ source.Cancel();
+ }
- Console.ReadLine();
- source.Cancel();
+ Logger.LogInformation("Server stopped");
}
-
- Logger.LogInformation("Server stopped");
}
private static void ConfigureLogging(ILoggingBuilder logging)
@@ -84,10 +86,10 @@ namespace Server
{
Logger.LogInformation(@"
Usage:
- Server.exe -help
+ Server -help
will diplay help information
- Server.exe -tr:<transport> -bf:<buffering> -pr:<protocol>
+ Server -tr:<transport> -bf:<buffering> -pr:<protocol>
will run server with specified arguments (tcp transport, no buffering,
and binary protocol by default)
Options:
@@ -109,7 +111,7 @@ Options:
multiplexed - multiplexed protocol will be used
Sample:
- Server.exe -tr:tcp
+ Server -tr:tcp
");
}
diff --git a/tutorial/netstd/build.sh b/tutorial/netstd/build.sh
old mode 100644
new mode 100755