Skip to content

Commit

Permalink
Merge pull request #679 from Aaronontheweb/fix-671
Browse files Browse the repository at this point in the history
Automatic App / Web.config loading #671
  • Loading branch information
Aaronontheweb committed Feb 26, 2015
2 parents 745ff1c + 72b3720 commit 0039248
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 117 deletions.
13 changes: 1 addition & 12 deletions src/core/Akka.Tests/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,14 @@
stdout-loglevel = INFO
loglevel = ERROR
actor {
provider = ""Akka.Remote.RemoteActorRefProvider, Akka.Remote""
debug {
receive = on
autoreceive = on
lifecycle = on
event-stream = on
unhandled = on
}
}
remote {
#this is the new upcoming remoting support, which enables multiple transports
helios.tcp {
transport-class = ""Akka.Remote.Transport.Helios.HeliosTcpTransport, Akka.Remote""
#applied-adapters = []
transport-protocol = tcp
port = 8091
hostname = ""127.0.0.1""
}
log-remote-lifecycle-events = INFO
}
}
]]>
</hocon>
Expand Down
5 changes: 3 additions & 2 deletions src/core/Akka/Configuration/ConfigurationFactory.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Configuration;
using System.Diagnostics;
using System.IO;
using System.Reflection;
Expand Down Expand Up @@ -37,8 +38,8 @@ public static Config ParseString(string hocon)
/// <returns>Config.</returns>
public static Config Load()
{
var section = new AkkaConfigurationSection();
Config config = section.AkkaConfig;
var section = (AkkaConfigurationSection)ConfigurationManager.GetSection("akka") ?? new AkkaConfigurationSection();
var config = section.AkkaConfig;

return config;
}
Expand Down
55 changes: 52 additions & 3 deletions src/examples/TimeServer/TimeClient/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,55 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<configSections>
<section name="akka" type="Akka.Configuration.Hocon.AkkaConfigurationSection, Akka" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<akka>
<hocon>
<![CDATA[
akka {
log-config-on-start = on
stdout-loglevel = DEBUG
loglevel = ERROR
actor {
provider = "Akka.Remote.RemoteActorRefProvider, Akka.Remote"
debug {
receive = off
autoreceive = on
lifecycle = on
event-stream = on
unhandled = on
}
}
deployment{
/user/timeChecker{
router = round-robin-pool
nr-of-instances = 10
}
}
remote {
log-received-messages = off
log-sent-messages = off
#this is the new upcoming remoting support, which enables multiple transports
helios.tcp {
transport-class = "Akka.Remote.Transport.Helios.HeliosTcpTransport, Akka.Remote"
applied-adapters = []
transport-protocol = tcp
port = 0 #bind to any available port
hostname = 0.0.0.0 #listens on ALL ips for this machine
public-hostname = localhost #but only accepts connections on localhost (usually 127.0.0.1)
}
log-remote-lifecycle-events = INFO
}
}
]]>
</hocon>
</akka>
</configuration>
51 changes: 1 addition & 50 deletions src/examples/TimeServer/TimeClient/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal class Program

private static void Main(string[] args)
{
using (var system = ActorSystem.Create("TimeClient", Config))
using (var system = ActorSystem.Create("TimeClient"))
{
var tmp = system.ActorSelection("akka.tcp://TimeServer@localhost:9391/user/time");
Console.Title = string.Format("TimeClient {0}", Process.GetCurrentProcess().Id);
Expand Down Expand Up @@ -63,54 +63,5 @@ public void Handle(CheckTime message)
_timeServer.Tell("gettime", Self);
}
}

