Make Ocelot work with service fabric DNS and naming service for guest exe and stateless (#242)

* test for issue

* added service fabric sample

* working!!

* changed sample naming to Ocelot

* removed files we dont need

* removed files we dont need

* updated sample gitignore

* updated sample gitignore

* getting ocelot to work with service fabric using the reverse proxy

* #238 - added support for service fabric discovery provider, proxies requests through naming service, wont work on partioned service fabric services yet

* #238 - Manually tested service fabric using sample..all seems OK. Made some changes after testing, added docs

* #238 - added docs for servic fabric
This commit is contained in:
Tom Pallister
2018-03-03 15:24:05 +00:00
committed by GitHub
parent 9cb25ab063
commit 454ba3f9a0
71 changed files with 2394 additions and 484 deletions

View File

@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<ApplicationManifest ApplicationTypeName="OcelotServiceApplicationType"
ApplicationTypeVersion="1.0.0"
xmlns="http://schemas.microsoft.com/2011/01/fabric"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Parameters>
<Parameter Name="OcelotApplicationService_InstanceCount" DefaultValue="1" />
<Parameter Name="OcelotApplicationApiGateway_InstanceCount" DefaultValue="1" />
</Parameters>
<!-- Import the ServiceManifest from the ServicePackage. The ServiceManifestName and ServiceManifestVersion
should match the Name and Version attributes of the ServiceManifest element defined in the
ServiceManifest.xml file. -->
<ServiceManifestImport>
<ServiceManifestRef ServiceManifestName="OcelotApplicationServicePkg" ServiceManifestVersion="1.0.0" />
<ConfigOverrides />
</ServiceManifestImport>
<ServiceManifestImport>
<ServiceManifestRef ServiceManifestName="OcelotApplicationApiGatewayPkg" ServiceManifestVersion="1.0.0" />
<ConfigOverrides />
</ServiceManifestImport>
<DefaultServices>
<!-- The section below creates instances of service types, when an instance of this
application type is created. You can also create one or more instances of service type using the
ServiceFabric PowerShell module.
The attribute ServiceTypeName below must match the name defined in the imported ServiceManifest.xml file. -->
<Service Name="OcelotApplicationService">
<StatelessService ServiceTypeName="OcelotApplicationServiceType" InstanceCount="[OcelotApplicationService_InstanceCount]">
<SingletonPartition />
</StatelessService>
</Service>
<Service Name="OcelotApplicationApiGateway">
<StatelessService ServiceTypeName="OcelotApplicationApiGatewayType" InstanceCount="[OcelotApplicationApiGateway_InstanceCount]">
<SingletonPartition />
</StatelessService>
</Service>
</DefaultServices>
</ApplicationManifest>

View File

@ -0,0 +1,2 @@
dotnet %~dp0\OcelotApplicationApiGateway.dll
exit /b %errorlevel%

View File

@ -0,0 +1,17 @@
#!/usr/bin/env bash
check_errs()
{
# Function. Parameter 1 is the return code
if [ "${1}" -ne "0" ]; then
# make our script exit with the right error code.
exit ${1}
fi
}
DIR=`dirname $0`
echo 0x3f > /proc/self/coredump_filter
source $DIR/dotnet-include.sh
dotnet $DIR/OcelotApplicationApiGateway.dll $@
check_errs $?

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<Settings xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2011/01/fabric">
<!-- Add your custom configuration sections and parameters here -->
<!--
<Section Name="MyConfigSection">
<Parameter Name="MyParameter" Value="Value1" />
</Section>
-->
</Settings>

View File

@ -0,0 +1,12 @@
contains a Settings.xml file, that can specify parameters for the service
Configuration packages describe user-defined, application-overridable configuration settings (sections of key-value pairs)
required for running service replicas/instances of service types specified in the ser-vice manifest. The configuration settings
must be stored in Settings.xml in the config package folder.
The service developer uses Service Fabric APIs to locate the package folders and read applica-tion-overridable configuration settings.
The service developer can also register callbacks that are in-voked when any of the configuration packages specified in the
service manifest are upgraded and re-reads new configuration settings inside that callback.
This means that Service Fabric will not recycle EXEs and DLLHOSTs specified in the host and support packages when
configuration packages are up-graded.

View File

@ -0,0 +1,5 @@
Data packages contain data files like custom dictionaries,
non-overridable configuration files, custom initialized data files, etc.
Service Fabric will recycle all EXEs and DLLHOSTs specified in the host and support packages when any of the data packages
specified inside service manifest are upgraded.

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<ServiceManifest Name="OcelotApplicationApiGatewayPkg"
Version="1.0.0"
xmlns="http://schemas.microsoft.com/2011/01/fabric"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ServiceTypes>
<!-- This is the name of your ServiceType.
This name must match the string used in RegisterServiceType call in Program.cs. -->
<StatelessServiceType ServiceTypeName="OcelotApplicationApiGatewayType" />
</ServiceTypes>
<!-- Code package is your service executable. -->
<CodePackage Name="Code" Version="1.0.0">
<EntryPoint>
<ExeHost>
<Program>entryPoint.sh</Program>
<ConsoleRedirection FileRetentionCount="5" FileMaxSizeInKb="2048"/>
</ExeHost>
</EntryPoint>
</CodePackage>
<!-- Config package is the contents of the Config directoy under PackageRoot that contains an
independently-updateable and versioned set of custom configuration settings for your service. -->
<ConfigPackage Name="Config" Version="1.0.0" />
<Resources>
<Endpoints>
<!-- This endpoint is used by the communication listener to obtain the port on which to
listen. Please note that if your service is partitioned, this port is shared with
replicas of different partitions that are placed in your code. -->
<Endpoint Name="WebEndpoint" Protocol="http" Port="31002" />
</Endpoints>
</Resources>
</ServiceManifest>

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<ServiceManifest Name="OcelotApplicationApiGatewayPkg"
Version="1.0.0"
xmlns="http://schemas.microsoft.com/2011/01/fabric"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ServiceTypes>
<!-- This is the name of your ServiceType.
This name must match the string used in RegisterServiceType call in Program.cs. -->
<StatelessServiceType ServiceTypeName="OcelotApplicationApiGatewayType" />
</ServiceTypes>
<!-- Code package is your service executable. -->
<CodePackage Name="Code" Version="1.0.0">
<EntryPoint>
<ExeHost>
<Program>entryPoint.cmd</Program>
<ConsoleRedirection FileRetentionCount="5" FileMaxSizeInKb="2048"/>
</ExeHost>
</EntryPoint>
</CodePackage>
<!-- Config package is the contents of the Config directoy under PackageRoot that contains an
independently-updateable and versioned set of custom configuration settings for your service. -->
<ConfigPackage Name="Config" Version="1.0.0" />
<Resources>
<Endpoints>
<!-- This endpoint is used by the communication listener to obtain the port on which to
listen. Please note that if your service is partitioned, this port is shared with
replicas of different partitions that are placed in your code. -->
<Endpoint Name="WebEndpoint" Protocol="http" Port="31002" />
</Endpoints>
</Resources>
</ServiceManifest>

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="utf-8"?>
<ServiceManifest Name="OcelotApplicationApiGatewayPkg"
Version="1.0.0"
xmlns="http://schemas.microsoft.com/2011/01/fabric"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ServiceTypes>
<!-- This is the name of your ServiceType.
This name must match the string used in RegisterServiceType call in Program.cs. -->
<StatelessServiceType ServiceTypeName="OcelotApplicationApiGatewayType" />
</ServiceTypes>
<!-- Code package is your service executable. -->
<CodePackage Name="Code" Version="1.0.0">
<EntryPoint>
<ExeHost>
<Program>entryPoint.cmd</Program>
<ConsoleRedirection FileRetentionCount="5" FileMaxSizeInKb="2048"/>
</ExeHost>
</EntryPoint>
</CodePackage>
<!-- Config package is the contents of the Config directoy under PackageRoot that contains an
independently-updateable and versioned set of custom configuration settings for your service. -->
<ConfigPackage Name="Config" Version="1.0.0" />
<Resources>
<Endpoints>
<!-- This endpoint is used by the communication listener to obtain the port on which to
listen. Please note that if your service is partitioned, this port is shared with
replicas of different partitions that are placed in your code. -->
<Endpoint Name="WebEndpoint" Protocol="http" Port="31002" />
</Endpoints>
</Resources>
</ServiceManifest>

View File

@ -0,0 +1,2 @@
dotnet %~dp0\OcelotApplicationService.dll
exit /b %errorlevel%

View File

@ -0,0 +1,15 @@
#!/usr/bin/env bash
check_errs()
{
# Function. Parameter 1 is the return code
if [ "${1}" -ne "0" ]; then
# make our script exit with the right error code.
exit ${1}
fi
}
DIR=`dirname $0`
source $DIR/dotnet-include.sh
dotnet $DIR/OcelotApplicationService.dll $@
check_errs $?

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8" ?>
<Settings xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2011/01/fabric">
<!-- Add your custom configuration sections and parameters here -->
<!--
<Section Name="MyConfigSection">
<Parameter Name="MyParameter" Value="Value1" />
</Section>
-->
</Settings>

View File

@ -0,0 +1,12 @@
contains a Settings.xml file, that can specify parameters for the service
Configuration packages describe user-defined, application-overridable configuration settings (sections of key-value pairs)
required for running service replicas/instances of service types specified in the ser-vice manifest. The configuration settings
must be stored in Settings.xml in the config package folder.
The service developer uses Service Fabric APIs to locate the package folders and read applica-tion-overridable configuration settings.
The service developer can also register callbacks that are in-voked when any of the configuration packages specified in the
service manifest are upgraded and re-reads new configuration settings inside that callback.
This means that Service Fabric will not recycle EXEs and DLLHOSTs specified in the host and support packages when
configuration packages are up-graded.

View File

@ -0,0 +1,5 @@
Data packages contain data files like custom dictionaries,
non-overridable configuration files, custom initialized data files, etc.
Service Fabric will recycle all EXEs and DLLHOSTs specified in the host and support packages when any of the data packages
specified inside service manifest are upgraded.

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<ServiceManifest Name="OcelotApplicationServicePkg"
Version="1.0.0"
xmlns="http://schemas.microsoft.com/2011/01/fabric"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ServiceTypes>
<!-- This is the name of your ServiceType.
This name must match the string used in RegisterServiceType call in Program.cs. -->
<StatelessServiceType ServiceTypeName="OcelotApplicationServiceType" />
</ServiceTypes>
<!-- Code package is your service executable. -->
<CodePackage Name="Code" Version="1.0.0">
<EntryPoint>
<ExeHost>
<Program>entryPoint.sh</Program>
<ConsoleRedirection FileRetentionCount="5" FileMaxSizeInKb="2048"/>
</ExeHost>
</EntryPoint>
</CodePackage>
<!-- Config package is the contents of the Config directoy under PackageRoot that contains an
independently-updateable and versioned set of custom configuration settings for your service. -->
<ConfigPackage Name="Config" Version="1.0.0" />
<Resources>
<Endpoints>
<Endpoint Name="ServiceEndpoint" Protocol="http"/>
</Endpoints>
</Resources>
</ServiceManifest>

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<ServiceManifest Name="OcelotApplicationServicePkg"
Version="1.0.0"
xmlns="http://schemas.microsoft.com/2011/01/fabric"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ServiceTypes>
<!-- This is the name of your ServiceType.
This name must match the string used in RegisterServiceType call in Program.cs. -->
<StatelessServiceType ServiceTypeName="OcelotApplicationServiceType" />
</ServiceTypes>
<!-- Code package is your service executable. -->
<CodePackage Name="Code" Version="1.0.0">
<EntryPoint>
<ExeHost>
<Program>entryPoint.cmd</Program>
<ConsoleRedirection FileRetentionCount="5" FileMaxSizeInKb="2048"/>
</ExeHost>
</EntryPoint>
</CodePackage>
<!-- Config package is the contents of the Config directoy under PackageRoot that contains an
independently-updateable and versioned set of custom configuration settings for your service. -->
<ConfigPackage Name="Config" Version="1.0.0" />
<Resources>
<Endpoints>
<Endpoint Name="ServiceEndpoint" Protocol="http"/>
</Endpoints>
</Resources>
</ServiceManifest>

View File

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="utf-8"?>
<ServiceManifest Name="OcelotApplicationServicePkg"
Version="1.0.0"
xmlns="http://schemas.microsoft.com/2011/01/fabric"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ServiceTypes>
<!-- This is the name of your ServiceType.
This name must match the string used in RegisterServiceType call in Program.cs. -->
<StatelessServiceType ServiceTypeName="OcelotApplicationServiceType" />
</ServiceTypes>
<!-- Code package is your service executable. -->
<CodePackage Name="Code" Version="1.0.0">
<EntryPoint>
<ExeHost>
<Program>entryPoint.cmd</Program>
<ConsoleRedirection FileRetentionCount="5" FileMaxSizeInKb="2048"/>
</ExeHost>
</EntryPoint>
</CodePackage>
<!-- Config package is the contents of the Config directoy under PackageRoot that contains an
independently-updateable and versioned set of custom configuration settings for your service. -->
<ConfigPackage Name="Config" Version="1.0.0" />
<Resources>
<Endpoints>
<Endpoint Name="ServiceEndpoint" Protocol="http"/>
</Endpoints>
</Resources>
</ServiceManifest>