File tree 1 file changed +23
-0
lines changed
1 file changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ server.Services.Add(Example2.BindService(proxyService2));
25
25
26
26
### Advanced usage
27
27
Extends auto-generated proxy client and intercept request/response
28
+
28
29
``` csharp
29
30
public sealed class ExampleImpl : Example .ExampleProxy
30
31
{
@@ -44,3 +45,25 @@ public sealed class ExampleImpl : Example.ExampleProxy
44
45
}
45
46
}
46
47
```
48
+
49
+ ### Dynamic Routing
50
+ Dynamic routing operates based on the method defined in ServiceDescriptor.
51
+
52
+ ``` csharp
53
+ var targetChannelA = new Channel (" 1.2.3.4" , 12345 , ChannelCredentials .Insecure );
54
+ var targetInvokerA = targetChannelA .CreateCallInvoker ();
55
+
56
+ var targetChannelB = new Channel (" 4.3.2.1" , 54321 , ChannelCredentials .Insecure );
57
+ var targetInvokerB = targetChannelB .CreateCallInvoker ();
58
+
59
+ var proxyRouter = new ProxyCallRouter ();
60
+
61
+ proxyRouter .Add (Example1 .Descriptor , targetInvokerA ); // Example1 -> 1.2.3.4:12345
62
+ proxyRouter .Add (Example2 .Descriptor , targetInvokerB ); // Example2 -> 4.3.2.1:54321
63
+
64
+ /* Setup Proxy Server */
65
+
66
+ var proxyServer = new Server ();
67
+ server .Services .Add (Example1 .BindService (new Example1 .Example1Proxy (proxyRouter )));
68
+ server .Services .Add (Example2 .BindService (new Example2 .Example2Proxy (proxyRouter )));
69
+ ```
You can’t perform that action at this time.
0 commit comments