Skip to content

Commit f5ed891

Browse files
authored
Update README.md
1 parent dca827a commit f5ed891

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

README.md

+23
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ server.Services.Add(Example2.BindService(proxyService2));
2525

2626
### Advanced usage
2727
Extends auto-generated proxy client and intercept request/response
28+
2829
```csharp
2930
public sealed class ExampleImpl : Example.ExampleProxy
3031
{
@@ -44,3 +45,25 @@ public sealed class ExampleImpl : Example.ExampleProxy
4445
}
4546
}
4647
```
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+
```

0 commit comments

Comments
 (0)