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

Akka.Discovery #4599

Merged
merged 3 commits into from
Nov 16, 2020
Merged

Akka.Discovery #4599

merged 3 commits into from
Nov 16, 2020

Conversation

ismaelhamed
Copy link
Member

Akka Discovery provides an interface around various ways of locating services. The built in methods are:

  • Configuration
  • Aggregate
  • DNS

Current known limitation

Endpoints should be defined as a list of configs:

akka.discovery.config.services = {
  service1 = {
    endpoints = [
      {
        host = "cat"
        port = 1233
      },
      {
        host = "dog"
        port = 1234
      }
    ]
  }
}

But AFAIK this is not possible with current Hocon implementation, at least unless #293 is implemented. So, in the mean time I have resorted to define endpoints as a lists of strings (much like we do with seed-nodes):

akka.discovery.config.services = {
  service1 = {
    endpoints = [
        "cat:1233",
        "dog:1234"
    ]
  }
}

<PropertyGroup>
<AssemblyTitle>Akka.Discovery.Tests</AssemblyTitle>
<TargetFrameworks>$(NetFrameworkTestVersion);$(NetCoreTestVersion)</TargetFrameworks>
<LangVersion>8</LangVersion>
Copy link
Member Author

@ismaelhamed ismaelhamed Oct 31, 2020

Choose a reason for hiding this comment

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

I hope this is fine for new projects.

Copy link
Member

Choose a reason for hiding this comment

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

Yep, that should be fine as long as we don't use default interfaces - which aren't binary backwards compatible

public override Task<Resolved> Lookup(Lookup query, TimeSpan resolveTimeout) =>
Resolve(_methods, query, resolveTimeout);

private async Task<Resolved> Resolve(IReadOnlyCollection<(string, ServiceDiscovery)> sds, Lookup query, TimeSpan resolveTimeout)
Copy link
Member Author

@ismaelhamed ismaelhamed Oct 31, 2020

Choose a reason for hiding this comment

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

Resolve is recursive. I think its fine, but it's open for improvements.

Copy link
Member

Choose a reason for hiding this comment

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

if someone runs into an issue with it, they we can always change it later

<TargetFramework>$(NetStandardLibVersion)</TargetFramework>
<PackageTags>$(AkkaPackageTags)</PackageTags>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<LangVersion>8</LangVersion>
Copy link
Member Author

Choose a reason for hiding this comment

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

I hope this is fine for new projects.

.ToDictionary(pair => pair.Key, pair =>
{
var (serviceName, full) = pair;
var endpoints = full.GetStringList("endpoints");
Copy link
Member Author

Choose a reason for hiding this comment

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

Missing GetConfigList, not currently supported

Copy link
Member

Choose a reason for hiding this comment

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

@Arkatufus is this something we need to add to the HOCON spec?

Copy link
Member Author

@ismaelhamed ismaelhamed Nov 7, 2020

Choose a reason for hiding this comment

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

I've linked an issue on the HOCON repo to this

@Aaronontheweb
Copy link
Member

@ismaelhamed looks like you're off to a great start! I'll do a deeper review soon - but do we need to wait until the DNS discovery is available before we consider merging this? Just want to know if I should wait for that before diving in.

@ismaelhamed
Copy link
Member Author

ismaelhamed commented Nov 7, 2020

Since both Config and Aggregate options are ready, IMO you should merge this as soon as you approve it. There seems to be some work to do on the Akka.Io.Dns in order to implement the DNS API, and that's something that you guys might want to plan carefully.

Also, I understand this new module will be released as a beta package first, so having it half-backed for now shouldn't be a problem.

@Aaronontheweb Aaronontheweb added this to the 1.4.12 milestone Nov 10, 2020
@Aaronontheweb Aaronontheweb linked an issue Nov 10, 2020 that may be closed by this pull request
@Aaronontheweb
Copy link
Member

Going to review this today

Copy link
Member

@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.

Some minor changes that I documented - but none worth blocking the merge of this PR. I'll send in a separate PR to add the beta tag for Akka.Discovery so we can include this as part of Akka.NET v1.4.12

@@ -0,0 +1,110 @@
//-----------------------------------------------------------------------
// <copyright file="Lease.cs" company="Akka.NET Project">
Copy link
Member

Choose a reason for hiding this comment

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

File name is technically wrong here

}

[InternalApi]
public class AggregateServiceDiscovery : ServiceDiscovery
Copy link
Member

Choose a reason for hiding this comment

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

LGTM

<PackageTags>$(AkkaPackageTags)</PackageTags>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<LangVersion>8</LangVersion>
</PropertyGroup>
Copy link
Member

Choose a reason for hiding this comment

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

need to add a tag here to mark this as a pre-release module


namespace Akka.Discovery
{
public class Discovery : IExtension
Copy link
Member

Choose a reason for hiding this comment

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

Should probably have an XML-DOC comment here

@Aaronontheweb
Copy link
Member

@ismaelhamed could you open an issue describing the Akka.IO DNS changes that we need to make in order to support DNS-based service discovery? We should start planning for those.

@Aaronontheweb Aaronontheweb merged commit e645a43 into akkadotnet:dev Nov 16, 2020
This was referenced Nov 16, 2020
@mchandschuh
Copy link
Contributor

Was DNS discovery ever implemented, and if not, is there an expected timeline and/or an issue available to track the progress (tried searching but didn't find it). Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Port Akka.Discovery to core Akka.NET library
3 participants