-
Notifications
You must be signed in to change notification settings - Fork 0
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
#1 Create Nacos service discovery provider #2
base: main
Are you sure you want to change the base?
Conversation
🆗 Great! Thank you for creation this PR! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please organize the folder structure more efficiently.
There is no need to create sub-sub folders.
Ocelot.Discovery.Nacos/src/Ocelot.Discovery.Nacos/GlobalUsings.cs
Outdated
Show resolved
Hide resolved
Ocelot.Discovery.Nacos/src/Ocelot.Discovery.Nacos/GlobalUsings.cs
Outdated
Show resolved
Hide resolved
Ocelot.Discovery.Nacos/test/Ocelot.Discovery.Nacos.UnitTest/MSTestSettings.cs
Outdated
Show resolved
Hide resolved
The solution and folder structure now appear satisfactory to me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added GitHub Actions workflows. And the latest build job produced a number of warnings (see in Files changed).
Could you fix all of them please?
src/Nacos.cs
Outdated
|
||
return new Service( | ||
id: instance.InstanceId, | ||
hostAndPort: new ServiceHostAndPort(instance.Ip, instance.Port), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hostAndPort: new ServiceHostAndPort(instance.Ip, instance.Port), | |
hostAndPort: new(instance.Ip, instance.Port), |
What is the scheme? Is the scheme known at this stage of building service?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a client fetches a service, it will access the corresponding service based on the address information at the time of registration, so if the registration is for an HTTPS address, then the fetched service is HTTPS, and vice versa.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, in the Nacos service discovery, scheme (protocol) management is not required, right?
For example, in Kubernetes we can manage the protocol while registering a service instance in the K8s registry.
In the next round of development, we will write acceptance tests that will show real usage in practice.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please fix warnings generated by static code analysis tool during execution of latest GitHub action build.
Miao, what is the current code coverage achieved by unit tests? |
61% coverage is low. |
4b53651
to
d7c7c33
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend using IOcelotLogger
instead of ILogger<Nacos>
.
After this minor refactoring, I will verify the actual code coverage through unit tests once again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for addressing the issues from the previous code review! ❤️
The repository looks much better now with the initial solution and unit testing in place. However, I am concerned that it has not been tested with real HTTP requests. It would be prudent commence acceptance testing at this stage. We need to conduct load testing to ensure that the provider can handle a high number of parallel requests.
- I'm going to add a commit with a draft version of the acceptance testing project.
- Please find below my additional suggestions for improving the code.
id: instance.InstanceId, | ||
hostAndPort: new(instance.Ip, instance.Port), | ||
name: instance.ServiceName, | ||
version: metadata.GetValueOrDefault("version", "default"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot get this default value. Could you show me in Nacos docs please that default version is marked as "default"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The version value is not explicitly defined as "default" in the Nacos documentation. The "default" value in the code is a custom fallback in case there is no "version" key in the metadata dictionary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You confirmed that this is the issue. I am not certain but these values may be applicable: current
, latest
, default
.
Question: How can the default
be consumed by Ocelot or Nacos client?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The version can be customized through the configuration file.
src/Nacos.cs
Outdated
private static string FormatTag(KeyValuePair<string, string> kv) | ||
=> $"{WebUtility.UrlEncode(kv.Key)}={WebUtility.UrlEncode(kv.Value)}"; | ||
|
||
private static readonly string[] _reservedKeys = { "version", "group", "cluster", "namespace", "weight" }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be better to make this definition public
.
Could you provide some links to metadata documentation that explain this?
I suggest writing an XML documentation (in the code) for the definition of the array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the nacos java version of the sdk, these are included by default, but in the nacos .net sdk these are not included by default and need to be added by yourself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please make this array publicly accessible, then.
builder.Services | ||
.AddNacosAspNet(builder.Configuration,section) | ||
.AddSingleton(NacosProviderFactory.Get) | ||
.AddSingleton(NacosMiddlewareConfigurationProvider.Get); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a word of caution!
It might be premature to define this since you were inspired by the Consul provider and ConsulMiddlewareConfigurationProvider implementation. However, please note that this Consul config provider was developed specifically for the AddConfigStoredInConsul()
feature, correct?
Therefore, let's keep it in the code for now, the next phase of acceptance testing will reveal the subsequent steps.
Hello, Miao! Current pitfalls of the project:
Finally, I believe that releasing this package for .NET 6+8 with the draft acceptance testing project is acceptable. However, we must develop real tests, and they must pass. Let's go! |
@MiaoShuYo commented on March 21
🆗 I am curious to know which IDE and code coverage did you utilize for measurement? |
Rider |
Please work on the acceptance tests as they are a required part of the PR process. Afterward, I will assist you in writing documentation. Do not hesitate to ask questions, I understand that acceptance testing can be a challenging milestone. P.S. Currently I am occupied with the release of the Ocelot version for .NET9. Apologies for being very busy at moment. |
I am very sorry that I recently had an operation due to an accident, so I cannot carry out relevant development for the time being. It is expected to be suspended for three to five months. |
Wow, I'm saddened to hear that! I wish you a smooth and speedy recovery. 💟 P.S. Since development will be suspended for the next X months, I need to inform you that the package will not be released. The version for .NET 9 will be released after your return to development. In the meantime, within the next 1–2 months, I’ll try to release a very draft version for the current TFMs: |
Closes #1
Related to