Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added AddHoconFile method #58

Merged
merged 1 commit into from
Jun 9, 2022

Conversation

Aaronontheweb
Copy link
Member

@Aaronontheweb Aaronontheweb commented Jun 9, 2022

Changes

Allows Akka.Hosting to automatically load HOCON from a file. Solves a longtime painpoint for users where they typically had to call ConfigurationFactory.ParseString(File.ReadAllText(filePath)). Now it's a one-liner.

Checklist

For significant changes, please ensure that the following have been completed (delete if not relevant):

Allows Akka.Hosting to automatically load HOCON from a file.
@Aaronontheweb Aaronontheweb added this to the 0.3.1 milestone Jun 9, 2022
Copy link
Member Author

@Aaronontheweb Aaronontheweb left a comment

Choose a reason for hiding this comment

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

Reviewed my own changes

@@ -36,19 +36,6 @@ public SingletonActor(IMySingletonInterface singleton)
});
}
}

private static async Task<IHost> StartHost(Action<IServiceCollection> testSetup)
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved this to a separate TestHelpers class so it can be re-used across multiple tests

var hocon = sys.Settings.Config;

// assert
hocon.HasPath("petabridge.cmd").Should().BeTrue();
Copy link
Member Author

Choose a reason for hiding this comment

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

This is a custom HOCON section in the test.hocon file that wouldn't normally appear in default HOCON - thus it demonstrates that the file is being correctly loaded into the ActorSystem as a result of the AddHoconFile method.

public static AkkaConfigurationBuilder AddHoconFile(this AkkaConfigurationBuilder builder, string hoconFilePath,
HoconAddMode addMode = HoconAddMode.Append)
{
var hoconText = ConfigurationFactory.ParseString(File.ReadAllText(hoconFilePath));
Copy link
Member Author

Choose a reason for hiding this comment

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

parses the file synchronously - this will throw an exception if the file is not found, which is to be expected.

Copy link
Contributor

@Arkatufus Arkatufus left a comment

Choose a reason for hiding this comment

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

LGTM

@Arkatufus Arkatufus merged commit a563398 into akkadotnet:dev Jun 9, 2022
@Aaronontheweb Aaronontheweb deleted the load-hocon-file branch June 9, 2022 14:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants