-
Notifications
You must be signed in to change notification settings - Fork 2
WCF Setup
This section discusses how a coordinator and workers can be configured to properly communicate.
To get the two to talk, you'll need to add the appropriate lines to your Application Configuration file. (Nearly) all WCF configuration belongs in the <configuration><system.serviceModel> section of that file.
The explanations on this page will only address the most common scenarios, and they assume you don't want to heavily modify the WCF behavior of DistrEx. If you do, you should read about DistrEx communication and the official WCF documentation.
A worker exposes two services, one for a different set of responsibilities. Hence, your <configuration><system.serviceModel><service> section will contain two <service> nodes.
<configuration>
<system.serviceModel>
<services>
<service name="DistrEx.Communication.Service.Executor.ExecutorService">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000/executor" />
</baseAddresses>
</host>
<endpoint address="" binding="wsDualHttpBinding" bindingConfiguration="executorBinding" contract="DistrEx.Communication.Contracts.Service.IExecutor" />
</service>
<service name="DistrEx.Communication.Service.AssemblyManager.AssemblyManagerService">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8000/assemblymanager" />
</baseAddresses>
</host>
<endpoint address="" binding="basicHttpBinding" bindingConfiguration="assemblyTransferBinding" contract="DistrEx.Communication.Contracts.Service.IAssemblyManager" />
</service>
</services>
<!-- ... -->
</system.serviceModel>
<!-- ... -->
</configuration>You are free to chose the <service><host><baseAddresses><add baseAddress="..."> as you please, but make sure they don't collide with any other services you might have running on your computer.
In theory, the <service name="..."> property can be changed to anything you want as well, but bear in mind that all currently pre-existing DistrEx worker apps (such as DistrEx.Worker.Host.exe) can only function properly if there is exactly one <service> node for both contracts (DistrEx.Communication.Contracts.Service.IExecutor and DistrEx.Communication.Contracts.Service.IAssemblyManager) in the configuration file.
Eagle-eyed readers will have spotted that there is still something missing: Binding configurations for the services defined above. These will be added in <configuration><system.serviceModel><bindings>.
<configuration>
<system.serviceModel>
<!-- ... -->
<bindings>
<wsDualHttpBinding>
<!-- binding for transferring instructions and arguments (<=1MiB) (max pool size: 2MiB) -->
<binding name="executorBinding" maxReceivedMessageSize="1049000" maxBufferPoolSize="2097000">
<readerQuotas maxStringContentLength="1049000" />
</binding>
</wsDualHttpBinding>
<basicHttpBinding>
<!-- binding for transferring assemblies (can be large) as streams (<=10MiB) -->
<binding name="assemblyTransferBinding" transferMode="StreamedRequest" maxReceivedMessageSize="10490000" />
</basicHttpBinding>
</bindings>
</system.serviceModel>
</configuration>In order for your coordinator to contact any workers, you'll need to add <endpoint> nodes to <configuration><system.serviceModel><client>.
<configuration>
<!-- ... -->
<system.serviceModel>
<client>
<endpoint name="Worker1-Executor" address="http://localhost:8000/executor" binding="wsHttpBinding" contract="DistrEx.Communication.Contracts.Service.IExecutor" />
<endpoint name="Worker1-AssemblyManager" address="http://localhost:8000/assemblymanager" binding="basicHttpBinding" contract="DistrEx.Communication.Contracts.Service.IAssemblyManager" />
</client>
<!-- ... -->
</system.serviceModel>
</configuration>Each worker exposes two services, so you'll need two client endpoints per worker. Make sure they match the worker's configurations.
The <endpoint name="..."> properties can be set to anything you want; they are used in the code to identify any workers that you want to use.
Since DistrEx communication follows the callback pattern, your coordinator does not just need to be able to call workers, it needs expose a service of its own as well, by addind a <service> node in <configuration><system.serviceModel>.
<configuration>
<!-- ... -->
<system.serviceModel>
<!-- ... -->
<service name="DistrEx.Communication.Service.Executor.ExecutorCallbackService">
<host>
<baseAddresses>
<add baseAddress="http://localhost:8001/executorcallback"/>
</baseAddresses>
</host>
<endpoint address="" binding="wsHttpBinding" contract="DistrEx.Communication.Contracts.Service.IExecutorCallback"/>
</service>
</system.serviceModel>
</configuration>This will let your worker contact your coordinator at the endpoint http://localhost:8001/executorcallback.
You are free to chose a different endpoint to expose your coordinator's callback service at in the <baseAddresses><add baseAddress="..."> property.