Jan Tattermusch | a7fff86 | 2015-02-13 11:08:08 -0800 | [diff] [blame] | 1 | #region Copyright notice and license |
| 2 | |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 3 | // Copyright 2015 gRPC authors. |
Craig Tiller | 190d360 | 2015-02-18 09:23:38 -0800 | [diff] [blame] | 4 | // |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 5 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | // you may not use this file except in compliance with the License. |
| 7 | // You may obtain a copy of the License at |
Craig Tiller | 190d360 | 2015-02-18 09:23:38 -0800 | [diff] [blame] | 8 | // |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 9 | // http://www.apache.org/licenses/LICENSE-2.0 |
Craig Tiller | 190d360 | 2015-02-18 09:23:38 -0800 | [diff] [blame] | 10 | // |
Jan Tattermusch | 7897ae9 | 2017-06-07 22:57:36 +0200 | [diff] [blame] | 11 | // Unless required by applicable law or agreed to in writing, software |
| 12 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | // See the License for the specific language governing permissions and |
| 15 | // limitations under the License. |
Jan Tattermusch | a7fff86 | 2015-02-13 11:08:08 -0800 | [diff] [blame] | 16 | |
| 17 | #endregion |
| 18 | |
Jan Tattermusch | a7608b0 | 2015-02-03 17:54:38 -0800 | [diff] [blame] | 19 | using System; |
Jan Tattermusch | 3086862 | 2015-02-19 09:22:33 -0800 | [diff] [blame] | 20 | using Grpc.Core.Internal; |
Jan Tattermusch | c0b3721 | 2015-03-13 08:35:41 -0700 | [diff] [blame] | 21 | using Grpc.Core.Utils; |
Jan Tattermusch | a7608b0 | 2015-02-03 17:54:38 -0800 | [diff] [blame] | 22 | |
Jan Tattermusch | 3086862 | 2015-02-19 09:22:33 -0800 | [diff] [blame] | 23 | namespace Grpc.Core |
Jan Tattermusch | a7608b0 | 2015-02-03 17:54:38 -0800 | [diff] [blame] | 24 | { |
Jan Tattermusch | a5272b6 | 2015-04-30 11:56:46 -0700 | [diff] [blame] | 25 | /// <summary> |
Jan Tattermusch | 5cb5ced | 2015-08-05 04:05:57 -0700 | [diff] [blame] | 26 | /// Details about a client-side call to be invoked. |
Jan Tattermusch | a5272b6 | 2015-04-30 11:56:46 -0700 | [diff] [blame] | 27 | /// </summary> |
Jan Tattermusch | 12855fc | 2015-08-24 16:43:23 -0700 | [diff] [blame] | 28 | /// <typeparam name="TRequest">Request message type for the call.</typeparam> |
| 29 | /// <typeparam name="TResponse">Response message type for the call.</typeparam> |
Jan Tattermusch | 9698b5b | 2015-08-10 16:40:19 -0700 | [diff] [blame] | 30 | public struct CallInvocationDetails<TRequest, TResponse> |
Jan Tattermusch | a7608b0 | 2015-02-03 17:54:38 -0800 | [diff] [blame] | 31 | { |
Jan Tattermusch | a7608b0 | 2015-02-03 17:54:38 -0800 | [diff] [blame] | 32 | readonly Channel channel; |
Jan Tattermusch | 5cb5ced | 2015-08-05 04:05:57 -0700 | [diff] [blame] | 33 | readonly string method; |
Jan Tattermusch | cc97fed | 2015-08-05 00:44:29 -0700 | [diff] [blame] | 34 | readonly string host; |
Jan Tattermusch | 5cb5ced | 2015-08-05 04:05:57 -0700 | [diff] [blame] | 35 | readonly Marshaller<TRequest> requestMarshaller; |
| 36 | readonly Marshaller<TResponse> responseMarshaller; |
Jan Tattermusch | 9698b5b | 2015-08-10 16:40:19 -0700 | [diff] [blame] | 37 | CallOptions options; |
Jan Tattermusch | a7608b0 | 2015-02-03 17:54:38 -0800 | [diff] [blame] | 38 | |
Jan Tattermusch | 1b926ee | 2015-08-10 22:51:29 -0700 | [diff] [blame] | 39 | /// <summary> |
Jan Tattermusch | 12855fc | 2015-08-24 16:43:23 -0700 | [diff] [blame] | 40 | /// Initializes a new instance of the <see cref="Grpc.Core.CallInvocationDetails{TRequest,TResponse}"/> struct. |
Jan Tattermusch | 1b926ee | 2015-08-10 22:51:29 -0700 | [diff] [blame] | 41 | /// </summary> |
| 42 | /// <param name="channel">Channel to use for this call.</param> |
| 43 | /// <param name="method">Method to call.</param> |
| 44 | /// <param name="options">Call options.</param> |
Jan Tattermusch | 5c371f8 | 2015-08-05 14:55:17 -0700 | [diff] [blame] | 45 | public CallInvocationDetails(Channel channel, Method<TRequest, TResponse> method, CallOptions options) : |
Jan Tattermusch | 9698b5b | 2015-08-10 16:40:19 -0700 | [diff] [blame] | 46 | this(channel, method, null, options) |
| 47 | { |
| 48 | } |
| 49 | |
Jan Tattermusch | 1b926ee | 2015-08-10 22:51:29 -0700 | [diff] [blame] | 50 | /// <summary> |
Jan Tattermusch | 12855fc | 2015-08-24 16:43:23 -0700 | [diff] [blame] | 51 | /// Initializes a new instance of the <see cref="Grpc.Core.CallInvocationDetails{TRequest,TResponse}"/> struct. |
Jan Tattermusch | 1b926ee | 2015-08-10 22:51:29 -0700 | [diff] [blame] | 52 | /// </summary> |
| 53 | /// <param name="channel">Channel to use for this call.</param> |
| 54 | /// <param name="method">Method to call.</param> |
| 55 | /// <param name="host">Host that contains the method. if <c>null</c>, default host will be used.</param> |
| 56 | /// <param name="options">Call options.</param> |
Jan Tattermusch | 9698b5b | 2015-08-10 16:40:19 -0700 | [diff] [blame] | 57 | public CallInvocationDetails(Channel channel, Method<TRequest, TResponse> method, string host, CallOptions options) : |
| 58 | this(channel, method.FullName, host, method.RequestMarshaller, method.ResponseMarshaller, options) |
Jan Tattermusch | 075dde4 | 2015-03-11 18:21:00 -0700 | [diff] [blame] | 59 | { |
Jan Tattermusch | cc97fed | 2015-08-05 00:44:29 -0700 | [diff] [blame] | 60 | } |
| 61 | |
Jan Tattermusch | 1b926ee | 2015-08-10 22:51:29 -0700 | [diff] [blame] | 62 | /// <summary> |
Jan Tattermusch | 12855fc | 2015-08-24 16:43:23 -0700 | [diff] [blame] | 63 | /// Initializes a new instance of the <see cref="Grpc.Core.CallInvocationDetails{TRequest,TResponse}"/> struct. |
Jan Tattermusch | 1b926ee | 2015-08-10 22:51:29 -0700 | [diff] [blame] | 64 | /// </summary> |
| 65 | /// <param name="channel">Channel to use for this call.</param> |
| 66 | /// <param name="method">Qualified method name.</param> |
| 67 | /// <param name="host">Host that contains the method.</param> |
| 68 | /// <param name="requestMarshaller">Request marshaller.</param> |
| 69 | /// <param name="responseMarshaller">Response marshaller.</param> |
| 70 | /// <param name="options">Call options.</param> |
Jan Tattermusch | 5c371f8 | 2015-08-05 14:55:17 -0700 | [diff] [blame] | 71 | public CallInvocationDetails(Channel channel, string method, string host, Marshaller<TRequest> requestMarshaller, Marshaller<TResponse> responseMarshaller, CallOptions options) |
Jan Tattermusch | cc97fed | 2015-08-05 00:44:29 -0700 | [diff] [blame] | 72 | { |
Jan Tattermusch | 7a3ee6a | 2016-02-18 10:36:02 -0800 | [diff] [blame] | 73 | this.channel = GrpcPreconditions.CheckNotNull(channel, "channel"); |
| 74 | this.method = GrpcPreconditions.CheckNotNull(method, "method"); |
Jan Tattermusch | cc97fed | 2015-08-05 00:44:29 -0700 | [diff] [blame] | 75 | this.host = host; |
Jan Tattermusch | 7a3ee6a | 2016-02-18 10:36:02 -0800 | [diff] [blame] | 76 | this.requestMarshaller = GrpcPreconditions.CheckNotNull(requestMarshaller, "requestMarshaller"); |
| 77 | this.responseMarshaller = GrpcPreconditions.CheckNotNull(responseMarshaller, "responseMarshaller"); |
Jan Tattermusch | 9698b5b | 2015-08-10 16:40:19 -0700 | [diff] [blame] | 78 | this.options = options; |
Jan Tattermusch | 8ce5e8b | 2015-02-05 10:56:49 -0800 | [diff] [blame] | 79 | } |
Jan Tattermusch | a7608b0 | 2015-02-03 17:54:38 -0800 | [diff] [blame] | 80 | |
Jan Tattermusch | 1b926ee | 2015-08-10 22:51:29 -0700 | [diff] [blame] | 81 | /// <summary> |
| 82 | /// Get channel associated with this call. |
| 83 | /// </summary> |
Jan Tattermusch | a7608b0 | 2015-02-03 17:54:38 -0800 | [diff] [blame] | 84 | public Channel Channel |
| 85 | { |
| 86 | get |
| 87 | { |
| 88 | return this.channel; |
| 89 | } |
| 90 | } |
| 91 | |
Jan Tattermusch | 1b926ee | 2015-08-10 22:51:29 -0700 | [diff] [blame] | 92 | /// <summary> |
| 93 | /// Gets name of method to be called. |
| 94 | /// </summary> |
Jan Tattermusch | 5cb5ced | 2015-08-05 04:05:57 -0700 | [diff] [blame] | 95 | public string Method |
Jan Tattermusch | a7608b0 | 2015-02-03 17:54:38 -0800 | [diff] [blame] | 96 | { |
| 97 | get |
| 98 | { |
Jan Tattermusch | cc97fed | 2015-08-05 00:44:29 -0700 | [diff] [blame] | 99 | return this.method; |
| 100 | } |
| 101 | } |
| 102 | |
Jan Tattermusch | 1b926ee | 2015-08-10 22:51:29 -0700 | [diff] [blame] | 103 | /// <summary> |
| 104 | /// Get name of host. |
| 105 | /// </summary> |
Jan Tattermusch | cc97fed | 2015-08-05 00:44:29 -0700 | [diff] [blame] | 106 | public string Host |
| 107 | { |
| 108 | get |
| 109 | { |
| 110 | return this.host; |
Jan Tattermusch | a7608b0 | 2015-02-03 17:54:38 -0800 | [diff] [blame] | 111 | } |
| 112 | } |
| 113 | |
Jan Tattermusch | 1b926ee | 2015-08-10 22:51:29 -0700 | [diff] [blame] | 114 | /// <summary> |
| 115 | /// Gets marshaller used to serialize requests. |
| 116 | /// </summary> |
Jan Tattermusch | 5cb5ced | 2015-08-05 04:05:57 -0700 | [diff] [blame] | 117 | public Marshaller<TRequest> RequestMarshaller |
| 118 | { |
| 119 | get |
| 120 | { |
| 121 | return this.requestMarshaller; |
| 122 | } |
| 123 | } |
| 124 | |
Jan Tattermusch | 1b926ee | 2015-08-10 22:51:29 -0700 | [diff] [blame] | 125 | /// <summary> |
| 126 | /// Gets marshaller used to deserialized responses. |
| 127 | /// </summary> |
Jan Tattermusch | 5cb5ced | 2015-08-05 04:05:57 -0700 | [diff] [blame] | 128 | public Marshaller<TResponse> ResponseMarshaller |
| 129 | { |
| 130 | get |
| 131 | { |
| 132 | return this.responseMarshaller; |
| 133 | } |
| 134 | } |
Jan Tattermusch | 5c371f8 | 2015-08-05 14:55:17 -0700 | [diff] [blame] | 135 | |
Jan Tattermusch | 1b926ee | 2015-08-10 22:51:29 -0700 | [diff] [blame] | 136 | /// <summary> |
| 137 | /// Gets the call options. |
| 138 | /// </summary> |
Jan Tattermusch | 5c371f8 | 2015-08-05 14:55:17 -0700 | [diff] [blame] | 139 | public CallOptions Options |
Jan Tattermusch | a7608b0 | 2015-02-03 17:54:38 -0800 | [diff] [blame] | 140 | { |
| 141 | get |
| 142 | { |
Jan Tattermusch | 5c371f8 | 2015-08-05 14:55:17 -0700 | [diff] [blame] | 143 | return options; |
Jan Tattermusch | 0846b68 | 2015-07-23 17:02:12 -0700 | [diff] [blame] | 144 | } |
| 145 | } |
Jan Tattermusch | 9698b5b | 2015-08-10 16:40:19 -0700 | [diff] [blame] | 146 | |
| 147 | /// <summary> |
Jan Tattermusch | 12855fc | 2015-08-24 16:43:23 -0700 | [diff] [blame] | 148 | /// Returns new instance of <see cref="CallInvocationDetails{TRequest, TResponse}"/> with |
Jan Tattermusch | 9698b5b | 2015-08-10 16:40:19 -0700 | [diff] [blame] | 149 | /// <c>Options</c> set to the value provided. Values of all other fields are preserved. |
| 150 | /// </summary> |
| 151 | public CallInvocationDetails<TRequest, TResponse> WithOptions(CallOptions options) |
| 152 | { |
| 153 | var newDetails = this; |
| 154 | newDetails.options = options; |
| 155 | return newDetails; |
| 156 | } |
Jan Tattermusch | a7608b0 | 2015-02-03 17:54:38 -0800 | [diff] [blame] | 157 | } |
| 158 | } |