Skip to content
This repository has been archived by the owner on May 23, 2023. It is now read-only.

Commit

Permalink
Merge pull request #75 from petabridge/dev
Browse files Browse the repository at this point in the history
v0.4.0-rc1 release
  • Loading branch information
Aaronontheweb authored Mar 5, 2020
2 parents 9660ae2 + 8e5c941 commit 89f5c93
Show file tree
Hide file tree
Showing 14 changed files with 68 additions and 21 deletions.
5 changes: 2 additions & 3 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
#### 0.3.0 December 31 2019 ####
* Updated all underlying dependencies to Akka.NET latest.
* Added [support for automatically loading environment variables into HOCON via Akka.Bootstrap.Docker](https://github.com/petabridge/akkadotnet-bootstrap/issues/62).
#### 0.4.0-rc1 March 04 2020 ####
* Upgraded to Akka.NET v1.4.1-rc1 and used native environment variable substitution from HOCON
17 changes: 12 additions & 5 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,22 @@ let solutionFile = FindFirstMatchingFile "*.sln" __SOURCE_DIRECTORY__ // dynami
let buildNumber = environVarOrDefault "BUILD_NUMBER" "0"
let hasTeamCity = (not (buildNumber = "0")) // check if we have the TeamCity environment variable for build # set
let preReleaseVersionSuffix = "beta" + (if (not (buildNumber = "0")) then (buildNumber) else DateTime.UtcNow.Ticks.ToString())
let versionSuffix =
match (getBuildParam "nugetprerelease") with
| "dev" -> preReleaseVersionSuffix
| _ -> ""

let releaseNotes =
File.ReadLines "./RELEASE_NOTES.md"
File.ReadLines (__SOURCE_DIRECTORY__ @@ "RELEASE_NOTES.md")
|> ReleaseNotesHelper.parseReleaseNotes

let versionFromReleaseNotes =
match releaseNotes.SemVer.PreRelease with
| Some r -> r.Origin
| None -> ""

let versionSuffix =
match (getBuildParam "nugetprerelease") with
| "dev" -> preReleaseVersionSuffix
| "" -> versionFromReleaseNotes
| str -> str

// Directories
let toolsDir = __SOURCE_DIRECTORY__ @@ "tools"
let output = __SOURCE_DIRECTORY__ @@ "bin"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="Petabridge.Cmd.Cluster" Version="0.7.0" />
<PackageReference Include="Petabridge.Cmd.Remote" Version="0.7.0" />
<PackageReference Include="Petabridge.Cmd.Cluster" Version="0.8.0-rc1" />
<PackageReference Include="Petabridge.Cmd.Remote" Version="0.8.0-rc1" />
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion src/Akka.Bootstrap.Docker.Sample/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using Akka.Configuration;
using Akka.Event;
using Akka.Routing;
using Hocon;
using Petabridge.Cmd.Cluster;
using Petabridge.Cmd.Host;
using Petabridge.Cmd.Remote;
Expand All @@ -20,7 +21,7 @@ static void Main(string[] args)
Environment.SetEnvironmentVariable("CLUSTER_IP", "localhost");
}

var config = ConfigurationFactory.ParseString(File.ReadAllText("app.conf"))
var config = HoconConfigurationFactory.Default()
.BootstrapFromDocker(); // forces all Docker environment variable substitution
var actorSystem = ActorSystem.Create("DockerBootstrap", config);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="5.9.0" />
<PackageReference Include="FluentAssertions" Version="5.10.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(TestSdkVersion)" />
<PackageReference Include="xunit" Version="$(XunitVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitVersion)" />
Expand Down
2 changes: 1 addition & 1 deletion src/Akka.Bootstrap.Docker.Tests/DockerBootstrapSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public void ShouldStartIfValidSeedNodesIfSupplied(string seedNodes)
Environment.SetEnvironmentVariable("CLUSTER_SEEDS", seedNodes, EnvironmentVariableTarget.Process);
var myConfig = ConfigurationFactory.Empty.BootstrapFromDocker();
myConfig.HasPath("akka.cluster.seed-nodes").Should().BeTrue();
var seeds = myConfig.GetStringList("akka.cluster.seed-nodes");
var seeds = myConfig.GetStringList("akka.cluster.seed-nodes").Select(x => x.Trim());
seeds.Should().BeEquivalentTo(seedNodes.Split(",").Select(x => x.Trim()));
}
finally
Expand Down
1 change: 1 addition & 0 deletions src/Akka.Bootstrap.Docker/DockerBootstrap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using System.Net;
using System.Text;
using Akka.Configuration;
using Hocon;

namespace Akka.Bootstrap.Docker
{
Expand Down
3 changes: 3 additions & 0 deletions src/Akka.Bootstrap.Docker/EnvironmentVariableConfigLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Linq;
using System.Text;
using Akka.Configuration;
using Hocon;

namespace Akka.Bootstrap.Docker
{
Expand Down Expand Up @@ -113,6 +114,8 @@ public static Config FromEnvironment(this Config input)
}
}

if(sb.Length == 0)
return Config.Empty;
var config = ConfigurationFactory.ParseString(sb.ToString());

