Skip to content

Commit

Permalink
Using EnvironmentVariableTarget.Machine to get the environment variab…
Browse files Browse the repository at this point in the history
…les. (#1220)

EnvironmentVariableTarget.Machine 

The environment variable is stored or retrieved from the HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment key in the Windows operating system registry. This value should be used on .NET implementations running on Windows systems only.

https://learn.microsoft.com/en-us/dotnet/api/system.environmentvariabletarget?view=net-6.0
  • Loading branch information
cuibty authored Oct 14, 2022
1 parent 702afed commit 1fa8d4c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/DotNetCore.CAP/Internal/SnowflakeId.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public static SnowflakeId Default()
return _snowflakeId;
}

if (!long.TryParse(Environment.GetEnvironmentVariable("CAP_WORKERID", EnvironmentVariableTarget.Machine), out var workerId))
if (!long.TryParse(Environment.GetEnvironmentVariable("CAP_WORKERID"), out var workerId))
{
workerId = Util.GenerateWorkerId(MaxWorkerId);
}
Expand Down Expand Up @@ -188,4 +188,4 @@ private static long GenerateRandomWorkerId(int maxWorkerId)
return new Random().Next(maxWorkerId + 1);
}
}
}
}

0 comments on commit 1fa8d4c

Please sign in to comment.