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
a75c63b1
Commit
a75c63b1
authored
8 years ago
by
Jan Tattermusch
Browse files
Options
Downloads
Plain Diff
Merge pull request #5073 from mleenhardt/calloptions-fluent
CallOptions fluent methods
parents
ab8b9f51
efa6af73
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.Tests/CallOptionsTest.cs
+13
-3
13 additions, 3 deletions
src/csharp/Grpc.Core.Tests/CallOptionsTest.cs
src/csharp/Grpc.Core/CallOptions.cs
+39
-12
39 additions, 12 deletions
src/csharp/Grpc.Core/CallOptions.cs
with
52 additions
and
15 deletions
src/csharp/Grpc.Core.Tests/CallOptionsTest.cs
+
13
−
3
View file @
a75c63b1
...
@@ -54,10 +54,20 @@ namespace Grpc.Core.Tests
...
@@ -54,10 +54,20 @@ namespace Grpc.Core.Tests
var
deadline
=
DateTime
.
UtcNow
;
var
deadline
=
DateTime
.
UtcNow
;
Assert
.
AreEqual
(
deadline
,
options
.
WithDeadline
(
deadline
).
Deadline
.
Value
);
Assert
.
AreEqual
(
deadline
,
options
.
WithDeadline
(
deadline
).
Deadline
.
Value
);
var
token
=
new
CancellationTokenSource
().
Token
;
var
cancellationToken
=
new
CancellationTokenSource
().
Token
;
Assert
.
AreEqual
(
token
,
options
.
WithCancellationToken
(
token
).
CancellationToken
);
Assert
.
AreEqual
(
cancellationToken
,
options
.
WithCancellationToken
(
cancellationToken
).
CancellationToken
);
var
writeOptions
=
new
WriteOptions
();
Assert
.
AreSame
(
writeOptions
,
options
.
WithWriteOptions
(
writeOptions
).
WriteOptions
);
var
propagationToken
=
new
ContextPropagationToken
(
CallSafeHandle
.
NullInstance
,
DateTime
.
UtcNow
,
CancellationToken
.
None
,
ContextPropagationOptions
.
Default
);
Assert
.
AreSame
(
propagationToken
,
options
.
WithPropagationToken
(
propagationToken
).
PropagationToken
);
var
credentials
=
new
FakeCallCredentials
();
Assert
.
AreSame
(
credentials
,
options
.
WithCredentials
(
credentials
).
Credentials
);
// Ch
ang
e original instance is unchanged.
// Ch
eck that th
e original instance is unchanged.
Assert
.
IsNull
(
options
.
Headers
);
Assert
.
IsNull
(
options
.
Headers
);
Assert
.
IsNull
(
options
.
Deadline
);
Assert
.
IsNull
(
options
.
Deadline
);
Assert
.
AreEqual
(
CancellationToken
.
None
,
options
.
CancellationToken
);
Assert
.
AreEqual
(
CancellationToken
.
None
,
options
.
CancellationToken
);
...
...
This diff is collapsed.
Click to expand it.
src/csharp/Grpc.Core/CallOptions.cs
+
39
−
12
View file @
a75c63b1
...
@@ -100,10 +100,7 @@ namespace Grpc.Core
...
@@ -100,10 +100,7 @@ namespace Grpc.Core
/// </summary>
/// </summary>
public
WriteOptions
WriteOptions
public
WriteOptions
WriteOptions
{
{
get
get
{
return
this
.
writeOptions
;
}
{
return
this
.
writeOptions
;
}
}
}
/// <summary>
/// <summary>
...
@@ -111,10 +108,7 @@ namespace Grpc.Core
...
@@ -111,10 +108,7 @@ namespace Grpc.Core
/// </summary>
/// </summary>
public
ContextPropagationToken
PropagationToken
public
ContextPropagationToken
PropagationToken
{
{
get
get
{
return
this
.
propagationToken
;
}
{
return
this
.
propagationToken
;
}
}
}
/// <summary>
/// <summary>
...
@@ -122,10 +116,7 @@ namespace Grpc.Core
...
@@ -122,10 +116,7 @@ namespace Grpc.Core
/// </summary>
/// </summary>
public
CallCredentials
Credentials
public
CallCredentials
Credentials
{
{
get
get
{
return
this
.
credentials
;
}
{
return
this
.
credentials
;
}
}
}
/// <summary>
/// <summary>
...
@@ -164,6 +155,42 @@ namespace Grpc.Core
...
@@ -164,6 +155,42 @@ namespace Grpc.Core
return
newOptions
;
return
newOptions
;
}
}
/// <summary>
/// Returns new instance of <see cref="CallOptions"/> with
/// <c>WriteOptions</c> set to the value provided. Values of all other fields are preserved.
/// </summary>
/// <param name="writeOptions">The write options.</param>
public
CallOptions
WithWriteOptions
(
WriteOptions
writeOptions
)
{
var
newOptions
=
this
;
newOptions
.
writeOptions
=
writeOptions
;
return
newOptions
;
}
/// <summary>
/// Returns new instance of <see cref="CallOptions"/> with
/// <c>PropagationToken</c> set to the value provided. Values of all other fields are preserved.
/// </summary>
/// <param name="propagationToken">The context propagation token.</param>
public
CallOptions
WithPropagationToken
(
ContextPropagationToken
propagationToken
)
{
var
newOptions
=
this
;
newOptions
.
propagationToken
=
propagationToken
;
return
newOptions
;
}
/// <summary>
/// Returns new instance of <see cref="CallOptions"/> with
/// <c>Credentials</c> set to the value provided. Values of all other fields are preserved.
/// </summary>
/// <param name="credentials">The call credentials.</param>
public
CallOptions
WithCredentials
(
CallCredentials
credentials
)
{
var
newOptions
=
this
;
newOptions
.
credentials
=
credentials
;
return
newOptions
;
}
/// <summary>
/// <summary>
/// Returns a new instance of <see cref="CallOptions"/> with
/// Returns a new instance of <see cref="CallOptions"/> with
/// all previously unset values set to their defaults and deadline and cancellation
/// all previously unset values set to their defaults and deadline and cancellation
...
...
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