return config;
Expand Down
35 changes: 35 additions & 0 deletions src/Akka.Bootstrap.Docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,41 @@ This library works with any runtime supported by Akka.NET.
* `CLUSTER_PORT` - the port number that will be used by Akka.Remote for inbound connections.
* `CLUSTER_SEEDS` - a comma-delimited list of seed node addresses used by Akka.Cluster. Here's [an example](https://github.com/petabridge/Cluster.WebCrawler/blob/9f854ff2bfb34464769f562936183ea7719da4ea/yaml/k8s-tracker-service.yaml#L46-L47).

### Using Environment Variables to Configure Akka.NET
In addition to the standardized environment variables listed above, the `Akka.Bootstrap.Docker` NuGet package can also parse Akka.NET configuration from environment variables. In order for the package to map environment variables to a HOCON entry, the name of the environment variable must adhere to the following conventions:

* Full stops (`.`) in the HOCON path are replaced with two underscores (`__`)
* Hyphens (`-`) in the HOCON path are replaced with one underscore (`_`)
* For an array based HOCON entry, the environment variable should be suffixed by two underscores and the index of the entry within the array (`__0`, `__1`, `__2`, etc. ).

As an example, the following list of environment variables:

```
AKKA__COORDINATED_SHUTDOWN__EXIT_CLR="on"
AKKA__ACTOR__PROVIDER="cluster"
AKKA__REMOTE__DOT_NETTY__TCP__HOSTNAME="127.0.0.1"
AKKA__REMOTE__DOT_NETTY__TCP__PUBLIC_HOSTNAME="example.local"
AKKA__REMOTE__DOT_NETTY__TCP__PORT="2559"
AKKA__CLUSTER__ROLES__0="demo"
AKKA__CLUSTER__ROLES__1="test"
AKKA__CLUSTER__ROLES__2="backup"
```

will produce a HOCON structure of:

```
akka {
coordinated_shutdown.exit_clr = "on"
actor.provider = "cluster"
remote.dot_netty.tcp {
hostname = "127.0.0.1"
public_hostname = "example.local"
port = "2559"
}
cluster.roles = [ "demo", "test", "backup" ]
}
```

### Using `Akka.Bootstrap.Docker`
The `Akka.Bootstrap.Docker` NuGet package itself is pretty simple - all it does is expose the `DockerBootstrap` class which gives you the ability to automatically load all of the environment variables we pass in via Docker into your Akka.Remote and Akka.Cluster configuration:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="5.9.0" />
<PackageReference Include="FluentAssertions" Version="5.10.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(TestSdkVersion)" />
<PackageReference Include="xunit" Version="$(XunitVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitVersion)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentAssertions" Version="5.9.0" />
<PackageReference Include="FluentAssertions" Version="5.10.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="$(TestSdkVersion)" />
<PackageReference Include="xunit" Version="$(XunitVersion)" />
<PackageReference Include="xunit.runner.visualstudio" Version="$(XunitVersion)" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System;
using System.Linq;
using Akka.Configuration;
using Hocon;
using FluentAssertions;
using Xunit;

Expand Down
1 change: 1 addition & 0 deletions src/Akka.Bootstrap.ServiceFabric/ServiceFabricBootstrap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System;
using System.Linq;
using Akka.Configuration;
using Hocon;

namespace Akka.Bootstrap.ServiceFabric
{
Expand Down
11 changes: 5 additions & 6 deletions src/common.props
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
<Project>
<PropertyGroup>
<Copyright>Copyright © 2015-2019 Petabridge®</Copyright>
<Copyright>Copyright © 2015-2020 Petabridge®</Copyright>
<Authors>Petabridge</Authors>
<VersionPrefix>0.3.0</VersionPrefix>
<PackageReleaseNotes>Updated all underlying dependencies to Akka.NET latest.
Added [support for automatically loading environment variables into HOCON via Akka.Bootstrap.Docker](https://github.com/petabridge/akkadotnet-bootstrap/issues/62).</PackageReleaseNotes>
<VersionPrefix>0.4.0</VersionPrefix>
<PackageReleaseNotes>Upgraded to Akka.NET v1.4.1-rc1 and used native environment variable substitution from HOCON</PackageReleaseNotes>
<PackageIconUrl>https://petabridge.com/images/logo.png</PackageIconUrl>
<PackageProjectUrl>https://github.com/petabridge/akkadotnet-bootstrap</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/petabridge/akkadotnet-bootstrap/blob/master/LICENSE</PackageLicenseUrl>
Expand All @@ -21,11 +20,11 @@ Added [support for automatically loading environment variables into HOCON via Ak
</PropertyGroup>
<PropertyGroup>
<XunitVersion>2.4.1</XunitVersion>
<TestSdkVersion>16.4.0</TestSdkVersion>
<TestSdkVersion>16.5.0</TestSdkVersion>
<NetCoreTestVersion>netcoreapp2.1</NetCoreTestVersion>
<NetStandardVersion>netstandard2.0</NetStandardVersion>
<NetFrameworkTestVersion>net461</NetFrameworkTestVersion>
<AkkaVersion>1.3.17</AkkaVersion>
<AkkaVersion>1.4.1-rc1</AkkaVersion>
<SourceLinkVersion>1.0.0</SourceLinkVersion>
</PropertyGroup>
</Project>

0 comments on commit 89f5c93

Please sign in to comment.