public static Config Config
{
get
{
return ConfigurationFactory.ParseString(@"
akka {
log-config-on-start = on
stdout-loglevel = DEBUG
loglevel = ERROR
actor {
provider = ""Akka.Remote.RemoteActorRefProvider, Akka.Remote""
debug {
receive = off
autoreceive = on
lifecycle = on
event-stream = on
unhandled = on
}
}
deployment{
/user/timeChecker{
router = round-robin-pool
nr-of-instances = 10
}
}
remote {
log-received-messages = off
log-sent-messages = off
#this is the new upcoming remoting support, which enables multiple transports
helios.tcp {
transport-class = ""Akka.Remote.Transport.Helios.HeliosTcpTransport, Akka.Remote""
applied-adapters = []
transport-protocol = tcp
port = 0 #bind to any available port
hostname = 0.0.0.0 #listens on ALL ips for this machine
public-hostname = localhost #but only accepts connections on localhost (usually 127.0.0.1)
}
log-remote-lifecycle-events = INFO
}
}
");
}
}
}
}
49 changes: 49 additions & 0 deletions src/examples/TimeServer/TimeServer/App.config
Original file line number Diff line number Diff line change
@@ -1,6 +1,55 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="akka" type="Akka.Configuration.Hocon.AkkaConfigurationSection, Akka" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<akka>
<hocon>
<![CDATA[
akka {
log-config-on-start = on
stdout-loglevel = DEBUG
loglevel = ERROR
actor {
provider = "Akka.Remote.RemoteActorRefProvider, Akka.Remote"
debug {
receive = on
autoreceive = on
lifecycle = on
event-stream = on
unhandled = on
}
}
deployment{
/user/time{
router = round-robin-pool
nr-of-instances = 10
}
}
remote {
log-received-messages = off
log-sent-messages = off
#this is the new upcoming remoting support, which enables multiple transports
helios.tcp {
transport-class = "Akka.Remote.Transport.Helios.HeliosTcpTransport, Akka.Remote"
applied-adapters = []
transport-protocol = tcp
port = 9391
hostname = 0.0.0.0 #listens on ALL ips for this machine
public-hostname = localhost #but only accepts connections on localhost (usually 127.0.0.1)
}
log-remote-lifecycle-events = INFO
}
}
]]>
</hocon>
</akka>
</configuration>
51 changes: 1 addition & 50 deletions src/examples/TimeServer/TimeServer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Program
{
static void Main(string[] args)
{
using (var system = ActorSystem.Create("TimeServer", Config))
using (var system = ActorSystem.Create("TimeServer"))
{
Console.Title = "Server";
var server = system.ActorOf<TimeServerActor>("time");
Expand All @@ -20,55 +20,6 @@ static void Main(string[] args)
}
}

public static Config Config
{
get
{
return ConfigurationFactory.ParseString(@"
akka {
log-config-on-start = on
stdout-loglevel = DEBUG
loglevel = ERROR
actor {
provider = ""Akka.Remote.RemoteActorRefProvider, Akka.Remote""
debug {
receive = on
autoreceive = on
lifecycle = on
event-stream = on
unhandled = on
}
}
deployment{
/user/time{
router = round-robin-pool
nr-of-instances = 10
}
}
remote {
log-received-messages = off
log-sent-messages = off
#this is the new upcoming remoting support, which enables multiple transports
helios.tcp {
transport-class = ""Akka.Remote.Transport.Helios.HeliosTcpTransport, Akka.Remote""
applied-adapters = []
transport-protocol = tcp
port = 9391
hostname = 0.0.0.0 #listens on ALL ips for this machine
public-hostname = localhost #but only accepts connections on localhost (usually 127.0.0.1)
}
log-remote-lifecycle-events = INFO
}
}
");
}
}

public class TimeServerActor : TypedActor, IHandle<string>
{
private readonly LoggingAdapter _log = Context.GetLogger();
Expand Down

2 comments on commit 0039248

@Petabridge-CI
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TeamCity Akka.NET :: Akka.NET PR Build Build 63 is now running

@Petabridge-CI
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TeamCity Akka.NET :: Akka.NET PR Build Build 63 outcome was FAILURE
Summary: System.Exception: xUnit failed for the following assemblies: D:\BuildAgent\work\49b164d63843fb4\src\core\Akka.Persistence.Tests\bin\Release\Akka.Persistence.Tests.dll, D:\BuildAgent\work\49b164d63843fb4\src\core\Akka.Tests\bin\Release\Akka.Tests.dll ... Build time: 00:10:13

Failed tests

Akka.Tests.dll: Akka.Tests.Routing.ResizerSpec.DefaultResizer_must_backoff: <no details avaliable>

Akka.Persistence.Tests.dll: Akka.Persistence.Tests.GuaranteedDeliveryCrashSpec.GuaranteedDelivery_should_not_send_when_actor_crashes: <no details avaliable>

Please sign in to comment.