Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
1ba7e5d8
Commit
1ba7e5d8
authored
8 years ago
by
Jan Tattermusch
Browse files
Options
Downloads
Patches
Plain Diff
regenerate
parent
48429044
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/csharp/helloworld-from-cli/Greeter/Helloworld.cs
+32
-5
32 additions, 5 deletions
examples/csharp/helloworld-from-cli/Greeter/Helloworld.cs
examples/csharp/helloworld-from-cli/Greeter/HelloworldGrpc.cs
+47
-26
47 additions, 26 deletions
...ples/csharp/helloworld-from-cli/Greeter/HelloworldGrpc.cs
with
79 additions
and
31 deletions
examples/csharp/helloworld-from-cli/Greeter/Helloworld.cs
+
32
−
5
View file @
1ba7e5d8
...
...
@@ -10,7 +10,6 @@ using scg = global::System.Collections.Generic;
namespace
Helloworld
{
/// <summary>Holder for reflection information generated from helloworld.proto</summary>
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
()]
public
static
partial
class
HelloworldReflection
{
#
region
Descriptor
...
...
@@ -41,31 +40,36 @@ namespace Helloworld {
}
#
region
Messages
/// <summary>
///
The request message containing the user's name.
/// The request message containing the user's name.
/// </summary>
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
()]
public
sealed
partial
class
HelloRequest
:
pb
::
IMessage
<
HelloRequest
>
{
private
static
readonly
pb
::
MessageParser
<
HelloRequest
>
_parser
=
new
pb
::
MessageParser
<
HelloRequest
>(()
=>
new
HelloRequest
());
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
]
public
static
pb
::
MessageParser
<
HelloRequest
>
Parser
{
get
{
return
_parser
;
}
}
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
]
public
static
pbr
::
MessageDescriptor
Descriptor
{
get
{
return
global
::
Helloworld
.
HelloworldReflection
.
Descriptor
.
MessageTypes
[
0
];
}
}
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
]
pbr
::
MessageDescriptor
pb
::
IMessage
.
Descriptor
{
get
{
return
Descriptor
;
}
}
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
]
public
HelloRequest
()
{
OnConstruction
();
}
partial
void
OnConstruction
();
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
]
public
HelloRequest
(
HelloRequest
other
)
:
this
()
{
name_
=
other
.
name_
;
}
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
]
public
HelloRequest
Clone
()
{
return
new
HelloRequest
(
this
);
}
...
...
@@ -73,6 +77,7 @@ namespace Helloworld {
/// <summary>Field number for the "name" field.</summary>
public
const
int
NameFieldNumber
=
1
;
private
string
name_
=
""
;
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
]
public
string
Name
{
get
{
return
name_
;
}
set
{
...
...
@@ -80,10 +85,12 @@ namespace Helloworld {
}
}
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
]
public
override
bool
Equals
(
object
other
)
{
return
Equals
(
other
as
HelloRequest
);
}
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
]
public
bool
Equals
(
HelloRequest
other
)
{
if
(
ReferenceEquals
(
other
,
null
))
{
return
false
;
...
...
@@ -95,16 +102,19 @@ namespace Helloworld {
return
true
;
}
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
]
public
override
int
GetHashCode
()
{
int
hash
=
1
;
if
(
Name
.
Length
!=
0
)
hash
^=
Name
.
GetHashCode
();
return
hash
;
}
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
]
public
override
string
ToString
()
{
return
pb
::
JsonFormatter
.
ToDiagnosticString
(
this
);
}
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
]
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
Name
.
Length
!=
0
)
{
output
.
WriteRawTag
(
10
);
...
...
@@ -112,6 +122,7 @@ namespace Helloworld {
}
}
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
]
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
Name
.
Length
!=
0
)
{
...
...
@@ -120,6 +131,7 @@ namespace Helloworld {
return
size
;
}
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
]
public
void
MergeFrom
(
HelloRequest
other
)
{
if
(
other
==
null
)
{
return
;
...
...
@@ -129,6 +141,7 @@ namespace Helloworld {
}
}
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
]
public
void
MergeFrom
(
pb
::
CodedInputStream
input
)
{
uint
tag
;
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
...
...
@@ -147,31 +160,36 @@ namespace Helloworld {
}
/// <summary>
///
The response message containing the greetings
/// The response message containing the greetings
/// </summary>
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
()]
public
sealed
partial
class
HelloReply
:
pb
::
IMessage
<
HelloReply
>
{
private
static
readonly
pb
::
MessageParser
<
HelloReply
>
_parser
=
new
pb
::
MessageParser
<
HelloReply
>(()
=>
new
HelloReply
());
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
]
public
static
pb
::
MessageParser
<
HelloReply
>
Parser
{
get
{
return
_parser
;
}
}
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
]
public
static
pbr
::
MessageDescriptor
Descriptor
{
get
{
return
global
::
Helloworld
.
HelloworldReflection
.
Descriptor
.
MessageTypes
[
1
];
}
}
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
]
pbr
::
MessageDescriptor
pb
::
IMessage
.
Descriptor
{
get
{
return
Descriptor
;
}
}
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
]
public
HelloReply
()
{
OnConstruction
();
}
partial
void
OnConstruction
();
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
]
public
HelloReply
(
HelloReply
other
)
:
this
()
{
message_
=
other
.
message_
;
}
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
]
public
HelloReply
Clone
()
{
return
new
HelloReply
(
this
);
}
...
...
@@ -179,6 +197,7 @@ namespace Helloworld {
/// <summary>Field number for the "message" field.</summary>
public
const
int
MessageFieldNumber
=
1
;
private
string
message_
=
""
;
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
]
public
string
Message
{
get
{
return
message_
;
}
set
{
...
...
@@ -186,10 +205,12 @@ namespace Helloworld {
}
}
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
]
public
override
bool
Equals
(
object
other
)
{
return
Equals
(
other
as
HelloReply
);
}
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
]
public
bool
Equals
(
HelloReply
other
)
{
if
(
ReferenceEquals
(
other
,
null
))
{
return
false
;
...
...
@@ -201,16 +222,19 @@ namespace Helloworld {
return
true
;
}
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
]
public
override
int
GetHashCode
()
{
int
hash
=
1
;
if
(
Message
.
Length
!=
0
)
hash
^=
Message
.
GetHashCode
();
return
hash
;
}
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
]
public
override
string
ToString
()
{
return
pb
::
JsonFormatter
.
ToDiagnosticString
(
this
);
}
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
]
public
void
WriteTo
(
pb
::
CodedOutputStream
output
)
{
if
(
Message
.
Length
!=
0
)
{
output
.
WriteRawTag
(
10
);
...
...
@@ -218,6 +242,7 @@ namespace Helloworld {
}
}
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
]
public
int
CalculateSize
()
{
int
size
=
0
;
if
(
Message
.
Length
!=
0
)
{
...
...
@@ -226,6 +251,7 @@ namespace Helloworld {
return
size
;
}
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
]
public
void
MergeFrom
(
HelloReply
other
)
{
if
(
other
==
null
)
{
return
;
...
...
@@ -235,6 +261,7 @@ namespace Helloworld {
}
}
[
global
::
System
.
Diagnostics
.
DebuggerNonUserCodeAttribute
]
public
void
MergeFrom
(
pb
::
CodedInputStream
input
)
{
uint
tag
;
while
((
tag
=
input
.
ReadTag
())
!=
0
)
{
...
...
This diff is collapsed.
Click to expand it.
examples/csharp/helloworld-from-cli/Greeter/HelloworldGrpc.cs
+
47
−
26
View file @
1ba7e5d8
...
...
@@ -35,21 +35,21 @@
using
System
;
using
System.Threading
;
using
System.Threading.Tasks
;
using
Grpc.Core
;
using
grpc
=
global
::
Grpc
.
Core
;
namespace
Helloworld
{
/// <summary>
///
The greeting service definition.
/// The greeting service definition.
/// </summary>
public
static
class
Greeter
public
static
partial
class
Greeter
{
static
readonly
string
__ServiceName
=
"helloworld.Greeter"
;
static
readonly
Marshaller
<
global
::
Helloworld
.
HelloRequest
>
__Marshaller_HelloRequest
=
Marshallers
.
Create
((
arg
)
=>
global
::
Google
.
Protobuf
.
MessageExtensions
.
ToByteArray
(
arg
),
global
::
Helloworld
.
HelloRequest
.
Parser
.
ParseFrom
);
static
readonly
Marshaller
<
global
::
Helloworld
.
HelloReply
>
__Marshaller_HelloReply
=
Marshallers
.
Create
((
arg
)
=>
global
::
Google
.
Protobuf
.
MessageExtensions
.
ToByteArray
(
arg
),
global
::
Helloworld
.
HelloReply
.
Parser
.
ParseFrom
);
static
readonly
grpc
::
Marshaller
<
global
::
Helloworld
.
HelloRequest
>
__Marshaller_HelloRequest
=
grpc
::
Marshallers
.
Create
((
arg
)
=>
global
::
Google
.
Protobuf
.
MessageExtensions
.
ToByteArray
(
arg
),
global
::
Helloworld
.
HelloRequest
.
Parser
.
ParseFrom
);
static
readonly
grpc
::
Marshaller
<
global
::
Helloworld
.
HelloReply
>
__Marshaller_HelloReply
=
grpc
::
Marshallers
.
Create
((
arg
)
=>
global
::
Google
.
Protobuf
.
MessageExtensions
.
ToByteArray
(
arg
),
global
::
Helloworld
.
HelloReply
.
Parser
.
ParseFrom
);
static
readonly
Method
<
global
::
Helloworld
.
HelloRequest
,
global
::
Helloworld
.
HelloReply
>
__Method_SayHello
=
new
Method
<
global
::
Helloworld
.
HelloRequest
,
global
::
Helloworld
.
HelloReply
>(
MethodType
.
Unary
,
static
readonly
grpc
::
Method
<
global
::
Helloworld
.
HelloRequest
,
global
::
Helloworld
.
HelloReply
>
__Method_SayHello
=
new
grpc
::
Method
<
global
::
Helloworld
.
HelloRequest
,
global
::
Helloworld
.
HelloReply
>(
grpc
::
MethodType
.
Unary
,
__ServiceName
,
"SayHello"
,
__Marshaller_HelloRequest
,
...
...
@@ -62,29 +62,32 @@ namespace Helloworld {
}
/// <summary>Base class for server-side implementations of Greeter</summary>
public
abstract
class
GreeterBase
public
abstract
partial
class
GreeterBase
{
/// <summary>
///
Sends a greeting
/// Sends a greeting
/// </summary>
public
virtual
global
::
System
.
Threading
.
Tasks
.
Task
<
global
::
Helloworld
.
HelloReply
>
SayHello
(
global
::
Helloworld
.
HelloRequest
request
,
ServerCallContext
context
)
/// <param name="request">The request received from the client.</param>
/// <param name="context">The context of the server-side call handler being invoked.</param>
/// <returns>The response to send back to the client (wrapped by a task).</returns>
public
virtual
global
::
System
.
Threading
.
Tasks
.
Task
<
global
::
Helloworld
.
HelloReply
>
SayHello
(
global
::
Helloworld
.
HelloRequest
request
,
grpc
::
ServerCallContext
context
)
{
throw
new
RpcException
(
new
Status
(
StatusCode
.
Unimplemented
,
""
));
throw
new
grpc
::
RpcException
(
new
grpc
::
Status
(
grpc
::
StatusCode
.
Unimplemented
,
""
));
}
}
/// <summary>Client for Greeter</summary>
public
class
GreeterClient
:
ClientBase
<
GreeterClient
>
public
partial
class
GreeterClient
:
grpc
::
ClientBase
<
GreeterClient
>
{
/// <summary>Creates a new client for Greeter</summary>
/// <param name="channel">The channel to use to make remote calls.</param>
public
GreeterClient
(
Channel
channel
)
:
base
(
channel
)
public
GreeterClient
(
grpc
::
Channel
channel
)
:
base
(
channel
)
{
}
/// <summary>Creates a new client for Greeter that uses a custom <c>CallInvoker</c>.</summary>
/// <param name="callInvoker">The callInvoker to use to make remote calls.</param>
public
GreeterClient
(
CallInvoker
callInvoker
)
:
base
(
callInvoker
)
public
GreeterClient
(
grpc
::
CallInvoker
callInvoker
)
:
base
(
callInvoker
)
{
}
/// <summary>Protected parameterless constructor to allow creation of test doubles.</summary>
...
...
@@ -98,33 +101,50 @@ namespace Helloworld {
}
/// <summary>
///
Sends a greeting
/// Sends a greeting
/// </summary>
public
virtual
global
::
Helloworld
.
HelloReply
SayHello
(
global
::
Helloworld
.
HelloRequest
request
,
Metadata
headers
=
null
,
DateTime
?
deadline
=
null
,
CancellationToken
cancellationToken
=
default
(
CancellationToken
))
/// <param name="request">The request to send to the server.</param>
/// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
/// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
/// <param name="cancellationToken">An optional token for canceling the call.</param>
/// <returns>The response received from the server.</returns>
public
virtual
global
::
Helloworld
.
HelloReply
SayHello
(
global
::
Helloworld
.
HelloRequest
request
,
grpc
::
Metadata
headers
=
null
,
DateTime
?
deadline
=
null
,
CancellationToken
cancellationToken
=
default
(
CancellationToken
))
{
return
SayHello
(
request
,
new
CallOptions
(
headers
,
deadline
,
cancellationToken
));
return
SayHello
(
request
,
new
grpc
::
CallOptions
(
headers
,
deadline
,
cancellationToken
));
}
/// <summary>
///
Sends a greeting
/// Sends a greeting
/// </summary>
public
virtual
global
::
Helloworld
.
HelloReply
SayHello
(
global
::
Helloworld
.
HelloRequest
request
,
CallOptions
options
)
/// <param name="request">The request to send to the server.</param>
/// <param name="options">The options for the call.</param>
/// <returns>The response received from the server.</returns>
public
virtual
global
::
Helloworld
.
HelloReply
SayHello
(
global
::
Helloworld
.
HelloRequest
request
,
grpc
::
CallOptions
options
)
{
return
CallInvoker
.
BlockingUnaryCall
(
__Method_SayHello
,
null
,
options
,
request
);
}
/// <summary>
///
Sends a greeting
/// Sends a greeting
/// </summary>
public
virtual
AsyncUnaryCall
<
global
::
Helloworld
.
HelloReply
>
SayHelloAsync
(
global
::
Helloworld
.
HelloRequest
request
,
Metadata
headers
=
null
,
DateTime
?
deadline
=
null
,
CancellationToken
cancellationToken
=
default
(
CancellationToken
))
/// <param name="request">The request to send to the server.</param>
/// <param name="headers">The initial metadata to send with the call. This parameter is optional.</param>
/// <param name="deadline">An optional deadline for the call. The call will be cancelled if deadline is hit.</param>
/// <param name="cancellationToken">An optional token for canceling the call.</param>
/// <returns>The call object.</returns>
public
virtual
grpc
::
AsyncUnaryCall
<
global
::
Helloworld
.
HelloReply
>
SayHelloAsync
(
global
::
Helloworld
.
HelloRequest
request
,
grpc
::
Metadata
headers
=
null
,
DateTime
?
deadline
=
null
,
CancellationToken
cancellationToken
=
default
(
CancellationToken
))
{
return
SayHelloAsync
(
request
,
new
CallOptions
(
headers
,
deadline
,
cancellationToken
));
return
SayHelloAsync
(
request
,
new
grpc
::
CallOptions
(
headers
,
deadline
,
cancellationToken
));
}
/// <summary>
///
Sends a greeting
/// Sends a greeting
/// </summary>
public
virtual
AsyncUnaryCall
<
global
::
Helloworld
.
HelloReply
>
SayHelloAsync
(
global
::
Helloworld
.
HelloRequest
request
,
CallOptions
options
)
/// <param name="request">The request to send to the server.</param>
/// <param name="options">The options for the call.</param>
/// <returns>The call object.</returns>
public
virtual
grpc
::
AsyncUnaryCall
<
global
::
Helloworld
.
HelloReply
>
SayHelloAsync
(
global
::
Helloworld
.
HelloRequest
request
,
grpc
::
CallOptions
options
)
{
return
CallInvoker
.
AsyncUnaryCall
(
__Method_SayHello
,
null
,
options
,
request
);
}
/// <summary>Creates a new instance of client from given <c>ClientBaseConfiguration</c>.</summary>
protected
override
GreeterClient
NewInstance
(
ClientBaseConfiguration
configuration
)
{
return
new
GreeterClient
(
configuration
);
...
...
@@ -132,9 +152,10 @@ namespace Helloworld {
}
/// <summary>Creates service definition that can be registered with a server</summary>
public
static
ServerServiceDefinition
BindService
(
GreeterBase
serviceImpl
)
/// <param name="serviceImpl">An object implementing the server-side handling logic.</param>
public
static
grpc
::
ServerServiceDefinition
BindService
(
GreeterBase
serviceImpl
)
{
return
ServerServiceDefinition
.
CreateBuilder
()
return
grpc
::
ServerServiceDefinition
.
CreateBuilder
()
.
AddMethod
(
__Method_SayHello
,
serviceImpl
.
SayHello
).
Build
();
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment