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
f72ead33
Commit
f72ead33
authored
8 years ago
by
Jan Tattermusch
Browse files
Options
Downloads
Patches
Plain Diff
refactor NoSuchMethodCallHandler
parent
21fbe201
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
src/csharp/Grpc.Core/Internal/ServerCallHandler.cs
+22
-11
22 additions, 11 deletions
src/csharp/Grpc.Core/Internal/ServerCallHandler.cs
src/csharp/Grpc.Core/Server.cs
+1
-1
1 addition, 1 deletion
src/csharp/Grpc.Core/Server.cs
with
23 additions
and
12 deletions
src/csharp/Grpc.Core/Internal/ServerCallHandler.cs
+
22
−
11
View file @
f72ead33
...
...
@@ -277,20 +277,31 @@ namespace Grpc.Core.Internal
}
}
internal
class
NoSuch
MethodCallHandler
:
IServerCallHandler
internal
class
Unimplemented
MethodCallHandler
:
IServerCallHandler
{
public
static
readonly
NoSuch
MethodCallHandler
Instance
=
new
NoSuch
MethodCallHandler
();
public
static
readonly
Unimplemented
MethodCallHandler
Instance
=
new
Unimplemented
MethodCallHandler
();
public
async
Task
HandleCall
(
ServerRpcNew
newRpc
,
CompletionQueueSafeHandle
cq
)
DuplexStreamingServerCallHandler
<
byte
[],
byte
[
]>
callHandlerImpl
;
public
UnimplementedMethodCallHandler
()
{
// We don't care about the payload type here.
var
asyncCall
=
new
AsyncCallServer
<
byte
[],
byte
[
]>
(
(
payload
)
=>
payload
,
(
payload
)
=>
payload
,
newRpc
.
Server
);
asyncCall
.
Initialize
(
newRpc
.
Call
,
cq
);
var
finishedTask
=
asyncCall
.
ServerSideCallAsync
();
await
asyncCall
.
SendStatusFromServerAsync
(
new
Status
(
StatusCode
.
Unimplemented
,
""
),
Metadata
.
Empty
,
null
).
ConfigureAwait
(
false
);
await
finishedTask
.
ConfigureAwait
(
false
);
var
marshaller
=
new
Marshaller
<
byte
[
]>
((
payload
)
=>
payload
,
(
payload
)
=>
payload
);
var
method
=
new
Method
<
byte
[],
byte
[
]>
(
MethodType
.
DuplexStreaming
,
""
,
""
,
marshaller
,
marshaller
);
this
.
callHandlerImpl
=
new
DuplexStreamingServerCallHandler
<
byte
[],
byte
[
]>
(
method
,
new
DuplexStreamingServerMethod
<
byte
[],
byte
[
]>
(
UnimplementedMethod
));
}
/// <summary>
/// Handler used for unimplemented method.
/// </summary>
private
Task
UnimplementedMethod
(
IAsyncStreamReader
<
byte
[
]>
requestStream
,
IServerStreamWriter
<
byte
[
]>
responseStream
,
ServerCallContext
ctx
)
{
ctx
.
Status
=
new
Status
(
StatusCode
.
Unimplemented
,
""
);
return
Task
.
FromResult
<
object
>(
null
);
}
public
Task
HandleCall
(
ServerRpcNew
newRpc
,
CompletionQueueSafeHandle
cq
)
{
return
callHandlerImpl
.
HandleCall
(
newRpc
,
cq
);
}
}
...
...
This diff is collapsed.
Click to expand it.
src/csharp/Grpc.Core/Server.cs
+
1
−
1
View file @
f72ead33
...
...
@@ -317,7 +317,7 @@ namespace Grpc.Core
IServerCallHandler
callHandler
;
if
(!
callHandlers
.
TryGetValue
(
newRpc
.
Method
,
out
callHandler
))
{
callHandler
=
NoSuch
MethodCallHandler
.
Instance
;
callHandler
=
Unimplemented
MethodCallHandler
.
Instance
;
}
await
callHandler
.
HandleCall
(
newRpc
,
cq
).
ConfigureAwait
(
false
);
}
...
...
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