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
56b805ff
Commit
56b805ff
authored
10 years ago
by
Jan Tattermusch
Browse files
Options
Downloads
Patches
Plain Diff
added support for streaming calls to TestService stubs
parent
eb3e76e7
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/csharp/GrpcApi/TestServiceGrpc.cs
+71
-4
71 additions, 4 deletions
src/csharp/GrpcApi/TestServiceGrpc.cs
with
71 additions
and
4 deletions
src/csharp/GrpcApi/TestServiceGrpc.cs
+
71
−
4
View file @
56b805ff
...
@@ -15,6 +15,10 @@ namespace grpc.testing
...
@@ -15,6 +15,10 @@ namespace grpc.testing
readonly
static
Marshaller
<
Empty
>
emptyMarshaller
=
Marshallers
.
Create
((
arg
)
=>
arg
.
ToByteArray
(),
Empty
.
ParseFrom
);
readonly
static
Marshaller
<
Empty
>
emptyMarshaller
=
Marshallers
.
Create
((
arg
)
=>
arg
.
ToByteArray
(),
Empty
.
ParseFrom
);
readonly
static
Marshaller
<
SimpleRequest
>
simpleRequestMarshaller
=
Marshallers
.
Create
((
arg
)
=>
arg
.
ToByteArray
(),
SimpleRequest
.
ParseFrom
);
readonly
static
Marshaller
<
SimpleRequest
>
simpleRequestMarshaller
=
Marshallers
.
Create
((
arg
)
=>
arg
.
ToByteArray
(),
SimpleRequest
.
ParseFrom
);
readonly
static
Marshaller
<
SimpleResponse
>
simpleResponseMarshaller
=
Marshallers
.
Create
((
arg
)
=>
arg
.
ToByteArray
(),
SimpleResponse
.
ParseFrom
);
readonly
static
Marshaller
<
SimpleResponse
>
simpleResponseMarshaller
=
Marshallers
.
Create
((
arg
)
=>
arg
.
ToByteArray
(),
SimpleResponse
.
ParseFrom
);
readonly
static
Marshaller
<
StreamingOutputCallRequest
>
streamingOutputCallRequestMarshaller
=
Marshallers
.
Create
((
arg
)
=>
arg
.
ToByteArray
(),
StreamingOutputCallRequest
.
ParseFrom
);
readonly
static
Marshaller
<
StreamingOutputCallResponse
>
streamingOutputCallResponseMarshaller
=
Marshallers
.
Create
((
arg
)
=>
arg
.
ToByteArray
(),
StreamingOutputCallResponse
.
ParseFrom
);
readonly
static
Marshaller
<
StreamingInputCallRequest
>
streamingInputCallRequestMarshaller
=
Marshallers
.
Create
((
arg
)
=>
arg
.
ToByteArray
(),
StreamingInputCallRequest
.
ParseFrom
);
readonly
static
Marshaller
<
StreamingInputCallResponse
>
streamingInputCallResponseMarshaller
=
Marshallers
.
Create
((
arg
)
=>
arg
.
ToByteArray
(),
StreamingInputCallResponse
.
ParseFrom
);
readonly
static
Method
<
Empty
,
Empty
>
emptyCallMethod
=
new
Method
<
Empty
,
Empty
>(
readonly
static
Method
<
Empty
,
Empty
>
emptyCallMethod
=
new
Method
<
Empty
,
Empty
>(
MethodType
.
Unary
,
MethodType
.
Unary
,
...
@@ -28,6 +32,30 @@ namespace grpc.testing
...
@@ -28,6 +32,30 @@ namespace grpc.testing
simpleRequestMarshaller
,
simpleRequestMarshaller
,
simpleResponseMarshaller
simpleResponseMarshaller
);
);
readonly
static
Method
<
StreamingOutputCallRequest
,
StreamingOutputCallResponse
>
streamingOutputCallMethod
=
new
Method
<
StreamingOutputCallRequest
,
StreamingOutputCallResponse
>(
MethodType
.
ServerStreaming
,
"/grpc.testing.TestService/StreamingOutputCall"
,
streamingOutputCallRequestMarshaller
,
streamingOutputCallResponseMarshaller
);
readonly
static
Method
<
StreamingInputCallRequest
,
StreamingInputCallResponse
>
streamingInputCallMethod
=
new
Method
<
StreamingInputCallRequest
,
StreamingInputCallResponse
>(
MethodType
.
ClientStreaming
,
"/grpc.testing.TestService/StreamingInputCall"
,
streamingInputCallRequestMarshaller
,
streamingInputCallResponseMarshaller
);
readonly
static
Method
<
StreamingOutputCallRequest
,
StreamingOutputCallResponse
>
fullDuplexCallMethod
=
new
Method
<
StreamingOutputCallRequest
,
StreamingOutputCallResponse
>(
MethodType
.
DuplexStreaming
,
"/grpc.testing.TestService/FullDuplexCall"
,
streamingOutputCallRequestMarshaller
,
streamingOutputCallResponseMarshaller
);
readonly
static
Method
<
StreamingOutputCallRequest
,
StreamingOutputCallResponse
>
halfDuplexCallMethod
=
new
Method
<
StreamingOutputCallRequest
,
StreamingOutputCallResponse
>(
MethodType
.
DuplexStreaming
,
"/grpc.testing.TestService/HalfDuplexCall"
,
streamingOutputCallRequestMarshaller
,
streamingOutputCallResponseMarshaller
);
public
interface
ITestServiceClient
public
interface
ITestServiceClient
{
{
...
@@ -39,10 +67,13 @@ namespace grpc.testing
...
@@ -39,10 +67,13 @@ namespace grpc.testing
Task
<
SimpleResponse
>
UnaryCallAsync
(
SimpleRequest
request
,
CancellationToken
token
=
default
(
CancellationToken
));
Task
<
SimpleResponse
>
UnaryCallAsync
(
SimpleRequest
request
,
CancellationToken
token
=
default
(
CancellationToken
));
// TODO: StreamingOutputCall
Task
StreamingOutputCall
(
StreamingOutputCallRequest
request
,
IObserver
<
StreamingOutputCallResponse
>
responseObserver
,
CancellationToken
token
=
default
(
CancellationToken
));
// TODO: StreamingInputCall
// TODO: FullDuplexCall
ClientStreamingAsyncResult
<
StreamingInputCallRequest
,
StreamingInputCallResponse
>
StreamingInputCall
(
CancellationToken
token
=
default
(
CancellationToken
));
// TODO: HalfDuplexCall
IObserver
<
StreamingOutputCallRequest
>
FullDuplexCall
(
IObserver
<
StreamingOutputCallResponse
>
responseObserver
,
CancellationToken
token
=
default
(
CancellationToken
));
IObserver
<
StreamingOutputCallRequest
>
HalfDuplexCall
(
IObserver
<
StreamingOutputCallResponse
>
responseObserver
,
CancellationToken
token
=
default
(
CancellationToken
));
}
}
public
class
TestServiceClientStub
:
ITestServiceClient
public
class
TestServiceClientStub
:
ITestServiceClient
...
@@ -77,6 +108,30 @@ namespace grpc.testing
...
@@ -77,6 +108,30 @@ namespace grpc.testing
var
call
=
new
Google
.
GRPC
.
Core
.
Call
<
SimpleRequest
,
SimpleResponse
>(
unaryCallMethod
,
channel
);
var
call
=
new
Google
.
GRPC
.
Core
.
Call
<
SimpleRequest
,
SimpleResponse
>(
unaryCallMethod
,
channel
);
return
Calls
.
AsyncUnaryCall
(
call
,
request
,
token
);
return
Calls
.
AsyncUnaryCall
(
call
,
request
,
token
);
}
}
public
Task
StreamingOutputCall
(
StreamingOutputCallRequest
request
,
IObserver
<
StreamingOutputCallResponse
>
responseObserver
,
CancellationToken
token
=
default
(
CancellationToken
))
{
var
call
=
new
Google
.
GRPC
.
Core
.
Call
<
StreamingOutputCallRequest
,
StreamingOutputCallResponse
>(
streamingOutputCallMethod
,
channel
);
return
Calls
.
AsyncServerStreamingCall
(
call
,
request
,
responseObserver
,
token
);
}
public
ClientStreamingAsyncResult
<
StreamingInputCallRequest
,
StreamingInputCallResponse
>
StreamingInputCall
(
CancellationToken
token
=
default
(
CancellationToken
))
{
var
call
=
new
Google
.
GRPC
.
Core
.
Call
<
StreamingInputCallRequest
,
StreamingInputCallResponse
>(
streamingInputCallMethod
,
channel
);
return
Calls
.
AsyncClientStreamingCall
(
call
,
token
);
}
public
IObserver
<
StreamingOutputCallRequest
>
FullDuplexCall
(
IObserver
<
StreamingOutputCallResponse
>
responseObserver
,
CancellationToken
token
=
default
(
CancellationToken
))
{
var
call
=
new
Google
.
GRPC
.
Core
.
Call
<
StreamingOutputCallRequest
,
StreamingOutputCallResponse
>(
fullDuplexCallMethod
,
channel
);
return
Calls
.
DuplexStreamingCall
(
call
,
responseObserver
,
token
);
}
public
IObserver
<
StreamingOutputCallRequest
>
HalfDuplexCall
(
IObserver
<
StreamingOutputCallResponse
>
responseObserver
,
CancellationToken
token
=
default
(
CancellationToken
))
{
var
call
=
new
Google
.
GRPC
.
Core
.
Call
<
StreamingOutputCallRequest
,
StreamingOutputCallResponse
>(
halfDuplexCallMethod
,
channel
);
return
Calls
.
DuplexStreamingCall
(
call
,
responseObserver
,
token
);
}
}
}
// server-side interface
// server-side interface
...
@@ -85,6 +140,14 @@ namespace grpc.testing
...
@@ -85,6 +140,14 @@ namespace grpc.testing
void
EmptyCall
(
Empty
request
,
IObserver
<
Empty
>
responseObserver
);
void
EmptyCall
(
Empty
request
,
IObserver
<
Empty
>
responseObserver
);
void
UnaryCall
(
SimpleRequest
request
,
IObserver
<
SimpleResponse
>
responseObserver
);
void
UnaryCall
(
SimpleRequest
request
,
IObserver
<
SimpleResponse
>
responseObserver
);
void
StreamingOutputCall
(
StreamingOutputCallRequest
request
,
IObserver
<
StreamingOutputCallResponse
>
responseObserver
);
IObserver
<
StreamingInputCallRequest
>
StreamingInputCall
(
IObserver
<
StreamingInputCallResponse
>
responseObserver
);
IObserver
<
StreamingOutputCallRequest
>
FullDuplexCall
(
IObserver
<
StreamingOutputCallResponse
>
responseObserver
);
IObserver
<
StreamingOutputCallRequest
>
HalfDuplexCall
(
IObserver
<
StreamingOutputCallResponse
>
responseObserver
);
}
}
public
static
ServerServiceDefinition
BindService
(
ITestService
serviceImpl
)
public
static
ServerServiceDefinition
BindService
(
ITestService
serviceImpl
)
...
@@ -92,6 +155,10 @@ namespace grpc.testing
...
@@ -92,6 +155,10 @@ namespace grpc.testing
return
ServerServiceDefinition
.
CreateBuilder
(
"/grpc.testing.TestService/"
)
return
ServerServiceDefinition
.
CreateBuilder
(
"/grpc.testing.TestService/"
)
.
AddMethod
(
emptyCallMethod
,
serviceImpl
.
EmptyCall
)
.
AddMethod
(
emptyCallMethod
,
serviceImpl
.
EmptyCall
)
.
AddMethod
(
unaryCallMethod
,
serviceImpl
.
UnaryCall
)
.
AddMethod
(
unaryCallMethod
,
serviceImpl
.
UnaryCall
)
.
AddMethod
(
streamingOutputCallMethod
,
serviceImpl
.
StreamingOutputCall
)
.
AddMethod
(
streamingInputCallMethod
,
serviceImpl
.
StreamingInputCall
)
.
AddMethod
(
fullDuplexCallMethod
,
serviceImpl
.
FullDuplexCall
)
.
AddMethod
(
halfDuplexCallMethod
,
serviceImpl
.
HalfDuplexCall
)
.
Build
();
.
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