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 filtering abilities into Agent.Services #128

Conversation

marcin-krystianc
Copy link
Contributor

@marcin-krystianc marcin-krystianc commented Oct 21, 2021

@@ -37,8 +37,12 @@ internal static string GenerateTestKeyName()

for (var i = 0; i < keyChars.Length; i++)
{
keyChars[i] = Convert.ToChar(Random.Next(65, 91));
lock (Random)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Random class is not thread-safe, we need to make sure only one thread uses it at a time.

{
return _client.Get<Dictionary<string, AgentService>>("/v1/agent/services").Execute(ct);
return await Services(null, ct);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is better to use await even for simple pass-through invocations like this one. When the call is not awaited then it will be not visible on the call stack (if there is an exception being thrown within that call).

Copy link
Member

Choose a reason for hiding this comment

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

Does this change break the API or ABI compatibility?

To be clear, I'm not arguing against it at all, I just wonder what it might mean in terms of semantic versioning.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, it is not affecting nether API nor ABI compatibility.
The 'aysnc' keyword doesn't change the "signature" of a method (note that the IAgentEndpoint doesn't use async keywords).

Copy link
Contributor

@adamreeve adamreeve left a comment

Choose a reason for hiding this comment

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

👍 looks good to me

Copy link
Member

@jgiannuzzi jgiannuzzi left a comment

Choose a reason for hiding this comment

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

LGTM too 👍

Copy link
Contributor

@mfkl mfkl left a comment

Choose a reason for hiding this comment

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

Looks OK.

Looking at the consul API, we should probably list the remaining tasks for full coverage of various Consul APIs. For example, for filtering, there is an extra parameter for enterprise Consul users (do we have any support policy for the Enterprise version of Consul btw?!) https://www.consul.io/api-docs/agent/service#parameters

Likewise, our selectors could support more keys https://www.consul.io/api-docs/agent/service#filtering. Just a few remarks on follow-up work, this is good to merge.

@marcin-krystianc marcin-krystianc merged commit 1480f7c into G-Research:master Oct 25, 2021
@marcin-krystianc marcin-krystianc deleted the dev-marcink-2021101-agentfiltering branch October 25, 2021 07:36
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.

Filter Agent Services on ServiceName?
4 participants