committed by
GitHub
62 changed files with 570 additions and 332 deletions
@ -0,0 +1,3 @@ |
|||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
|||
<ConfigureAwait ContinueOnCapturedContext="false" /> |
|||
</Weavers> |
|||
@ -0,0 +1,30 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
|||
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> |
|||
<xs:element name="Weavers"> |
|||
<xs:complexType> |
|||
<xs:all> |
|||
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1"> |
|||
<xs:complexType> |
|||
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" /> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:all> |
|||
<xs:attribute name="VerifyAssembly" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> |
|||
<xs:annotation> |
|||
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="GenerateXsd" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:schema> |
|||
@ -0,0 +1,15 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="..\..\..\configureawait.props" /> |
|||
<Import Project="..\..\..\common.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netstandard2.0</TargetFramework> |
|||
<RootNamespace /> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Volo.Abp.Core" Version="$(VoloAbpPackageVersion)" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,17 @@ |
|||
using LINGYUN.Abp.IdGenerator.Snowflake; |
|||
using Microsoft.Extensions.DependencyInjection; |
|||
using Microsoft.Extensions.DependencyInjection.Extensions; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace LINGYUN.Abp.IdGenerator; |
|||
|
|||
public class AbpIdGeneratorModule : AbpModule |
|||
{ |
|||
public override void ConfigureServices(ServiceConfigurationContext context) |
|||
{ |
|||
var snowflakeIdOptions = new SnowflakeIdOptions(); |
|||
context.Services.ExecutePreConfiguredActions(snowflakeIdOptions); |
|||
|
|||
context.Services.TryAddSingleton<IDistributedIdGenerator>(SnowflakeIdGenerator.Create(snowflakeIdOptions)); |
|||
} |
|||
} |
|||
@ -0,0 +1,6 @@ |
|||
namespace LINGYUN.Abp.IdGenerator; |
|||
|
|||
public interface IDistributedIdGenerator |
|||
{ |
|||
long Create(); |
|||
} |
|||
@ -0,0 +1,29 @@ |
|||
namespace LINGYUN.Abp.IdGenerator.Snowflake; |
|||
|
|||
public class SnowflakeIdOptions |
|||
{ |
|||
/// <summary>
|
|||
/// 机器Id长度
|
|||
/// </summary>
|
|||
public int WorkerIdBits { get; set; } |
|||
/// <summary>
|
|||
/// 机房Id长度
|
|||
/// </summary>
|
|||
public int DatacenterIdBits { get; set; } |
|||
/// <summary>
|
|||
/// 12bit 的序号
|
|||
/// </summary>
|
|||
public long Sequence { get; set; } |
|||
/// <summary>
|
|||
/// 每秒生成Id的数量
|
|||
/// </summary>
|
|||
public int SequenceBits { get; set; } |
|||
|
|||
public SnowflakeIdOptions() |
|||
{ |
|||
WorkerIdBits = 5; |
|||
DatacenterIdBits = 5; |
|||
Sequence = 0L; |
|||
SequenceBits = 12; |
|||
} |
|||
} |
|||
@ -1,7 +0,0 @@ |
|||
namespace LINGYUN.Abp.RealTime |
|||
{ |
|||
public interface ISnowflakeIdrGenerator |
|||
{ |
|||
long Create(); |
|||
} |
|||
} |
|||
@ -1,24 +0,0 @@ |
|||
namespace LINGYUN.Abp.RealTime |
|||
{ |
|||
public class SnowflakeIdOptions |
|||
{ |
|||
/// <summary>
|
|||
/// 机器Id长度
|
|||
/// </summary>
|
|||
public int WorkerIdBits { get; set; } |
|||
/// <summary>
|
|||
/// 机房Id长度
|
|||
/// </summary>
|
|||
public int DatacenterIdBits { get; set; } |
|||
/// <summary>
|
|||
/// 每秒生成Id的数量
|
|||
/// </summary>
|
|||
public int SequenceBits { get; set; } |
|||
public SnowflakeIdOptions() |
|||
{ |
|||
WorkerIdBits = 5; |
|||
DatacenterIdBits = 5; |
|||
SequenceBits = 12; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,3 @@ |
|||
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
|||
<ConfigureAwait /> |
|||
</Weavers> |
|||
@ -0,0 +1,30 @@ |
|||
<?xml version="1.0" encoding="utf-8"?> |
|||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
|||
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> |
|||
<xs:element name="Weavers"> |
|||
<xs:complexType> |
|||
<xs:all> |
|||
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1"> |
|||
<xs:complexType> |
|||
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" /> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:all> |
|||
<xs:attribute name="VerifyAssembly" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> |
|||
<xs:annotation> |
|||
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
<xs:attribute name="GenerateXsd" type="xs:boolean"> |
|||
<xs:annotation> |
|||
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> |
|||
</xs:annotation> |
|||
</xs:attribute> |
|||
</xs:complexType> |
|||
</xs:element> |
|||
</xs:schema> |
|||
@ -0,0 +1,19 @@ |
|||
<Project Sdk="Microsoft.NET.Sdk"> |
|||
|
|||
<Import Project="..\..\..\configureawait.props" /> |
|||
<Import Project="..\..\..\common.props" /> |
|||
|
|||
<PropertyGroup> |
|||
<TargetFramework>netstandard2.0</TargetFramework> |
|||
<RootNamespace /> |
|||
</PropertyGroup> |
|||
|
|||
<ItemGroup> |
|||
<PackageReference Include="Serilog" Version="$(SerilogPackageVersion)" /> |
|||
</ItemGroup> |
|||
|
|||
<ItemGroup> |
|||
<ProjectReference Include="..\..\common\LINGYUN.Abp.IdGenerator\LINGYUN.Abp.IdGenerator.csproj" /> |
|||
</ItemGroup> |
|||
|
|||
</Project> |
|||
@ -0,0 +1,10 @@ |
|||
using LINGYUN.Abp.IdGenerator; |
|||
using Volo.Abp.Modularity; |
|||
|
|||
namespace LINGYUN.Abp.Serilog.Enrichers.UniqueId |
|||
{ |
|||
[DependsOn(typeof(AbpIdGeneratorModule))] |
|||
public class AbpSerilogEnrichersUniqueIdModule : AbpModule |
|||
{ |
|||
} |
|||
} |
|||
@ -0,0 +1,7 @@ |
|||
namespace LINGYUN.Abp.Serilog.Enrichers.UniqueId |
|||
{ |
|||
public class AbpSerilogUniqueIdConsts |
|||
{ |
|||
public const string UniqueIdPropertyName = "UniqueId"; |
|||
} |
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
using LINGYUN.Abp.IdGenerator; |
|||
using LINGYUN.Abp.IdGenerator.Snowflake; |
|||
using Serilog.Core; |
|||
using Serilog.Events; |
|||
|
|||
namespace LINGYUN.Abp.Serilog.Enrichers.UniqueId |
|||
{ |
|||
public class UniqueIdEnricher : ILogEventEnricher |
|||
{ |
|||
private readonly static IDistributedIdGenerator _distributedIdGenerator |
|||
= SnowflakeIdGenerator.Create(new SnowflakeIdOptions()); |
|||
|
|||
public void Enrich(LogEvent logEvent, ILogEventPropertyFactory propertyFactory) |
|||
{ |
|||
logEvent.AddOrUpdateProperty( |
|||
propertyFactory.CreateProperty( |
|||
AbpSerilogUniqueIdConsts.UniqueIdPropertyName, |
|||
_distributedIdGenerator.Create())); |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,16 @@ |
|||
using LINGYUN.Abp.Serilog.Enrichers.UniqueId; |
|||
using Serilog.Configuration; |
|||
using System; |
|||
|
|||
namespace Serilog |
|||
{ |
|||
public static class UniqueIdLoggerConfigurationExtensions |
|||
{ |
|||
public static LoggerConfiguration WithUniqueId( |
|||
this LoggerEnrichmentConfiguration enrichmentConfiguration) |
|||
{ |
|||
if (enrichmentConfiguration == null) throw new ArgumentNullException(nameof(enrichmentConfiguration)); |
|||
return enrichmentConfiguration.With<UniqueIdEnricher>(); |
|||
} |
|||
} |
|||
} |
|||
@ -1,21 +1,30 @@ |
|||
|
|||
Microsoft Visual Studio Solution File, Format Version 12.00 |
|||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LINGYUN.MicroService.Internal.ApiGateway", "src\LINGYUN.MicroService.Internal.ApiGateway\LINGYUN.MicroService.Internal.ApiGateway.csproj", "{00A2F7A3-BEC3-48F4-A91C-5A336C32A5D2}" |
|||
EndProject |
|||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{E8067AED-2B6E-4134-AAF8-9101457D709A}" |
|||
EndProject |
|||
Global |
|||
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
|||
Debug|Any CPU = Debug|Any CPU |
|||
Release|Any CPU = Release|Any CPU |
|||
EndGlobalSection |
|||
GlobalSection(ProjectConfigurationPlatforms) = postSolution |
|||
{00A2F7A3-BEC3-48F4-A91C-5A336C32A5D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|||
{00A2F7A3-BEC3-48F4-A91C-5A336C32A5D2}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|||
{00A2F7A3-BEC3-48F4-A91C-5A336C32A5D2}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|||
{00A2F7A3-BEC3-48F4-A91C-5A336C32A5D2}.Release|Any CPU.Build.0 = Release|Any CPU |
|||
EndGlobalSection |
|||
GlobalSection(NestedProjects) = preSolution |
|||
{00A2F7A3-BEC3-48F4-A91C-5A336C32A5D2} = {E8067AED-2B6E-4134-AAF8-9101457D709A} |
|||
EndGlobalSection |
|||
EndGlobal |
|||
|
|||
Microsoft Visual Studio Solution File, Format Version 12.00 |
|||
# Visual Studio Version 17 |
|||
VisualStudioVersion = 17.0.31919.166 |
|||
MinimumVisualStudioVersion = 10.0.40219.1 |
|||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LINGYUN.MicroService.Internal.ApiGateway", "src\LINGYUN.MicroService.Internal.ApiGateway\LINGYUN.MicroService.Internal.ApiGateway.csproj", "{00A2F7A3-BEC3-48F4-A91C-5A336C32A5D2}" |
|||
EndProject |
|||
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{E8067AED-2B6E-4134-AAF8-9101457D709A}" |
|||
EndProject |
|||
Global |
|||
GlobalSection(SolutionConfigurationPlatforms) = preSolution |
|||
Debug|Any CPU = Debug|Any CPU |
|||
Release|Any CPU = Release|Any CPU |
|||
EndGlobalSection |
|||
GlobalSection(ProjectConfigurationPlatforms) = postSolution |
|||
{00A2F7A3-BEC3-48F4-A91C-5A336C32A5D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU |
|||
{00A2F7A3-BEC3-48F4-A91C-5A336C32A5D2}.Debug|Any CPU.Build.0 = Debug|Any CPU |
|||
{00A2F7A3-BEC3-48F4-A91C-5A336C32A5D2}.Release|Any CPU.ActiveCfg = Release|Any CPU |
|||
{00A2F7A3-BEC3-48F4-A91C-5A336C32A5D2}.Release|Any CPU.Build.0 = Release|Any CPU |
|||
EndGlobalSection |
|||
GlobalSection(SolutionProperties) = preSolution |
|||
HideSolutionNode = FALSE |
|||
EndGlobalSection |
|||
GlobalSection(NestedProjects) = preSolution |
|||
{00A2F7A3-BEC3-48F4-A91C-5A336C32A5D2} = {E8067AED-2B6E-4134-AAF8-9101457D709A} |
|||
EndGlobalSection |
|||
GlobalSection(ExtensibilityGlobals) = postSolution |
|||
SolutionGuid = {972464AB-1B23-4D87-89A2-13271E1873B9} |
|||
EndGlobalSection |
|||
EndGlobal |
|||
|
|||
Loading…
Reference in new issue