diff --git a/CAP.vssettings b/CAP.vssettings
new file mode 100644
index 0000000..aa71084
--- /dev/null
+++ b/CAP.vssettings
@@ -0,0 +1,230 @@
+falsetruetruefalsetruefalsetruetruetrue00truetruetruefalse56553510truetruetruetruefalsetrue10%vsspv_visualstudio_dir%\Projectstruefalsetrue44true%vsspv_visualstudio_dir%\Templates\ItemTemplatestruetrue201%vsspv_visualstudio_dir%\Templates\ProjectTemplatestrue4truetruefalsetruetruetruetruetrue5true60falseHACK:2TODO:2UNDONE:2UnresolvedMergeConflict:3falsefalsehttps://go.microsoft.com/fwlink/?LinkId=36599&clcid=%vsspv_lcid_hex%1%systemroot%\system32\notepad.exehttps://go.microsoft.com/fwlink/?LinkId=32722&clcid=%vsspv_lcid_hex%01014truetruetruetrue2truefalsetruefalsefalsetruetruefalsetruetruetrue58truefalse4truetruetruetrue<CodeStyleOption SerializationVersion="1" Type="Boolean" Value="false" DiagnosticSeverity="Hidden" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Hidden" />true0truetruefalsefalsetruetrue<CodeStyleOption SerializationVersion="1" Type="Boolean" Value="false" DiagnosticSeverity="Hidden" />false<CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Hidden" />truefalsetruetruetruetrue<CodeStyleOption SerializationVersion="1" Type="Boolean" Value="false" DiagnosticSeverity="Hidden" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="false" DiagnosticSeverity="Hidden" />true4truetruetruetrue2truetruetruefalsefalsetruetruetruetruetruetrue58truefalse4truetruetruetrue2truetrue10truefalse2truetruefalsefalse0true2falsetruefalse2truefalsefalsetruetruefalse1truetruefalse0falsetruefalsefalsefalsefalse{}[]().,:;+-*/%&|^!=<>?@#\truefalse0truefalsetruefalsefalsefalsetruefalsetruetrue0truetruefalsefalsefalsefalsetruefalse5120falsefalse2falsefalsefalsefalsefalsefalsetruefalsetruefalsefalsetruefalsetruefalsefalse1truefalse5falsetruetruetruefalsefalse0falsefalsetruetrue3falsefalsefalse60falsefalsetruefalsefalse2falsefalsetruetruefalsefalsefalsetrue55falsetruetruetruetruetruefalsefalsetruefalsefalsetruetruetruefalsefalsetruetruefalse1truefalsefalsefalsefalsefalsefalse0falsefalsetrue2falsefalse4truetruetruetrue2truetruetruefalsefalsetruetruefalsetruetruetrue58truefalse4truetruetruetrue1111<CodeStyleOption SerializationVersion="1" Type="Boolean" Value="false" DiagnosticSeverity="Hidden" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="false" DiagnosticSeverity="Hidden" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Hidden" />111100111011011110000<CodeStyleOption SerializationVersion="1" Type="Boolean" Value="false" DiagnosticSeverity="Hidden" />00010<CodeStyleOption SerializationVersion="1" Type="Boolean" Value="false" DiagnosticSeverity="Hidden" /><NamingPreferencesInfo SerializationVersion="4">
+ <SymbolSpecifications>
+ <SymbolSpecification ID="5c545a62-b14d-460a-88d8-e936c0a39316" Name="Class">
+ <ApplicableSymbolKindList>
+ <TypeKind>Class</TypeKind>
+ </ApplicableSymbolKindList>
+ <ApplicableAccessibilityList>
+ <AccessibilityKind>Public</AccessibilityKind>
+ <AccessibilityKind>Internal</AccessibilityKind>
+ <AccessibilityKind>Private</AccessibilityKind>
+ <AccessibilityKind>Protected</AccessibilityKind>
+ <AccessibilityKind>ProtectedOrInternal</AccessibilityKind>
+ </ApplicableAccessibilityList>
+ <RequiredModifierList />
+ </SymbolSpecification>
+ <SymbolSpecification ID="23d856b4-5089-4405-83ce-749aada99153" Name="Interface">
+ <ApplicableSymbolKindList>
+ <TypeKind>Interface</TypeKind>
+ </ApplicableSymbolKindList>
+ <ApplicableAccessibilityList>
+ <AccessibilityKind>Public</AccessibilityKind>
+ <AccessibilityKind>Internal</AccessibilityKind>
+ <AccessibilityKind>Private</AccessibilityKind>
+ <AccessibilityKind>Protected</AccessibilityKind>
+ <AccessibilityKind>ProtectedOrInternal</AccessibilityKind>
+ </ApplicableAccessibilityList>
+ <RequiredModifierList />
+ </SymbolSpecification>
+ <SymbolSpecification ID="d1796e78-ff66-463f-8576-eb46416060c0" Name="Struct">
+ <ApplicableSymbolKindList>
+ <TypeKind>Struct</TypeKind>
+ </ApplicableSymbolKindList>
+ <ApplicableAccessibilityList>
+ <AccessibilityKind>Public</AccessibilityKind>
+ <AccessibilityKind>Internal</AccessibilityKind>
+ <AccessibilityKind>Private</AccessibilityKind>
+ <AccessibilityKind>Protected</AccessibilityKind>
+ <AccessibilityKind>ProtectedOrInternal</AccessibilityKind>
+ </ApplicableAccessibilityList>
+ <RequiredModifierList />
+ </SymbolSpecification>
+ <SymbolSpecification ID="d8af8dc6-1ade-441d-9947-8946922e198a" Name="Enum">
+ <ApplicableSymbolKindList>
+ <TypeKind>Enum</TypeKind>
+ </ApplicableSymbolKindList>
+ <ApplicableAccessibilityList>
+ <AccessibilityKind>Public</AccessibilityKind>
+ <AccessibilityKind>Internal</AccessibilityKind>
+ <AccessibilityKind>Private</AccessibilityKind>
+ <AccessibilityKind>Protected</AccessibilityKind>
+ <AccessibilityKind>ProtectedOrInternal</AccessibilityKind>
+ </ApplicableAccessibilityList>
+ <RequiredModifierList />
+ </SymbolSpecification>
+ <SymbolSpecification ID="408a3347-b908-4b54-a954-1355e64c1de3" Name="Delegate">
+ <ApplicableSymbolKindList>
+ <TypeKind>Delegate</TypeKind>
+ </ApplicableSymbolKindList>
+ <ApplicableAccessibilityList>
+ <AccessibilityKind>Public</AccessibilityKind>
+ <AccessibilityKind>Internal</AccessibilityKind>
+ <AccessibilityKind>Private</AccessibilityKind>
+ <AccessibilityKind>Protected</AccessibilityKind>
+ <AccessibilityKind>ProtectedOrInternal</AccessibilityKind>
+ </ApplicableAccessibilityList>
+ <RequiredModifierList />
+ </SymbolSpecification>
+ <SymbolSpecification ID="830657f6-e7e5-4830-b328-f109d3b6c165" Name="Event">
+ <ApplicableSymbolKindList>
+ <SymbolKind>Event</SymbolKind>
+ </ApplicableSymbolKindList>
+ <ApplicableAccessibilityList>
+ <AccessibilityKind>Public</AccessibilityKind>
+ <AccessibilityKind>Internal</AccessibilityKind>
+ <AccessibilityKind>Private</AccessibilityKind>
+ <AccessibilityKind>Protected</AccessibilityKind>
+ <AccessibilityKind>ProtectedOrInternal</AccessibilityKind>
+ </ApplicableAccessibilityList>
+ <RequiredModifierList />
+ </SymbolSpecification>
+ <SymbolSpecification ID="390caed4-f0a9-42bb-adbb-b44c4a302a22" Name="Method">
+ <ApplicableSymbolKindList>
+ <SymbolKind>Method</SymbolKind>
+ </ApplicableSymbolKindList>
+ <ApplicableAccessibilityList>
+ <AccessibilityKind>Public</AccessibilityKind>
+ </ApplicableAccessibilityList>
+ <RequiredModifierList />
+ </SymbolSpecification>
+ <SymbolSpecification ID="af410767-f189-47c6-b140-aeccf1ff242e" Name="Private Method">
+ <ApplicableSymbolKindList>
+ <SymbolKind>Method</SymbolKind>
+ </ApplicableSymbolKindList>
+ <ApplicableAccessibilityList>
+ <AccessibilityKind>Private</AccessibilityKind>
+ </ApplicableAccessibilityList>
+ <RequiredModifierList />
+ </SymbolSpecification>
+ <SymbolSpecification ID="8076757e-6a4a-47f1-9b4b-ae8a3284e987" Name="Abstract Method">
+ <ApplicableSymbolKindList>
+ <SymbolKind>Method</SymbolKind>
+ </ApplicableSymbolKindList>
+ <ApplicableAccessibilityList>
+ <AccessibilityKind>Public</AccessibilityKind>
+ <AccessibilityKind>Internal</AccessibilityKind>
+ <AccessibilityKind>Private</AccessibilityKind>
+ <AccessibilityKind>Protected</AccessibilityKind>
+ <AccessibilityKind>ProtectedOrInternal</AccessibilityKind>
+ </ApplicableAccessibilityList>
+ <RequiredModifierList>
+ <ModifierKind>IsAbstract</ModifierKind>
+ </RequiredModifierList>
+ </SymbolSpecification>
+ <SymbolSpecification ID="16133061-a8e7-4392-92c3-1d93cd54c218" Name="Static Method">
+ <ApplicableSymbolKindList>
+ <SymbolKind>Method</SymbolKind>
+ </ApplicableSymbolKindList>
+ <ApplicableAccessibilityList>
+ <AccessibilityKind>Public</AccessibilityKind>
+ <AccessibilityKind>Internal</AccessibilityKind>
+ <AccessibilityKind>Private</AccessibilityKind>
+ <AccessibilityKind>Protected</AccessibilityKind>
+ <AccessibilityKind>ProtectedOrInternal</AccessibilityKind>
+ </ApplicableAccessibilityList>
+ <RequiredModifierList>
+ <ModifierKind>IsStatic</ModifierKind>
+ </RequiredModifierList>
+ </SymbolSpecification>
+ <SymbolSpecification ID="da6a2919-5aa6-4ad1-a24d-576776ed3974" Name="Property">
+ <ApplicableSymbolKindList>
+ <SymbolKind>Property</SymbolKind>
+ </ApplicableSymbolKindList>
+ <ApplicableAccessibilityList>
+ <AccessibilityKind>Public</AccessibilityKind>
+ <AccessibilityKind>Internal</AccessibilityKind>
+ <AccessibilityKind>Private</AccessibilityKind>
+ <AccessibilityKind>Protected</AccessibilityKind>
+ <AccessibilityKind>ProtectedOrInternal</AccessibilityKind>
+ </ApplicableAccessibilityList>
+ <RequiredModifierList />
+ </SymbolSpecification>
+ <SymbolSpecification ID="b24a91ce-3501-4799-b6df-baf044156c83" Name="Public or Protected Field">
+ <ApplicableSymbolKindList>
+ <SymbolKind>Field</SymbolKind>
+ </ApplicableSymbolKindList>
+ <ApplicableAccessibilityList>
+ <AccessibilityKind>Public</AccessibilityKind>
+ <AccessibilityKind>Protected</AccessibilityKind>
+ </ApplicableAccessibilityList>
+ <RequiredModifierList />
+ </SymbolSpecification>
+ <SymbolSpecification ID="70af42cb-1741-4027-969c-9edc4877d965" Name="Static Field">
+ <ApplicableSymbolKindList>
+ <SymbolKind>Field</SymbolKind>
+ </ApplicableSymbolKindList>
+ <ApplicableAccessibilityList>
+ <AccessibilityKind>Public</AccessibilityKind>
+ <AccessibilityKind>Internal</AccessibilityKind>
+ <AccessibilityKind>Private</AccessibilityKind>
+ <AccessibilityKind>Protected</AccessibilityKind>
+ <AccessibilityKind>ProtectedOrInternal</AccessibilityKind>
+ </ApplicableAccessibilityList>
+ <RequiredModifierList>
+ <ModifierKind>IsStatic</ModifierKind>
+ </RequiredModifierList>
+ </SymbolSpecification>
+ <SymbolSpecification ID="10790aa6-0a0b-432d-a52d-d252ca92302b" Name="Private or Internal Field">
+ <ApplicableSymbolKindList>
+ <SymbolKind>Field</SymbolKind>
+ </ApplicableSymbolKindList>
+ <ApplicableAccessibilityList>
+ <AccessibilityKind>Internal</AccessibilityKind>
+ <AccessibilityKind>Private</AccessibilityKind>
+ </ApplicableAccessibilityList>
+ <RequiredModifierList />
+ </SymbolSpecification>
+ <SymbolSpecification ID="ac995be4-88de-4771-9dcc-a456a7c02d89" Name="Private or Internal Static Field">
+ <ApplicableSymbolKindList>
+ <SymbolKind>Field</SymbolKind>
+ </ApplicableSymbolKindList>
+ <ApplicableAccessibilityList>
+ <AccessibilityKind>Internal</AccessibilityKind>
+ <AccessibilityKind>Private</AccessibilityKind>
+ </ApplicableAccessibilityList>
+ <RequiredModifierList>
+ <ModifierKind>IsStatic</ModifierKind>
+ </RequiredModifierList>
+ </SymbolSpecification>
+ <SymbolSpecification ID="2c07f5bf-bc81-4c2b-82b4-ae9b3ffd0ba4" Name="Types">
+ <ApplicableSymbolKindList>
+ <TypeKind>Class</TypeKind>
+ <TypeKind>Struct</TypeKind>
+ <TypeKind>Interface</TypeKind>
+ <TypeKind>Enum</TypeKind>
+ </ApplicableSymbolKindList>
+ <ApplicableAccessibilityList>
+ <AccessibilityKind>Public</AccessibilityKind>
+ <AccessibilityKind>Internal</AccessibilityKind>
+ <AccessibilityKind>Private</AccessibilityKind>
+ <AccessibilityKind>Protected</AccessibilityKind>
+ <AccessibilityKind>ProtectedOrInternal</AccessibilityKind>
+ </ApplicableAccessibilityList>
+ <RequiredModifierList />
+ </SymbolSpecification>
+ <SymbolSpecification ID="5f3ddba1-279f-486c-801e-5c097c36dd85" Name="Non-Field Members">
+ <ApplicableSymbolKindList>
+ <SymbolKind>Property</SymbolKind>
+ <SymbolKind>Method</SymbolKind>
+ <SymbolKind>Event</SymbolKind>
+ </ApplicableSymbolKindList>
+ <ApplicableAccessibilityList>
+ <AccessibilityKind>Public</AccessibilityKind>
+ <AccessibilityKind>Internal</AccessibilityKind>
+ <AccessibilityKind>Private</AccessibilityKind>
+ <AccessibilityKind>Protected</AccessibilityKind>
+ <AccessibilityKind>ProtectedOrInternal</AccessibilityKind>
+ </ApplicableAccessibilityList>
+ <RequiredModifierList />
+ </SymbolSpecification>
+ </SymbolSpecifications>
+ <NamingStyles>
+ <NamingStyle ID="87e7c501-9948-4b53-b1eb-a6cbe918feee" Name="Pascal Case" Prefix="" Suffix="" WordSeparator="" CapitalizationScheme="PascalCase" />
+ <NamingStyle ID="1ecc5eb6-b5fc-49a5-a9f1-a980f3e48c92" Name="Begins with I" Prefix="I" Suffix="" WordSeparator="" CapitalizationScheme="PascalCase" />
+ </NamingStyles>
+ <NamingRules>
+ <SerializableNamingRule SymbolSpecificationID="23d856b4-5089-4405-83ce-749aada99153" NamingStyleID="1ecc5eb6-b5fc-49a5-a9f1-a980f3e48c92" EnforcementLevel="Info" />
+ <SerializableNamingRule SymbolSpecificationID="2c07f5bf-bc81-4c2b-82b4-ae9b3ffd0ba4" NamingStyleID="87e7c501-9948-4b53-b1eb-a6cbe918feee" EnforcementLevel="Info" />
+ <SerializableNamingRule SymbolSpecificationID="5f3ddba1-279f-486c-801e-5c097c36dd85" NamingStyleID="87e7c501-9948-4b53-b1eb-a6cbe918feee" EnforcementLevel="Info" />
+ </NamingRules>
+</NamingPreferencesInfo>10011111-1-1<CodeStyleOption SerializationVersion="1" Type="Boolean" Value="true" DiagnosticSeverity="Hidden" />012110000011010011121<CodeStyleOption SerializationVersion="1" Type="Boolean" Value="false" DiagnosticSeverity="Hidden" />011<CodeStyleOption SerializationVersion="1" Type="Boolean" Value="false" DiagnosticSeverity="Hidden" /><CodeStyleOption SerializationVersion="1" Type="Boolean" Value="false" DiagnosticSeverity="Hidden" />01101100010114truetruetruetrue2truetruetruefalsefalsetruetruefalsetruetruetrue58truefalse4truetruetruetruetruetrue0truetruefalsetruefalsetruetrue4truetruetruetrue2truetruefalsefalsefalsetruetruefalsetruetruetrue58truefalse4truetruetruetrue16244681013027014130030571648769114413810003575607202202157245271502431557746900202000-1-17257087123839990128jpg080gif99915000-12083886085-1750-11317273516765887200-1-104294967295201001128954521521676031116750848210033012865075201800-114145511216768975072570870text/html;text/x-jquery-tmpl;text/template;text/x-handlebars;text/x-handlebars-template;text/x-jsrender1673925816777215090HTML5010500-120111190170100112167508481200-14truetruetruetrue2truetruetruefalsefalsetruetruefalsetruetruetrue58truefalse4truetruetruetrue4truetruetruetrue2truetruetruefalsefalsetruetruetruefalsetruetrue58falsefalse4falsetruetruetrue4truetruetruetrue2truetruetruefalsefalsetruetruefalsetruetruetrue58truefalse4truetruetruetrueImplicit (Windows)|$(VSInstallDir)\JavaScript\References\libhelp.js|$(VSInstallDir)\JavaScript\References\domWindows.js|$(VSInstallDir)\JavaScript\References\underscorefilter.js|$(VSInstallDir)\JavaScript\References\showPlainComments.js;Implicit (Windows 8.1)|$(VSInstallDir)\JavaScript\References\libhelp.js|$(VSInstallDir)\JavaScript\References\sitetypesWindows.js|$(VSInstallDir)\JavaScript\References\domWindows_8.1.js|$(VSInstallDir)\JavaScript\References\underscorefilter.js|$(VSInstallDir)\JavaScript\References\showPlainComments.js;Implicit (Windows Phone 8.1)|$(VSInstallDir)\JavaScript\References\libhelp.js|$(VSInstallDir)\JavaScript\References\sitetypesWindows.js|$(VSInstallDir)\JavaScript\References\domWindowsPhone_8.1.js|$(VSInstallDir)\JavaScript\References\underscorefilter.js|$(VSInstallDir)\JavaScript\References\showPlainComments.js;Implicit (Web)|$(VSInstallDir)\JavaScript\References\libhelp.js|$(VSInstallDir)\JavaScript\References\sitetypesWeb.js|$(VSInstallDir)\JavaScript\References\domWeb.js|$(VSInstallDir)\JavaScript\References\underscorefilter.js|$(VSInstallDir)\JavaScript\References\showPlainComments.js;Dedicated Worker|$(VSInstallDir)\JavaScript\References\libhelp.js|$(VSInstallDir)\JavaScript\References\dedicatedworker.js|$(VSInstallDir)\JavaScript\References\underscorefilter.js|$(VSInstallDir)\JavaScript\References\showPlainComments.js;Generic|$(VSInstallDir)\JavaScript\References\libhelp.js|$(VSInstallDir)\JavaScript\References\underscorefilter.js|$(VSInstallDir)\JavaScript\References\showPlainComments.js;falsetruetruefalsetruetruetruetruefalsetruetruetruetruefalsetruetrue2truetruetruetrue2truetruefalsefalsefalsetruetruefalsetruetruetrue58truefalse2truetruetruetrue4truetruetruetrue2truetruetruefalsefalsetruetruefalsetruetruetrue58truefalse4truetruetruetrue4truetruetruetrue1truetruefalsefalsefalsetruetruetruetruetruetrue58truefalse4truetruetruetrue4truetruetruetrue1truetruefalsefalsefalsetruetruetruetruetruetrue58truefalse4falsetruetruetrue4truetruetruetrue2truetruefalsefalsefalsetruetruefalsetruetruetrue58truefalse4truetruetruetrue4truetruetruetrue1truetruefalsefalsefalsetruetruetruetruetruetrue58truefalse4falsetruetruetrue4truetruetruetrue1truetruefalsefalsefalsetruetruetruetruetruetrue58truefalse4falsetruetruetrue4truetruetruetrue2truetruetruefalsefalsetruetruefalsefalsetruetrue58truefalse4truetruetruetruefalsefalsefalsetruetruetruefalsetruetruetruetruetruetrue2.3falsetruefalsefalsetruetruefalsetruefalsetruefalsetruefalsefalse{}[]().,:;+-*/%&|^!~=<>? falsefalsetrue4truetruetruetrue2truetruetruefalsefalsetruetruefalsetruefalsetrue58truefalse4falsetruetruetrue2truetruetruetrue2truetruefalsefalsefalsetruetruefalsetruetruetrue58truefalse2falsetruetruetrueTrueTruetrueTrue1101011110101101100010001010001001101011000000167577360473600210110111000050001500015001000100010002000200050001000010000250100050012510001100111111111100001110010011000000001012048509000100111000001010011010101113276881921101101https://referencesource.microsoft.com/symbolshttps://msdl.microsoft.com/download/symbolsFunction: $FUNCTION, Thread: $TID $TNAMEtruefalsetruetruetruetruefalsefalsefalsetruefalsefalsefalsefalsetruetruetruetruefalsefalsetruetruefalsetruefalsefalsetruefalse00True<ExtensionRepositoryConfigList Capacity="0" xmlns="clr-namespace:Microsoft.VisualStudio.ExtensionManager;assembly=Microsoft.VisualStudio.ExtensionManager.Implementation" />Truefalsetruefalse2{B1BA9461-FC54-45B3-A484-CB6DD0B95C94}02 15.0.0.0F7Shift+F7Ctrl+F4Ctrl+W, Ctrl+NCtrl+W, NF4F6falsefalsefalsefalsetruefalsefalsefalsetruefalsefalsefalsefalsetruetruetruetruefalsefalsetruetruefalsetruefalse{B1BA9461-FC54-45B3-A484-CB6DD0B95C94}0false01truefalsefalsetruefalsetruetrueTrueFalseTrueTrueTrueFalseFalseFalseTrueFalsefalse10{e7f851c8-6267-4794-b0fe-7bcab6dacbb4}-#1071Standard0true419100MatchCase=0 WholeWord=0 Hidden=1 Up=0 Selection=0 Block=0 KeepCase=0 SubFolders=0 KeepOpen=0 NameOnly=0 Append=0 Plain Document FindMatchCase=0 WholeWord=0 Hidden=1 Up=0 Selection=0 Block=0 KeepCase=0 SubFolders=1 KeepOpen=0 NameOnly=0 Append=0 Plain Files FindAllMatchCase=0 WholeWord=0 Hidden=1 Up=0 Selection=0 Block=0 KeepCase=0 SubFolders=0 KeepOpen=0 NameOnly=0 Append=0 Plain Document Find111111111111111Regex25607Design|Debug|NoToolWinOnTrueSemi-expandedTrueTrueOnFalsehttp://schemastore.org/api/json/catalog.json.\node_modules\.bin;$(VSINSTALLDIR)\Web\External;$(PATH);C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\binFalseFalseFalseFalsefalsefalseNoneFalseTrueTrueTrueTrueTrueTrueTrueTrue%VsInstallDir%\xml\SchemasTrue5105TrueFalseFalseTrueTrue4TrueFalseTrueTrueSplitViewDefaultPixelsFalseControlMouseWheelOpenInBrowserTrueTrueTrue8, 8SnapLinesTrueTrueTrueTrueTrueTrue\node_modules\,\bower_components\,\typings\,\lib\,.min.TrueFalsefalsetruefalsefalse-1506464101csv3.01002.03.01100TrueTrueTrue25FalseTrueTrueTrueDoubleQuote120False
\ No newline at end of file
diff --git a/Cap.sln b/Cap.sln
index ae04418..ce339ad 100644
--- a/Cap.sln
+++ b/Cap.sln
@@ -1,13 +1,16 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
-VisualStudioVersion = 15.0.26430.6
+VisualStudioVersion = 15.0.26430.13
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{9B2AE124-6636-4DE9-83A3-70360DABD0C4}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{C09CDAB0-6DD4-46E9-B7F3-3EF2A4741EA0}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{57A8A8E5-5715-41BF-A0A6-46B819933FBC}"
+ ProjectSection(SolutionItems) = preProject
+ CAP.vssettings = CAP.vssettings
+ EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{9E5A7F49-8E31-4A71-90CC-1DA9AEDA99EE}"
ProjectSection(SolutionItems) = preProject
@@ -18,21 +21,17 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{9E5A7F
{82A7F48D-3B50-4B1E-B82E-3ADA8210C358} = {82A7F48D-3B50-4B1E-B82E-3ADA8210C358}
EndProjectSection
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cap.Consistency", "src\Cap.Consistency\Cap.Consistency.csproj", "{E8AF8611-0EA4-4B19-BC48-87C57A87DC66}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cap.Consistency.Test", "test\Cap.Consistency.Test\Cap.Consistency.Test.csproj", "{3A444CF8-1611-407F-8D32-5D0CDC3DD49D}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DotNetCore.CAP", "src\DotNetCore.CAP\DotNetCore.CAP.csproj", "{E8AF8611-0EA4-4B19-BC48-87C57A87DC66}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cap.Consistency.EntityFrameworkCore", "src\Cap.Consistency.EntityFrameworkCore\Cap.Consistency.EntityFrameworkCore.csproj", "{96111249-C4C3-4DC9-A887-32D583723AB1}"
-EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Cap.Consistency.EntityFrameworkCore.Test", "test\Cap.Consistency.EntityFrameworkCore.Test\Cap.Consistency.EntityFrameworkCore.Test.csproj", "{7442C942-1DDC-40E4-8F1B-654E721EAA45}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DotNetCore.CAP.EntityFrameworkCore", "src\DotNetCore.CAP.EntityFrameworkCore\DotNetCore.CAP.EntityFrameworkCore.csproj", "{96111249-C4C3-4DC9-A887-32D583723AB1}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{3A6B6931-A123-477A-9469-8B468B5385AF}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample.Kafka", "samples\Sample.Kafka\Sample.Kafka.csproj", "{2F095ED9-5BC9-4512-9013-A47685FB2508}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cap.Consistency.Kafka", "src\Cap.Consistency.Kafka\Cap.Consistency.Kafka.csproj", "{C42CDE33-0878-4BA0-96F2-4CB7C8FDEAAD}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotNetCore.CAP.Kafka", "src\DotNetCore.CAP.Kafka\DotNetCore.CAP.Kafka.csproj", "{C42CDE33-0878-4BA0-96F2-4CB7C8FDEAAD}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cap.Consistency.RabbitMQ", "src\Cap.Consistency.RabbitMQ\Cap.Consistency.RabbitMQ.csproj", "{9961B80E-0718-4280-B2A0-271B003DE26B}"
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotNetCore.CAP.RabbitMQ", "src\DotNetCore.CAP.RabbitMQ\DotNetCore.CAP.RabbitMQ.csproj", "{9961B80E-0718-4280-B2A0-271B003DE26B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{10C0818D-9160-4B80-BB86-DDE925B64D43}"
ProjectSection(SolutionItems) = preProject
@@ -46,6 +45,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{10C0818D
build\version.props = build\version.props
EndProjectSection
EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DotNetCore.CAP.EntityFrameworkCore.Test", "test\DotNetCore.CAP.EntityFrameworkCore.Test\DotNetCore.CAP.EntityFrameworkCore.Test.csproj", "{69370370-9873-4D6A-965D-D1E16694047D}"
+EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DotNetCore.CAP.Test", "test\DotNetCore.CAP.Test\DotNetCore.CAP.Test.csproj", "{F608B509-A99B-4AC7-8227-42051DD4A578}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -56,18 +59,10 @@ Global
{E8AF8611-0EA4-4B19-BC48-87C57A87DC66}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E8AF8611-0EA4-4B19-BC48-87C57A87DC66}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E8AF8611-0EA4-4B19-BC48-87C57A87DC66}.Release|Any CPU.Build.0 = Release|Any CPU
- {3A444CF8-1611-407F-8D32-5D0CDC3DD49D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {3A444CF8-1611-407F-8D32-5D0CDC3DD49D}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {3A444CF8-1611-407F-8D32-5D0CDC3DD49D}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {3A444CF8-1611-407F-8D32-5D0CDC3DD49D}.Release|Any CPU.Build.0 = Release|Any CPU
{96111249-C4C3-4DC9-A887-32D583723AB1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{96111249-C4C3-4DC9-A887-32D583723AB1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{96111249-C4C3-4DC9-A887-32D583723AB1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{96111249-C4C3-4DC9-A887-32D583723AB1}.Release|Any CPU.Build.0 = Release|Any CPU
- {7442C942-1DDC-40E4-8F1B-654E721EAA45}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {7442C942-1DDC-40E4-8F1B-654E721EAA45}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {7442C942-1DDC-40E4-8F1B-654E721EAA45}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {7442C942-1DDC-40E4-8F1B-654E721EAA45}.Release|Any CPU.Build.0 = Release|Any CPU
{2F095ED9-5BC9-4512-9013-A47685FB2508}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2F095ED9-5BC9-4512-9013-A47685FB2508}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2F095ED9-5BC9-4512-9013-A47685FB2508}.Release|Any CPU.ActiveCfg = Release|Any CPU
@@ -80,6 +75,14 @@ Global
{9961B80E-0718-4280-B2A0-271B003DE26B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9961B80E-0718-4280-B2A0-271B003DE26B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9961B80E-0718-4280-B2A0-271B003DE26B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {69370370-9873-4D6A-965D-D1E16694047D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {69370370-9873-4D6A-965D-D1E16694047D}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {69370370-9873-4D6A-965D-D1E16694047D}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {69370370-9873-4D6A-965D-D1E16694047D}.Release|Any CPU.Build.0 = Release|Any CPU
+ {F608B509-A99B-4AC7-8227-42051DD4A578}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F608B509-A99B-4AC7-8227-42051DD4A578}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F608B509-A99B-4AC7-8227-42051DD4A578}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F608B509-A99B-4AC7-8227-42051DD4A578}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -87,11 +90,11 @@ Global
GlobalSection(NestedProjects) = preSolution
{9E5A7F49-8E31-4A71-90CC-1DA9AEDA99EE} = {C09CDAB0-6DD4-46E9-B7F3-3EF2A4741EA0}
{E8AF8611-0EA4-4B19-BC48-87C57A87DC66} = {9B2AE124-6636-4DE9-83A3-70360DABD0C4}
- {3A444CF8-1611-407F-8D32-5D0CDC3DD49D} = {C09CDAB0-6DD4-46E9-B7F3-3EF2A4741EA0}
{96111249-C4C3-4DC9-A887-32D583723AB1} = {9B2AE124-6636-4DE9-83A3-70360DABD0C4}
- {7442C942-1DDC-40E4-8F1B-654E721EAA45} = {C09CDAB0-6DD4-46E9-B7F3-3EF2A4741EA0}
{2F095ED9-5BC9-4512-9013-A47685FB2508} = {3A6B6931-A123-477A-9469-8B468B5385AF}
{C42CDE33-0878-4BA0-96F2-4CB7C8FDEAAD} = {9B2AE124-6636-4DE9-83A3-70360DABD0C4}
{9961B80E-0718-4280-B2A0-271B003DE26B} = {9B2AE124-6636-4DE9-83A3-70360DABD0C4}
+ {69370370-9873-4D6A-965D-D1E16694047D} = {C09CDAB0-6DD4-46E9-B7F3-3EF2A4741EA0}
+ {F608B509-A99B-4AC7-8227-42051DD4A578} = {C09CDAB0-6DD4-46E9-B7F3-3EF2A4741EA0}
EndGlobalSection
EndGlobal
diff --git a/samples/Sample.Kafka/AppDbContext.cs b/samples/Sample.Kafka/AppDbContext.cs
index fbc9da5..30ffe0a 100644
--- a/samples/Sample.Kafka/AppDbContext.cs
+++ b/samples/Sample.Kafka/AppDbContext.cs
@@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
-using Cap.Consistency.Infrastructure;
+using DotNetCore.CAP.Infrastructure;
using JetBrains.Annotations;
using Microsoft.EntityFrameworkCore;
diff --git a/samples/Sample.Kafka/Controllers/ValuesController.cs b/samples/Sample.Kafka/Controllers/ValuesController.cs
index 88ae91f..ac1a041 100644
--- a/samples/Sample.Kafka/Controllers/ValuesController.cs
+++ b/samples/Sample.Kafka/Controllers/ValuesController.cs
@@ -1,8 +1,7 @@
using System;
using System.Threading.Tasks;
-using Cap.Consistency;
-using Cap.Consistency.Consumer;
-using Cap.Consistency.Kafka;
+using DotNetCore.CAP;
+using DotNetCore.CAP.Kafka;
using Microsoft.AspNetCore.Mvc;
namespace Sample.Kafka.Controllers
@@ -10,9 +9,9 @@ namespace Sample.Kafka.Controllers
[Route("api/[controller]")]
public class ValuesController : Controller, IConsumerService
{
- private readonly IProducerClient _producer;
+ private readonly ICapProducerService _producer;
- public ValuesController(IProducerClient producer) {
+ public ValuesController(ICapProducerService producer) {
_producer = producer;
}
diff --git a/samples/Sample.Kafka/Migrations/20170622091105_CreateInit.Designer.cs b/samples/Sample.Kafka/Migrations/20170622091105_CreateInit.Designer.cs
index afa67cd..18e9aee 100644
--- a/samples/Sample.Kafka/Migrations/20170622091105_CreateInit.Designer.cs
+++ b/samples/Sample.Kafka/Migrations/20170622091105_CreateInit.Designer.cs
@@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Sample.Kafka;
-using Cap.Consistency.Infrastructure;
+using DotNetCore.CAP.Infrastructure;
namespace Sample.Kafka.Migrations
{
@@ -18,7 +18,7 @@ namespace Sample.Kafka.Migrations
.HasAnnotation("ProductVersion", "1.1.2")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
- modelBuilder.Entity("Cap.Consistency.Infrastructure.ConsistencyMessage", b =>
+ modelBuilder.Entity("DotNetCore.CAP.Infrastructure.ConsistencyMessage", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd();
diff --git a/samples/Sample.Kafka/Migrations/AppDbContextModelSnapshot.cs b/samples/Sample.Kafka/Migrations/AppDbContextModelSnapshot.cs
index 6150414..50ca1dd 100644
--- a/samples/Sample.Kafka/Migrations/AppDbContextModelSnapshot.cs
+++ b/samples/Sample.Kafka/Migrations/AppDbContextModelSnapshot.cs
@@ -4,7 +4,7 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Sample.Kafka;
-using Cap.Consistency.Infrastructure;
+using DotNetCore.CAP.Infrastructure;
namespace Sample.Kafka.Migrations
{
@@ -17,7 +17,7 @@ namespace Sample.Kafka.Migrations
.HasAnnotation("ProductVersion", "1.1.2")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
- modelBuilder.Entity("Cap.Consistency.Infrastructure.ConsistencyMessage", b =>
+ modelBuilder.Entity("DotNetCore.CAP.Infrastructure.ConsistencyMessage", b =>
{
b.Property("Id")
.ValueGeneratedOnAdd();
diff --git a/samples/Sample.Kafka/Sample.Kafka.csproj b/samples/Sample.Kafka/Sample.Kafka.csproj
index 783a746..e8c907e 100644
--- a/samples/Sample.Kafka/Sample.Kafka.csproj
+++ b/samples/Sample.Kafka/Sample.Kafka.csproj
@@ -23,10 +23,10 @@
-
-
-
-
+
+
+
+
diff --git a/src/Cap.Consistency.EntityFrameworkCore/ConsistencyEntityFrameworkBuilderExtensions.cs b/src/Cap.Consistency.EntityFrameworkCore/ConsistencyEntityFrameworkBuilderExtensions.cs
deleted file mode 100644
index 1d5eb99..0000000
--- a/src/Cap.Consistency.EntityFrameworkCore/ConsistencyEntityFrameworkBuilderExtensions.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using Cap.Consistency;
-using Cap.Consistency.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore;
-
-namespace Microsoft.Extensions.DependencyInjection
-{
- ///
- /// Contains extension methods to for adding entity framework stores.
- ///
- public static class ConsistencyEntityFrameworkBuilderExtensions
- {
- ///
- /// Adds an Entity Framework implementation of message stores.
- ///
- /// The Entity Framework database context to use.
- /// The instance this method extends.
- /// The instance this method extends.
- public static ConsistencyBuilder AddEntityFrameworkStores(this ConsistencyBuilder builder)
- where TContext : DbContext {
- builder.Services.AddScoped>();
-
- return builder;
- }
- }
-}
\ No newline at end of file
diff --git a/src/Cap.Consistency.Kafka/Cap.Consistency.Kafka.csproj b/src/Cap.Consistency.Kafka/Cap.Consistency.Kafka.csproj
deleted file mode 100644
index 3aa2b27..0000000
--- a/src/Cap.Consistency.Kafka/Cap.Consistency.Kafka.csproj
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
- netstandard1.6
- 1.6.1
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/Cap.Consistency.RabbitMQ/RabbitMQTopicAttribute.cs b/src/Cap.Consistency.RabbitMQ/RabbitMQTopicAttribute.cs
deleted file mode 100644
index 62f5e3b..0000000
--- a/src/Cap.Consistency.RabbitMQ/RabbitMQTopicAttribute.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using Cap.Consistency.Abstractions;
-
-namespace Cap.Consistency.RabbitMQ
-{
- public class RabbitMQTopicAttribute : TopicAttribute
- {
-
- public RabbitMQTopicAttribute(string routingKey) : base(routingKey) {
-
- }
- }
-}
diff --git a/src/Cap.Consistency/Abstractions/IConsumerInvoker.cs b/src/Cap.Consistency/Abstractions/IConsumerInvoker.cs
deleted file mode 100644
index 1c000c5..0000000
--- a/src/Cap.Consistency/Abstractions/IConsumerInvoker.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Cap.Consistency.Abstractions
-{
- public interface IConsumerInvoker
- {
- Task InvokeAsync();
- }
-}
diff --git a/src/Cap.Consistency/Abstractions/ModelBinding/IModelBinder.cs b/src/Cap.Consistency/Abstractions/ModelBinding/IModelBinder.cs
deleted file mode 100644
index fbfd207..0000000
--- a/src/Cap.Consistency/Abstractions/ModelBinding/IModelBinder.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Cap.Consistency.Abstractions.ModelBinding
-{
- public interface IModelBinder
- {
- Task BindModelAsync(ModelBindingContext bindingContext);
- }
-}
diff --git a/src/Cap.Consistency/Consumer/IConsumerService.cs b/src/Cap.Consistency/Consumer/IConsumerService.cs
deleted file mode 100644
index b61edf3..0000000
--- a/src/Cap.Consistency/Consumer/IConsumerService.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Cap.Consistency.Consumer
-{
- public interface IConsumerService
- {
- }
-}
diff --git a/src/Cap.Consistency/IProcessingServer.cs b/src/Cap.Consistency/IProcessingServer.cs
deleted file mode 100644
index 2a9e9f3..0000000
--- a/src/Cap.Consistency/IProcessingServer.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Cap.Consistency
-{
- public interface IProcessingServer : IDisposable
- {
- void Start();
- }
-}
diff --git a/src/Cap.Consistency/IProducerClient.cs b/src/Cap.Consistency/IProducerClient.cs
deleted file mode 100644
index 0aacc89..0000000
--- a/src/Cap.Consistency/IProducerClient.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Threading.Tasks;
-using Cap.Consistency.Infrastructure;
-
-namespace Cap.Consistency
-{
- public interface IProducerClient
- {
- Task SendAsync(string topic, string content);
- }
-}
diff --git a/src/Cap.Consistency/Infrastructure/IConsumerInvokerFactory.cs b/src/Cap.Consistency/Infrastructure/IConsumerInvokerFactory.cs
deleted file mode 100644
index bc1260d..0000000
--- a/src/Cap.Consistency/Infrastructure/IConsumerInvokerFactory.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using Cap.Consistency.Abstractions;
-
-namespace Cap.Consistency.Infrastructure
-{
- public interface IConsumerInvokerFactory
- {
- IConsumerInvoker CreateInvoker(ConsumerContext actionContext);
- }
-}
diff --git a/src/Cap.Consistency/Job/IProcessor.cs b/src/Cap.Consistency/Job/IProcessor.cs
deleted file mode 100644
index d312511..0000000
--- a/src/Cap.Consistency/Job/IProcessor.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Cap.Consistency.Job
-{
- public interface IJobProcessor
- {
- Task ProcessAsync(ProcessingContext context);
- }
-}
diff --git a/src/Cap.Consistency/Microsoft.Extensions.DependencyInjection/ConsistencyBuilder.cs b/src/Cap.Consistency/Microsoft.Extensions.DependencyInjection/ConsistencyBuilder.cs
deleted file mode 100644
index 999d8a0..0000000
--- a/src/Cap.Consistency/Microsoft.Extensions.DependencyInjection/ConsistencyBuilder.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-using System;
-using Cap.Consistency;
-using Cap.Consistency.Job;
-
-namespace Microsoft.Extensions.DependencyInjection
-{
- ///
- /// Used to verify Consistency service was called on a ServiceCollection
- ///
- public class ConsistencyMarkerService { }
-
- public class ConsistencyBuilder
- {
- public ConsistencyBuilder(IServiceCollection services) {
- Services = services;
- }
-
- public IServiceCollection Services { get; private set; }
-
- private ConsistencyBuilder AddScoped(Type serviceType, Type concreteType) {
- Services.AddScoped(serviceType, concreteType);
- return this;
- }
-
- private ConsistencyBuilder AddSingleton()
- where TService : class
- where TImplementation : class, TService {
- Services.AddSingleton();
- return this;
- }
-
- ///
- /// Adds an .
- ///
- /// The type for the to add.
- /// The current instance.
- public virtual ConsistencyBuilder AddMessageStore()
- where T : class, IConsistencyMessageStore {
-
- return AddScoped(typeof(IConsistencyMessageStore), typeof(T));
- }
-
- public virtual ConsistencyBuilder AddJobs()
- where T : class, IJob {
-
- return AddSingleton();
- }
-
- public virtual ConsistencyBuilder AddProducerClient()
- where T:class, IProducerClient {
-
- return AddScoped(typeof(IProducerClient), typeof(T));
- }
- }
-}
\ No newline at end of file
diff --git a/src/Cap.Consistency.EntityFrameworkCore/ConsistencyDbContext.cs b/src/DotNetCore.CAP.EntityFrameworkCore/ConsistencyDbContext.cs
similarity index 89%
rename from src/Cap.Consistency.EntityFrameworkCore/ConsistencyDbContext.cs
rename to src/DotNetCore.CAP.EntityFrameworkCore/ConsistencyDbContext.cs
index 9a372d8..778d30a 100644
--- a/src/Cap.Consistency.EntityFrameworkCore/ConsistencyDbContext.cs
+++ b/src/DotNetCore.CAP.EntityFrameworkCore/ConsistencyDbContext.cs
@@ -1,8 +1,7 @@
-using System;
-using Cap.Consistency.Infrastructure;
+using DotNetCore.CAP.Infrastructure;
using Microsoft.EntityFrameworkCore;
-namespace Cap.Consistency.EntityFrameworkCore
+namespace DotNetCore.CAP.EntityFrameworkCore
{
///
/// Base class for the Entity Framework database context used for consistency.
@@ -33,8 +32,10 @@ namespace Cap.Consistency.EntityFrameworkCore
///
/// The builder being used to construct the model for this context.
///
- protected override void OnModelCreating(ModelBuilder modelBuilder) {
- modelBuilder.Entity(b => {
+ protected override void OnModelCreating(ModelBuilder modelBuilder)
+ {
+ modelBuilder.Entity(b =>
+ {
b.HasKey(m => m.Id);
b.ToTable("ConsistencyMessages");
});
diff --git a/src/DotNetCore.CAP.EntityFrameworkCore/ConsistencyEntityFrameworkBuilderExtensions.cs b/src/DotNetCore.CAP.EntityFrameworkCore/ConsistencyEntityFrameworkBuilderExtensions.cs
new file mode 100644
index 0000000..d0320c1
--- /dev/null
+++ b/src/DotNetCore.CAP.EntityFrameworkCore/ConsistencyEntityFrameworkBuilderExtensions.cs
@@ -0,0 +1,26 @@
+using DotNetCore.CAP;
+using DotNetCore.CAP.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore;
+
+namespace Microsoft.Extensions.DependencyInjection
+{
+ ///
+ /// Contains extension methods to for adding entity framework stores.
+ ///
+ public static class ConsistencyEntityFrameworkBuilderExtensions
+ {
+ ///
+ /// Adds an Entity Framework implementation of message stores.
+ ///
+ /// The Entity Framework database context to use.
+ /// The instance this method extends.
+ /// The instance this method extends.
+ public static CapBuilder AddEntityFrameworkStores(this CapBuilder builder)
+ where TContext : DbContext
+ {
+ builder.Services.AddScoped>();
+
+ return builder;
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Cap.Consistency.EntityFrameworkCore/ConsistencyMessageStore.cs b/src/DotNetCore.CAP.EntityFrameworkCore/ConsistencyMessageStore.cs
similarity index 86%
rename from src/Cap.Consistency.EntityFrameworkCore/ConsistencyMessageStore.cs
rename to src/DotNetCore.CAP.EntityFrameworkCore/ConsistencyMessageStore.cs
index 6f75520..3df7510 100644
--- a/src/Cap.Consistency.EntityFrameworkCore/ConsistencyMessageStore.cs
+++ b/src/DotNetCore.CAP.EntityFrameworkCore/ConsistencyMessageStore.cs
@@ -2,10 +2,10 @@
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using Cap.Consistency.Infrastructure;
+using DotNetCore.CAP.Infrastructure;
using Microsoft.EntityFrameworkCore;
-namespace Cap.Consistency.EntityFrameworkCore
+namespace DotNetCore.CAP.EntityFrameworkCore
{
///
/// Represents a new instance of a persistence store for the specified message types.
@@ -13,7 +13,7 @@ namespace Cap.Consistency.EntityFrameworkCore
/// The type representing a message.
/// The type of the data context class used to access the store.
/// The type of the primary key for a message.
- public class ConsistencyMessageStore : IConsistencyMessageStore where TContext : DbContext
+ public class ConsistencyMessageStore : ICapMessageStore where TContext : DbContext
{
private bool _disposed;
@@ -21,8 +21,10 @@ namespace Cap.Consistency.EntityFrameworkCore
/// Constructs a new instance of .
///
/// The .
- public ConsistencyMessageStore(TContext context) {
- if (context == null) {
+ public ConsistencyMessageStore(TContext context)
+ {
+ if (context == null)
+ {
throw new ArgumentNullException(nameof(context));
}
Context = context;
@@ -38,10 +40,12 @@ namespace Cap.Consistency.EntityFrameworkCore
/// The message to create.
/// The used to propagate notifications that the operation should be canceled.
/// The that represents the asynchronous operation, containing the of the creation operation.
- public async virtual Task CreateAsync(ConsistencyMessage message, CancellationToken cancellationToken) {
+ public async virtual Task CreateAsync(ConsistencyMessage message, CancellationToken cancellationToken)
+ {
cancellationToken.ThrowIfCancellationRequested();
ThrowIfDisposed();
- if (message == null) {
+ if (message == null)
+ {
throw new ArgumentNullException(nameof(message));
}
Context.Add(message);
@@ -55,18 +59,22 @@ namespace Cap.Consistency.EntityFrameworkCore
/// The message to delete.
/// The used to propagate notifications that the operation should be canceled.
/// The that represents the asynchronous operation, containing the of the update operation.
- public async virtual Task DeleteAsync(ConsistencyMessage message, CancellationToken cancellationToken) {
+ public async virtual Task DeleteAsync(ConsistencyMessage message, CancellationToken cancellationToken)
+ {
cancellationToken.ThrowIfCancellationRequested();
ThrowIfDisposed();
- if (message == null) {
+ if (message == null)
+ {
throw new ArgumentNullException(nameof(message));
}
Context.Remove(message);
- try {
+ try
+ {
await SaveChanges(cancellationToken);
}
- catch (DbUpdateConcurrencyException ex) {
+ catch (DbUpdateConcurrencyException ex)
+ {
return OperateResult.Failed(new OperateError() { Code = "DbUpdateConcurrencyException", Description = ex.Message });
}
return OperateResult.Success;
@@ -80,7 +88,8 @@ namespace Cap.Consistency.EntityFrameworkCore
///
/// The that represents the asynchronous operation, containing the message matching the specified if it exists.
///
- public virtual Task FindByIdAsync(string messageId, CancellationToken cancellationToken) {
+ public virtual Task FindByIdAsync(string messageId, CancellationToken cancellationToken)
+ {
cancellationToken.ThrowIfCancellationRequested();
ThrowIfDisposed();
return MessageSet.FindAsync(new object[] { messageId }, cancellationToken);
@@ -92,10 +101,12 @@ namespace Cap.Consistency.EntityFrameworkCore
/// The message whose identifier should be retrieved.
/// The used to propagate notifications that the operation should be canceled.
/// The that represents the asynchronous operation, containing the identifier for the specified .
- public Task GeConsistencyMessageIdAsync(ConsistencyMessage message, CancellationToken cancellationToken) {
+ public Task GeConsistencyMessageIdAsync(ConsistencyMessage message, CancellationToken cancellationToken)
+ {
cancellationToken.ThrowIfCancellationRequested();
ThrowIfDisposed();
- if (message == null) {
+ if (message == null)
+ {
throw new ArgumentNullException(nameof(message));
}
return Task.FromResult(message.Id);
@@ -107,26 +118,31 @@ namespace Cap.Consistency.EntityFrameworkCore
/// The message to update.
/// The used to propagate notifications that the operation should be canceled.
/// The that represents the asynchronous operation, containing the of the update operation.
- public async virtual Task UpdateAsync(ConsistencyMessage message, CancellationToken cancellationToken) {
+ public async virtual Task UpdateAsync(ConsistencyMessage message, CancellationToken cancellationToken)
+ {
cancellationToken.ThrowIfCancellationRequested();
ThrowIfDisposed();
- if (message == null) {
+ if (message == null)
+ {
throw new ArgumentNullException(nameof(message));
}
Context.Attach(message);
message.UpdateTime = DateTime.Now;
Context.Update(message);
- try {
+ try
+ {
await SaveChanges(cancellationToken);
}
- catch (DbUpdateConcurrencyException ex) {
+ catch (DbUpdateConcurrencyException ex)
+ {
return OperateResult.Failed(new OperateError() { Code = "DbUpdateConcurrencyException", Description = ex.Message });
}
return OperateResult.Success;
}
- public Task GetFirstEnqueuedMessageAsync(CancellationToken cancellationToken) {
+ public Task GetFirstEnqueuedMessageAsync(CancellationToken cancellationToken)
+ {
cancellationToken.ThrowIfCancellationRequested();
return MessageSet.AsNoTracking().Where(x => x.Status == MessageStatus.WaitForSend).FirstOrDefaultAsync(cancellationToken);
}
@@ -155,15 +171,18 @@ namespace Cap.Consistency.EntityFrameworkCore
/// Saves the current store.
/// The used to propagate notifications that the operation should be canceled.
/// The that represents the asynchronous operation.
- protected Task SaveChanges(CancellationToken cancellationToken) {
+ protected Task SaveChanges(CancellationToken cancellationToken)
+ {
return AutoSaveChanges ? Context.SaveChangesAsync(cancellationToken) : Task.CompletedTask;
}
///
/// Throws if this class has been disposed.
///
- protected void ThrowIfDisposed() {
- if (_disposed) {
+ protected void ThrowIfDisposed()
+ {
+ if (_disposed)
+ {
throw new ObjectDisposedException(GetType().Name);
}
}
@@ -171,7 +190,8 @@ namespace Cap.Consistency.EntityFrameworkCore
///
/// Dispose the store
///
- public void Dispose() {
+ public void Dispose()
+ {
_disposed = true;
}
}
diff --git a/src/Cap.Consistency.EntityFrameworkCore/Cap.Consistency.EntityFrameworkCore.csproj b/src/DotNetCore.CAP.EntityFrameworkCore/DotNetCore.CAP.EntityFrameworkCore.csproj
similarity index 80%
rename from src/Cap.Consistency.EntityFrameworkCore/Cap.Consistency.EntityFrameworkCore.csproj
rename to src/DotNetCore.CAP.EntityFrameworkCore/DotNetCore.CAP.EntityFrameworkCore.csproj
index 72bfcb6..5160ace 100644
--- a/src/Cap.Consistency.EntityFrameworkCore/Cap.Consistency.EntityFrameworkCore.csproj
+++ b/src/DotNetCore.CAP.EntityFrameworkCore/DotNetCore.CAP.EntityFrameworkCore.csproj
@@ -2,8 +2,8 @@
netstandard1.6
- Cap.Consistency.EntityFrameworkCore
- Cap.Consistency.EntityFrameworkCore
+ DotNetCore.CAP.EntityFrameworkCore
+ DotNetCore.CAP.EntityFrameworkCore
1.6.1
$(PackageTargetFallback);dnxcore50
false
@@ -11,14 +11,14 @@
false
-
-
-
-
+
+
+
+
diff --git a/src/DotNetCore.CAP.Kafka/DotNetCore.CAP.Kafka.csproj b/src/DotNetCore.CAP.Kafka/DotNetCore.CAP.Kafka.csproj
new file mode 100644
index 0000000..66db043
--- /dev/null
+++ b/src/DotNetCore.CAP.Kafka/DotNetCore.CAP.Kafka.csproj
@@ -0,0 +1,22 @@
+
+
+
+ netstandard1.6
+ 1.6.1
+ DotNetCore.CAP.Kafka
+ DotNetCore.CAP.Kafka
+ $(PackageTargetFallback);dnxcore50
+ false
+ false
+ false
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Cap.Consistency.Kafka/IProcessor.Producer.cs b/src/DotNetCore.CAP.Kafka/IProcessor.Producer.cs
similarity index 77%
rename from src/Cap.Consistency.Kafka/IProcessor.Producer.cs
rename to src/DotNetCore.CAP.Kafka/IProcessor.Producer.cs
index 72bfc7e..316a10c 100644
--- a/src/Cap.Consistency.Kafka/IProcessor.Producer.cs
+++ b/src/DotNetCore.CAP.Kafka/IProcessor.Producer.cs
@@ -4,19 +4,18 @@ using System.Diagnostics;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
-using Cap.Consistency.Infrastructure;
-using Cap.Consistency.Job;
using Confluent.Kafka;
using Confluent.Kafka.Serialization;
+using DotNetCore.CAP.Infrastructure;
+using DotNetCore.CAP.Job;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
-namespace Cap.Consistency.Kafka
+namespace DotNetCore.CAP.Kafka
{
public class KafkaJobProcessor : IJobProcessor
{
-
private readonly ConsistencyOptions _options;
private readonly CancellationTokenSource _cts;
@@ -29,8 +28,8 @@ namespace Cap.Consistency.Kafka
public KafkaJobProcessor(
IOptions options,
ILogger logger,
- IServiceProvider provider) {
-
+ IServiceProvider provider)
+ {
_logger = logger;
_options = options.Value;
_provider = provider;
@@ -40,45 +39,53 @@ namespace Cap.Consistency.Kafka
public bool Waiting { get; private set; }
- public Task ProcessAsync(ProcessingContext context) {
-
+ public Task ProcessAsync(ProcessingContext context)
+ {
if (context == null) throw new ArgumentNullException(nameof(context));
context.ThrowIfStopping();
return ProcessCoreAsync(context);
}
- public async Task ProcessCoreAsync(ProcessingContext context) {
- try {
+ public async Task ProcessCoreAsync(ProcessingContext context)
+ {
+ try
+ {
var worked = await Step(context);
context.ThrowIfStopping();
-
+
Waiting = true;
- if (!worked) {
+ if (!worked)
+ {
var token = GetTokenToWaitOn(context);
- }
+ }
await WaitHandleEx.WaitAnyAsync(WaitHandleEx.PulseEvent, context.CancellationToken.WaitHandle, _pollingDelay);
}
- finally {
+ finally
+ {
Waiting = false;
}
}
- protected virtual CancellationToken GetTokenToWaitOn(ProcessingContext context) {
+ protected virtual CancellationToken GetTokenToWaitOn(ProcessingContext context)
+ {
return context.CancellationToken;
}
- private async Task Step(ProcessingContext context) {
- using (var scopedContext = context.CreateScope()) {
+ private async Task Step(ProcessingContext context)
+ {
+ using (var scopedContext = context.CreateScope())
+ {
var provider = scopedContext.Provider;
- var messageStore = provider.GetRequiredService();
- try {
+ var messageStore = provider.GetRequiredService();
+ try
+ {
var message = await messageStore.GetFirstEnqueuedMessageAsync(_cts.Token);
- if (message != null) {
-
+ if (message != null)
+ {
var sp = Stopwatch.StartNew();
message.Status = MessageStatus.Processing;
await messageStore.UpdateAsync(message, _cts.Token);
@@ -87,10 +94,12 @@ namespace Cap.Consistency.Kafka
sp.Stop();
- if (!jobResult) {
+ if (!jobResult)
+ {
_logger.JobFailed(new Exception("topic send failed"));
}
- else {
+ else
+ {
message.Status = MessageStatus.Successed;
await messageStore.UpdateAsync(message, _cts.Token);
//await messageStore.DeleteAsync(message, _cts.Token);
@@ -98,31 +107,37 @@ namespace Cap.Consistency.Kafka
}
}
}
- catch (Exception ex) {
+ catch (Exception )
+ {
return false;
}
}
return true;
}
- private bool ExecuteJob(string topic, string content) {
- try {
+ private bool ExecuteJob(string topic, string content)
+ {
+ try
+ {
var config = new Dictionary { { "bootstrap.servers", _options.BrokerUrlList } };
- using (var producer = new Producer(config, null, new StringSerializer(Encoding.UTF8))) {
+ using (var producer = new Producer(config, null, new StringSerializer(Encoding.UTF8)))
+ {
var message = producer.ProduceAsync(topic, null, content).Result;
- if (message.Error.Code == ErrorCode.NoError) {
+ if (message.Error.Code == ErrorCode.NoError)
+ {
return true;
}
- else {
+ else
+ {
return false;
}
}
}
- catch (Exception ex) {
+ catch (Exception ex)
+ {
_logger.ExceptionOccuredWhileExecutingJob(topic, ex);
return false;
}
}
-
}
-}
+}
\ No newline at end of file
diff --git a/src/Cap.Consistency.Kafka/KafkaConsumerClient.cs b/src/DotNetCore.CAP.Kafka/KafkaConsumerClient.cs
similarity index 76%
rename from src/Cap.Consistency.Kafka/KafkaConsumerClient.cs
rename to src/DotNetCore.CAP.Kafka/KafkaConsumerClient.cs
index 31f9bc8..82e60fa 100644
--- a/src/Cap.Consistency.Kafka/KafkaConsumerClient.cs
+++ b/src/DotNetCore.CAP.Kafka/KafkaConsumerClient.cs
@@ -1,12 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
-using Cap.Consistency.Consumer;
-using Cap.Consistency.Infrastructure;
using Confluent.Kafka;
using Confluent.Kafka.Serialization;
+using DotNetCore.CAP.Infrastructure;
-namespace Cap.Consistency.Kafka
+namespace DotNetCore.CAP.Kafka
{
public class KafkaConsumerClient : IConsumerClient
{
@@ -19,38 +18,46 @@ namespace Cap.Consistency.Kafka
public IDeserializer StringDeserializer { get; set; }
- public KafkaConsumerClient(string groupId, string bootstrapServers) {
+ public KafkaConsumerClient(string groupId, string bootstrapServers)
+ {
_groupId = groupId;
_bootstrapServers = bootstrapServers;
StringDeserializer = new StringDeserializer(Encoding.UTF8);
}
- public void Subscribe(string topic) {
+ public void Subscribe(string topic)
+ {
Subscribe(topic, 0);
}
- public void Subscribe(string topicName, int partition) {
- if (_consumerClient == null) {
+ public void Subscribe(string topicName, int partition)
+ {
+ if (_consumerClient == null)
+ {
InitKafkaClient();
}
_consumerClient.Assignment.Add(new TopicPartition(topicName, partition));
_consumerClient.Subscribe(topicName);
}
- public void Listening(TimeSpan timeout) {
- while (true) {
+ public void Listening(TimeSpan timeout)
+ {
+ while (true)
+ {
_consumerClient.Poll(timeout);
}
}
- public void Dispose() {
+ public void Dispose()
+ {
_consumerClient.Dispose();
}
#region private methods
- private void InitKafkaClient() {
+ private void InitKafkaClient()
+ {
var config = new Dictionary{
{ "group.id", _groupId },
{ "bootstrap.servers", _bootstrapServers }
@@ -60,8 +67,10 @@ namespace Cap.Consistency.Kafka
_consumerClient.OnMessage += ConsumerClient_OnMessage;
}
- private void ConsumerClient_OnMessage(object sender, Message e) {
- var message = new DeliverMessage {
+ private void ConsumerClient_OnMessage(object sender, Message e)
+ {
+ var message = new DeliverMessage
+ {
MessageKey = e.Topic,
Value = e.Value,
Body = Encoding.UTF8.GetBytes(e.Value)
diff --git a/src/Cap.Consistency.Kafka/KafkaConsumerClientFactory.cs b/src/DotNetCore.CAP.Kafka/KafkaConsumerClientFactory.cs
similarity index 72%
rename from src/Cap.Consistency.Kafka/KafkaConsumerClientFactory.cs
rename to src/DotNetCore.CAP.Kafka/KafkaConsumerClientFactory.cs
index 71b17fe..9257a4c 100644
--- a/src/Cap.Consistency.Kafka/KafkaConsumerClientFactory.cs
+++ b/src/DotNetCore.CAP.Kafka/KafkaConsumerClientFactory.cs
@@ -1,10 +1,9 @@
-using Cap.Consistency.Consumer;
-
-namespace Cap.Consistency.Kafka
+namespace DotNetCore.CAP.Kafka
{
public class KafkaConsumerClientFactory : IConsumerClientFactory
{
- public IConsumerClient Create(string groupId, string clientHostAddress) {
+ public IConsumerClient Create(string groupId, string clientHostAddress)
+ {
return new KafkaConsumerClient(groupId, clientHostAddress);
}
}
diff --git a/src/Cap.Consistency.Kafka/KafkaTopicAttribute.cs b/src/DotNetCore.CAP.Kafka/KafkaTopicAttribute.cs
similarity index 91%
rename from src/Cap.Consistency.Kafka/KafkaTopicAttribute.cs
rename to src/DotNetCore.CAP.Kafka/KafkaTopicAttribute.cs
index fd21d5e..ad628b6 100644
--- a/src/Cap.Consistency.Kafka/KafkaTopicAttribute.cs
+++ b/src/DotNetCore.CAP.Kafka/KafkaTopicAttribute.cs
@@ -1,6 +1,6 @@
-using Cap.Consistency.Abstractions;
+using DotNetCore.CAP.Abstractions;
-namespace Cap.Consistency.Kafka
+namespace DotNetCore.CAP.Kafka
{
public class KafkaTopicAttribute : TopicAttribute
{
diff --git a/src/Cap.Consistency.Kafka/LoggerExtensions.cs b/src/DotNetCore.CAP.Kafka/LoggerExtensions.cs
similarity index 90%
rename from src/Cap.Consistency.Kafka/LoggerExtensions.cs
rename to src/DotNetCore.CAP.Kafka/LoggerExtensions.cs
index 62aeb49..ac85f0f 100644
--- a/src/Cap.Consistency.Kafka/LoggerExtensions.cs
+++ b/src/DotNetCore.CAP.Kafka/LoggerExtensions.cs
@@ -1,9 +1,7 @@
using System;
-using System.Collections.Generic;
-using System.Text;
using Microsoft.Extensions.Logging;
-namespace Cap.Consistency.Kafka
+namespace DotNetCore.CAP.Kafka
{
internal static class LoggerExtensions
{
@@ -20,7 +18,8 @@ namespace Cap.Consistency.Kafka
private static Action _jobCouldNotBeLoaded;
private static Action _exceptionOccuredWhileExecutingJob;
- static LoggerExtensions() {
+ static LoggerExtensions()
+ {
_collectingExpiredEntities = LoggerMessage.Define(
LogLevel.Debug,
1,
@@ -73,45 +72,54 @@ namespace Cap.Consistency.Kafka
"Requeuing for another retry.");
}
- public static void CollectingExpiredEntities(this ILogger logger) {
+ public static void CollectingExpiredEntities(this ILogger logger)
+ {
_collectingExpiredEntities(logger, null);
}
- public static void Installing(this ILogger logger) {
+ public static void Installing(this ILogger logger)
+ {
_installing(logger, null);
}
- public static void InstallingError(this ILogger logger, Exception ex) {
+ public static void InstallingError(this ILogger logger, Exception ex)
+ {
_installingError(logger, ex);
}
- public static void InstallingSuccess(this ILogger logger) {
+ public static void InstallingSuccess(this ILogger logger)
+ {
_installingSuccess(logger, null);
}
-
- public static void JobFailed(this ILogger logger, Exception ex) {
+ public static void JobFailed(this ILogger logger, Exception ex)
+ {
_jobFailed(logger, ex);
}
- public static void JobFailedWillRetry(this ILogger logger, Exception ex) {
+ public static void JobFailedWillRetry(this ILogger logger, Exception ex)
+ {
_jobFailedWillRetry(logger, ex);
}
- public static void JobRetrying(this ILogger logger, int retries) {
+ public static void JobRetrying(this ILogger logger, int retries)
+ {
_jobRetrying(logger, retries, null);
}
- public static void JobExecuted(this ILogger logger, double seconds) {
+ public static void JobExecuted(this ILogger logger, double seconds)
+ {
_jobExecuted(logger, seconds, null);
}
- public static void JobCouldNotBeLoaded(this ILogger logger, int jobId, Exception ex) {
+ public static void JobCouldNotBeLoaded(this ILogger logger, int jobId, Exception ex)
+ {
_jobCouldNotBeLoaded(logger, jobId, ex);
}
- public static void ExceptionOccuredWhileExecutingJob(this ILogger logger, string jobId, Exception ex) {
+ public static void ExceptionOccuredWhileExecutingJob(this ILogger logger, string jobId, Exception ex)
+ {
_exceptionOccuredWhileExecutingJob(logger, jobId, ex);
}
}
-}
+}
\ No newline at end of file
diff --git a/src/Cap.Consistency.Kafka/Microsoft.Extensions.DependencyInjection/ConsistencyBuilderExtensions.cs b/src/DotNetCore.CAP.Kafka/Microsoft.Extensions.DependencyInjection/ConsistencyBuilderExtensions.cs
similarity index 65%
rename from src/Cap.Consistency.Kafka/Microsoft.Extensions.DependencyInjection/ConsistencyBuilderExtensions.cs
rename to src/DotNetCore.CAP.Kafka/Microsoft.Extensions.DependencyInjection/ConsistencyBuilderExtensions.cs
index c46a0d4..c9505cd 100644
--- a/src/Cap.Consistency.Kafka/Microsoft.Extensions.DependencyInjection/ConsistencyBuilderExtensions.cs
+++ b/src/DotNetCore.CAP.Kafka/Microsoft.Extensions.DependencyInjection/ConsistencyBuilderExtensions.cs
@@ -1,13 +1,13 @@
-using Cap.Consistency.Consumer;
-using Cap.Consistency.Job;
-using Cap.Consistency.Kafka;
+using DotNetCore.CAP;
+using DotNetCore.CAP.Job;
+using DotNetCore.CAP.Kafka;
namespace Microsoft.Extensions.DependencyInjection
{
public static class ConsistencyBuilderExtensions
{
- public static ConsistencyBuilder AddKafka(this ConsistencyBuilder builder) {
-
+ public static CapBuilder AddKafka(this CapBuilder builder)
+ {
builder.Services.AddSingleton();
builder.Services.AddTransient();
diff --git a/src/Cap.Consistency.RabbitMQ/Cap.Consistency.RabbitMQ.csproj b/src/DotNetCore.CAP.RabbitMQ/DotNetCore.CAP.RabbitMQ.csproj
similarity index 83%
rename from src/Cap.Consistency.RabbitMQ/Cap.Consistency.RabbitMQ.csproj
rename to src/DotNetCore.CAP.RabbitMQ/DotNetCore.CAP.RabbitMQ.csproj
index 834407f..e13f354 100644
--- a/src/Cap.Consistency.RabbitMQ/Cap.Consistency.RabbitMQ.csproj
+++ b/src/DotNetCore.CAP.RabbitMQ/DotNetCore.CAP.RabbitMQ.csproj
@@ -10,7 +10,7 @@
-
+
diff --git a/src/Cap.Consistency.RabbitMQ/RabbitMQConsumerClient.cs b/src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClient.cs
similarity index 80%
rename from src/Cap.Consistency.RabbitMQ/RabbitMQConsumerClient.cs
rename to src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClient.cs
index 921fafa..6757b1e 100644
--- a/src/Cap.Consistency.RabbitMQ/RabbitMQConsumerClient.cs
+++ b/src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClient.cs
@@ -1,11 +1,10 @@
using System;
using System.Text;
-using Cap.Consistency.Consumer;
-using Cap.Consistency.Infrastructure;
+using DotNetCore.CAP.Infrastructure;
using RabbitMQ.Client;
using RabbitMQ.Client.Events;
-namespace Cap.Consistency.RabbitMQ
+namespace DotNetCore.CAP.RabbitMQ
{
public class RabbitMQConsumerClient : IConsumerClient
{
@@ -22,14 +21,16 @@ namespace Cap.Consistency.RabbitMQ
public event EventHandler MessageReceieved;
- public RabbitMQConsumerClient(string exchange, string hostName) {
+ public RabbitMQConsumerClient(string exchange, string hostName)
+ {
_exchange = exchange;
_hostName = hostName;
InitClient();
}
- private void InitClient() {
+ private void InitClient()
+ {
_connectionFactory = new ConnectionFactory { HostName = _hostName };
_connection = _connectionFactory.CreateConnection();
_channel = _connection.CreateModel();
@@ -37,7 +38,8 @@ namespace Cap.Consistency.RabbitMQ
_queueName = _channel.QueueDeclare().QueueName;
}
- public void Listening(TimeSpan timeout) {
+ public void Listening(TimeSpan timeout)
+ {
// Task.Delay(timeout).Wait();
var consumer = new EventingBasicConsumer(_channel);
@@ -45,21 +47,26 @@ namespace Cap.Consistency.RabbitMQ
_channel.BasicConsume(_queueName, true, consumer);
}
- public void Subscribe(string topic) {
+ public void Subscribe(string topic)
+ {
_channel.QueueBind(_queueName, _exchange, topic);
}
- public void Subscribe(string topic, int partition) {
+ public void Subscribe(string topic, int partition)
+ {
_channel.QueueBind(_queueName, _exchange, topic);
}
- public void Dispose() {
+ public void Dispose()
+ {
_channel.Dispose();
_connection.Dispose();
}
- private void OnConsumerReceived(object sender, BasicDeliverEventArgs e) {
- var message = new DeliverMessage {
+ private void OnConsumerReceived(object sender, BasicDeliverEventArgs e)
+ {
+ var message = new DeliverMessage
+ {
MessageKey = e.RoutingKey,
Body = e.Body,
Value = Encoding.UTF8.GetString(e.Body)
diff --git a/src/Cap.Consistency.RabbitMQ/RabbitMQConsumerClientFactory.cs b/src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClientFactory.cs
similarity index 72%
rename from src/Cap.Consistency.RabbitMQ/RabbitMQConsumerClientFactory.cs
rename to src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClientFactory.cs
index d02c0ab..29fae2a 100644
--- a/src/Cap.Consistency.RabbitMQ/RabbitMQConsumerClientFactory.cs
+++ b/src/DotNetCore.CAP.RabbitMQ/RabbitMQConsumerClientFactory.cs
@@ -1,10 +1,9 @@
-using Cap.Consistency.Consumer;
-
-namespace Cap.Consistency.RabbitMQ
+namespace DotNetCore.CAP.RabbitMQ
{
public class RabbitMQConsumerClientFactory : IConsumerClientFactory
{
- public IConsumerClient Create(string groupId, string clientHostAddress) {
+ public IConsumerClient Create(string groupId, string clientHostAddress)
+ {
return new RabbitMQConsumerClient(groupId, clientHostAddress);
}
}
diff --git a/src/Cap.Consistency.RabbitMQ/RabbitMQProducerClient.cs b/src/DotNetCore.CAP.RabbitMQ/RabbitMQProducerClient.cs
similarity index 76%
rename from src/Cap.Consistency.RabbitMQ/RabbitMQProducerClient.cs
rename to src/DotNetCore.CAP.RabbitMQ/RabbitMQProducerClient.cs
index ad9e0f9..42a26b7 100644
--- a/src/Cap.Consistency.RabbitMQ/RabbitMQProducerClient.cs
+++ b/src/DotNetCore.CAP.RabbitMQ/RabbitMQProducerClient.cs
@@ -1,26 +1,29 @@
using System.Text;
using System.Threading.Tasks;
-using Cap.Consistency.Infrastructure;
+using DotNetCore.CAP.Infrastructure;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using RabbitMQ.Client;
-namespace Cap.Consistency.RabbitMQ
+namespace DotNetCore.CAP.RabbitMQ
{
- public class RabbitMQProducerClient : IProducerClient
+ public class RabbitMQProducerClient : ICapProducerService
{
private readonly ConsistencyOptions _options;
private readonly ILogger _logger;
- public RabbitMQProducerClient(IOptions options, ILoggerFactory loggerFactory) {
+ public RabbitMQProducerClient(IOptions options, ILoggerFactory loggerFactory)
+ {
_options = options.Value;
_logger = loggerFactory.CreateLogger(nameof(RabbitMQProducerClient));
}
- public Task SendAsync(string topic, string content) {
+ public Task SendAsync(string topic, string content)
+ {
var factory = new ConnectionFactory() { HostName = _options.BrokerUrlList };
using (var connection = factory.CreateConnection())
- using (var channel = connection.CreateModel()) {
+ using (var channel = connection.CreateModel())
+ {
channel.ExchangeDeclare(exchange: "topic_logs",
type: "topic");
diff --git a/src/DotNetCore.CAP.RabbitMQ/RabbitMQTopicAttribute.cs b/src/DotNetCore.CAP.RabbitMQ/RabbitMQTopicAttribute.cs
new file mode 100644
index 0000000..1b6e027
--- /dev/null
+++ b/src/DotNetCore.CAP.RabbitMQ/RabbitMQTopicAttribute.cs
@@ -0,0 +1,11 @@
+using DotNetCore.CAP.Abstractions;
+
+namespace DotNetCore.CAP.RabbitMQ
+{
+ public class RabbitMQTopicAttribute : TopicAttribute
+ {
+ public RabbitMQTopicAttribute(string routingKey) : base(routingKey)
+ {
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Cap.Consistency/Abstractions/ConsumerContext.cs b/src/DotNetCore.CAP/Abstractions/ConsumerContext.cs
similarity index 70%
rename from src/Cap.Consistency/Abstractions/ConsumerContext.cs
rename to src/DotNetCore.CAP/Abstractions/ConsumerContext.cs
index c61d9fe..e700541 100644
--- a/src/Cap.Consistency/Abstractions/ConsumerContext.cs
+++ b/src/DotNetCore.CAP/Abstractions/ConsumerContext.cs
@@ -1,15 +1,12 @@
using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Threading.Tasks;
-using Cap.Consistency.Infrastructure;
+using DotNetCore.CAP.Infrastructure;
-namespace Cap.Consistency.Abstractions
+namespace DotNetCore.CAP.Abstractions
{
public class ConsumerContext
{
- public ConsumerContext(ConsumerExecutorDescriptor descriptor, DeliverMessage message) {
-
+ public ConsumerContext(ConsumerExecutorDescriptor descriptor, DeliverMessage message)
+ {
ConsumerDescriptor = descriptor ?? throw new ArgumentNullException(nameof(descriptor));
DeliverMessage = message ?? throw new ArgumentNullException(nameof(message));
}
@@ -18,4 +15,4 @@ namespace Cap.Consistency.Abstractions
public DeliverMessage DeliverMessage { get; set; }
}
-}
+}
\ No newline at end of file
diff --git a/src/Cap.Consistency/Abstractions/ConsumerExecutorDescriptor.cs b/src/DotNetCore.CAP/Abstractions/ConsumerExecutorDescriptor.cs
similarity index 61%
rename from src/Cap.Consistency/Abstractions/ConsumerExecutorDescriptor.cs
rename to src/DotNetCore.CAP/Abstractions/ConsumerExecutorDescriptor.cs
index 48fda7a..ef50933 100644
--- a/src/Cap.Consistency/Abstractions/ConsumerExecutorDescriptor.cs
+++ b/src/DotNetCore.CAP/Abstractions/ConsumerExecutorDescriptor.cs
@@ -1,9 +1,6 @@
-using System;
-using System.Collections.Generic;
-using System.Reflection;
-using System.Text;
+using System.Reflection;
-namespace Cap.Consistency.Abstractions
+namespace DotNetCore.CAP.Abstractions
{
public class ConsumerExecutorDescriptor
{
@@ -13,4 +10,4 @@ namespace Cap.Consistency.Abstractions
public TopicAttribute Attribute { get; set; }
}
-}
+}
\ No newline at end of file
diff --git a/src/Cap.Consistency/Abstractions/ConsumerInvokerContext.cs b/src/DotNetCore.CAP/Abstractions/ConsumerInvokerContext.cs
similarity index 68%
rename from src/Cap.Consistency/Abstractions/ConsumerInvokerContext.cs
rename to src/DotNetCore.CAP/Abstractions/ConsumerInvokerContext.cs
index f5e0afc..cedea1a 100644
--- a/src/Cap.Consistency/Abstractions/ConsumerInvokerContext.cs
+++ b/src/DotNetCore.CAP/Abstractions/ConsumerInvokerContext.cs
@@ -1,20 +1,17 @@
using System;
-using System.Collections.Generic;
-using System.Text;
-namespace Cap.Consistency.Abstractions
+namespace DotNetCore.CAP.Abstractions
{
public class ConsumerInvokerContext
{
- public ConsumerInvokerContext(ConsumerContext consumerContext) {
- ConsumerContext = consumerContext ??
+ public ConsumerInvokerContext(ConsumerContext consumerContext)
+ {
+ ConsumerContext = consumerContext ??
throw new ArgumentNullException(nameof(consumerContext));
-
}
public ConsumerContext ConsumerContext { get; set; }
public IConsumerInvoker Result { get; set; }
-
}
-}
+}
\ No newline at end of file
diff --git a/src/DotNetCore.CAP/Abstractions/IConsumerInvoker.cs b/src/DotNetCore.CAP/Abstractions/IConsumerInvoker.cs
new file mode 100644
index 0000000..ede8fa3
--- /dev/null
+++ b/src/DotNetCore.CAP/Abstractions/IConsumerInvoker.cs
@@ -0,0 +1,9 @@
+using System.Threading.Tasks;
+
+namespace DotNetCore.CAP.Abstractions
+{
+ public interface IConsumerInvoker
+ {
+ Task InvokeAsync();
+ }
+}
\ No newline at end of file
diff --git a/src/DotNetCore.CAP/Abstractions/ModelBinding/IModelBinder.cs b/src/DotNetCore.CAP/Abstractions/ModelBinding/IModelBinder.cs
new file mode 100644
index 0000000..3b87c51
--- /dev/null
+++ b/src/DotNetCore.CAP/Abstractions/ModelBinding/IModelBinder.cs
@@ -0,0 +1,9 @@
+using System.Threading.Tasks;
+
+namespace DotNetCore.CAP.Abstractions.ModelBinding
+{
+ public interface IModelBinder
+ {
+ Task BindModelAsync(ModelBindingContext bindingContext);
+ }
+}
\ No newline at end of file
diff --git a/src/Cap.Consistency/Abstractions/ModelBinding/ModelBindingContext.cs b/src/DotNetCore.CAP/Abstractions/ModelBinding/ModelBindingContext.cs
similarity index 72%
rename from src/Cap.Consistency/Abstractions/ModelBinding/ModelBindingContext.cs
rename to src/DotNetCore.CAP/Abstractions/ModelBinding/ModelBindingContext.cs
index f680da1..9b57fe1 100644
--- a/src/Cap.Consistency/Abstractions/ModelBinding/ModelBindingContext.cs
+++ b/src/DotNetCore.CAP/Abstractions/ModelBinding/ModelBindingContext.cs
@@ -1,9 +1,7 @@
using System;
-using System.Collections.Generic;
-using System.Text;
using Microsoft.Extensions.Primitives;
-namespace Cap.Consistency.Abstractions.ModelBinding
+namespace DotNetCore.CAP.Abstractions.ModelBinding
{
public class ModelBindingContext
{
@@ -17,12 +15,14 @@ namespace Cap.Consistency.Abstractions.ModelBinding
public object Result { get; set; }
- public static ModelBindingContext CreateBindingContext(string values, string modelName, Type modelType) {
- return new ModelBindingContext() {
+ public static ModelBindingContext CreateBindingContext(string values, string modelName, Type modelType)
+ {
+ return new ModelBindingContext()
+ {
ModelName = modelName,
ModelType = modelType,
Values = values
};
}
}
-}
+}
\ No newline at end of file
diff --git a/src/Cap.Consistency/Abstractions/TopicAttribute.cs b/src/DotNetCore.CAP/Abstractions/TopicAttribute.cs
similarity index 65%
rename from src/Cap.Consistency/Abstractions/TopicAttribute.cs
rename to src/DotNetCore.CAP/Abstractions/TopicAttribute.cs
index a2c1677..195af85 100644
--- a/src/Cap.Consistency/Abstractions/TopicAttribute.cs
+++ b/src/DotNetCore.CAP/Abstractions/TopicAttribute.cs
@@ -1,20 +1,19 @@
using System;
-using System.Collections.Generic;
-using System.Text;
-namespace Cap.Consistency.Abstractions
+namespace DotNetCore.CAP.Abstractions
{
-
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, Inherited = true, AllowMultiple = true)]
public abstract class TopicAttribute : Attribute
{
- readonly string _name;
+ private readonly string _name;
- public TopicAttribute(string topicName) {
+ public TopicAttribute(string topicName)
+ {
this._name = topicName;
}
- public string Name {
+ public string Name
+ {
get { return _name; }
}
@@ -22,4 +21,4 @@ namespace Cap.Consistency.Abstractions
public bool IsOneWay { get; set; }
}
-}
+}
\ No newline at end of file
diff --git a/src/Cap.Consistency/Microsoft.AspNetCore.Builder/BuilderExtensions.cs b/src/DotNetCore.CAP/CAP.AppBuilderExtensions.cs
similarity index 76%
rename from src/Cap.Consistency/Microsoft.AspNetCore.Builder/BuilderExtensions.cs
rename to src/DotNetCore.CAP/CAP.AppBuilderExtensions.cs
index 8d630eb..897d27d 100644
--- a/src/Cap.Consistency/Microsoft.AspNetCore.Builder/BuilderExtensions.cs
+++ b/src/DotNetCore.CAP/CAP.AppBuilderExtensions.cs
@@ -1,28 +1,30 @@
using System;
-using Cap.Consistency;
+using DotNetCore.CAP;
using Microsoft.Extensions.DependencyInjection;
-// ReSharper disable once CheckNamespace
namespace Microsoft.AspNetCore.Builder
{
///
/// Consistence extensions for
///
- public static class BuilderExtensions
+ public static class AppBuilderExtensions
{
///
/// Enables Consistence for the current application
///
/// The instance this method extends.
/// The instance this method extends.
- public static IApplicationBuilder UseConsistency(this IApplicationBuilder app) {
- if (app == null) {
+ public static IApplicationBuilder UseConsistency(this IApplicationBuilder app)
+ {
+ if (app == null)
+ {
throw new ArgumentNullException(nameof(app));
}
-
- var marker = app.ApplicationServices.GetService();
-
- if (marker == null) {
+
+ var marker = app.ApplicationServices.GetService();
+
+ if (marker == null)
+ {
throw new InvalidOperationException("Add Consistency must be called on the service collection.");
}
diff --git a/src/DotNetCore.CAP/CAP.Builder.cs b/src/DotNetCore.CAP/CAP.Builder.cs
new file mode 100644
index 0000000..8ca1931
--- /dev/null
+++ b/src/DotNetCore.CAP/CAP.Builder.cs
@@ -0,0 +1,58 @@
+using System;
+using DotNetCore.CAP;
+using DotNetCore.CAP.Job;
+
+namespace Microsoft.Extensions.DependencyInjection
+{
+ ///
+ /// Used to verify Consistency service was called on a ServiceCollection
+ ///
+ public class CapMarkerService { }
+
+ public class CapBuilder
+ {
+ public CapBuilder(IServiceCollection services)
+ {
+ Services = services;
+ }
+
+ public IServiceCollection Services { get; private set; }
+
+ private CapBuilder AddScoped(Type serviceType, Type concreteType)
+ {
+ Services.AddScoped(serviceType, concreteType);
+ return this;
+ }
+
+ private CapBuilder AddSingleton()
+ where TService : class
+ where TImplementation : class, TService
+ {
+ Services.AddSingleton();
+ return this;
+ }
+
+ ///
+ /// Adds an .
+ ///
+ /// The type for the to add.
+ /// The current instance.
+ public virtual CapBuilder AddMessageStore()
+ where T : class, ICapMessageStore
+ {
+ return AddScoped(typeof(ICapMessageStore), typeof(T));
+ }
+
+ public virtual CapBuilder AddJobs()
+ where T : class, IJob
+ {
+ return AddSingleton();
+ }
+
+ public virtual CapBuilder AddProducerClient()
+ where T : class, ICapProducerService
+ {
+ return AddScoped(typeof(ICapProducerService), typeof(T));
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Cap.Consistency/Microsoft.Extensions.DependencyInjection/ServiceCollectionExtensions.cs b/src/DotNetCore.CAP/CAP.ServiceCollectionExtensions.cs
similarity index 72%
rename from src/Cap.Consistency/Microsoft.Extensions.DependencyInjection/ServiceCollectionExtensions.cs
rename to src/DotNetCore.CAP/CAP.ServiceCollectionExtensions.cs
index 314a8d2..8a3ebc0 100644
--- a/src/Cap.Consistency/Microsoft.Extensions.DependencyInjection/ServiceCollectionExtensions.cs
+++ b/src/DotNetCore.CAP/CAP.ServiceCollectionExtensions.cs
@@ -1,12 +1,11 @@
using System;
using System.Collections.Generic;
using System.Reflection;
-using Cap.Consistency;
-using Cap.Consistency.Abstractions.ModelBinding;
-using Cap.Consistency.Consumer;
-using Cap.Consistency.Infrastructure;
-using Cap.Consistency.Internal;
-using Cap.Consistency.Job;
+using DotNetCore.CAP;
+using DotNetCore.CAP.Abstractions.ModelBinding;
+using DotNetCore.CAP.Infrastructure;
+using DotNetCore.CAP.Internal;
+using DotNetCore.CAP.Job;
using Microsoft.Extensions.DependencyInjection.Extensions;
namespace Microsoft.Extensions.DependencyInjection
@@ -20,11 +19,12 @@ namespace Microsoft.Extensions.DependencyInjection
/// Adds and configures the consistence services for the consitence.
///
/// The services available in the application.
- /// An for application services.
- public static ConsistencyBuilder AddConsistency(this IServiceCollection services) {
+ /// An for application services.
+ public static CapBuilder AddConsistency(this IServiceCollection services)
+ {
services.AddConsistency(x => new ConsistencyOptions());
- return new ConsistencyBuilder(services);
+ return new CapBuilder(services);
}
///
@@ -32,12 +32,12 @@ namespace Microsoft.Extensions.DependencyInjection
///
/// The services available in the application.
/// An action to configure the .
- /// An for application services.
- public static ConsistencyBuilder AddConsistency(
+ /// An for application services.
+ public static CapBuilder AddConsistency(
this IServiceCollection services,
- Action setupAction) {
-
- services.TryAddSingleton();
+ Action setupAction)
+ {
+ services.TryAddSingleton();
services.Configure(setupAction);
AddConsumerServices(services);
@@ -55,27 +55,32 @@ namespace Microsoft.Extensions.DependencyInjection
services.TryAddSingleton();
services.TryAddTransient();
- services.TryAddScoped();
+ services.TryAddScoped();
- return new ConsistencyBuilder(services);
+ return new CapBuilder(services);
}
- private static void AddConsumerServices(IServiceCollection services) {
+ private static void AddConsumerServices(IServiceCollection services)
+ {
var consumerListenerServices = new Dictionary();
- foreach (var rejectedServices in services) {
+ foreach (var rejectedServices in services)
+ {
if (rejectedServices.ImplementationType != null
&& typeof(IConsumerService).IsAssignableFrom(rejectedServices.ImplementationType))
consumerListenerServices.Add(typeof(IConsumerService), rejectedServices.ImplementationType);
}
- foreach (var service in consumerListenerServices) {
+ foreach (var service in consumerListenerServices)
+ {
services.AddSingleton(service.Key, service.Value);
}
var types = Assembly.GetEntryAssembly().ExportedTypes;
- foreach (var type in types) {
- if (typeof(IConsumerService).IsAssignableFrom(type)) {
+ foreach (var type in types)
+ {
+ if (typeof(IConsumerService).IsAssignableFrom(type))
+ {
services.AddSingleton(typeof(IConsumerService), type);
}
}
diff --git a/src/Cap.Consistency/Cap.Consistency.csproj b/src/DotNetCore.CAP/DotNetCore.CAP.csproj
similarity index 96%
rename from src/Cap.Consistency/Cap.Consistency.csproj
rename to src/DotNetCore.CAP/DotNetCore.CAP.csproj
index 7f13274..0554fe9 100644
--- a/src/Cap.Consistency/Cap.Consistency.csproj
+++ b/src/DotNetCore.CAP/DotNetCore.CAP.csproj
@@ -1,7 +1,7 @@
- Cap.Consistency
+ DotNetCore.CAP
netstandard1.6
1.6.1
$(PackageTargetFallback);dnxcore50
diff --git a/src/Cap.Consistency/IBootstrapper.Default.cs b/src/DotNetCore.CAP/IBootstrapper.Default.cs
similarity index 70%
rename from src/Cap.Consistency/IBootstrapper.Default.cs
rename to src/DotNetCore.CAP/IBootstrapper.Default.cs
index e0361b1..81f1239 100644
--- a/src/Cap.Consistency/IBootstrapper.Default.cs
+++ b/src/DotNetCore.CAP/IBootstrapper.Default.cs
@@ -1,14 +1,13 @@
using System;
-using System.Linq;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
-using Cap.Consistency.Infrastructure;
+using DotNetCore.CAP.Infrastructure;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
-namespace Cap.Consistency
+namespace DotNetCore.CAP
{
public class DefaultBootstrapper : IBootstrapper
{
@@ -19,39 +18,44 @@ namespace Cap.Consistency
public DefaultBootstrapper(
IOptions options,
- IConsistencyMessageStore storage,
+ ICapMessageStore storage,
IApplicationLifetime appLifetime,
- IServiceProvider provider) {
-
+ IServiceProvider provider)
+ {
Options = options.Value;
Storage = storage;
_appLifetime = appLifetime;
Provider = provider;
Servers = Provider.GetServices();
_cts = new CancellationTokenSource();
- _ctsRegistration = appLifetime.ApplicationStopping.Register(() => {
+ _ctsRegistration = appLifetime.ApplicationStopping.Register(() =>
+ {
_cts.Cancel();
- try {
+ try
+ {
_bootstrappingTask?.Wait();
}
- catch (OperationCanceledException) {
+ catch (OperationCanceledException)
+ {
}
});
}
protected ConsistencyOptions Options { get; }
- protected IConsistencyMessageStore Storage { get; }
+ protected ICapMessageStore Storage { get; }
protected IEnumerable Servers { get; }
public IServiceProvider Provider { get; private set; }
- public Task BootstrapAsync() {
+ public Task BootstrapAsync()
+ {
return (_bootstrappingTask = BootstrapTaskAsync());
}
- private async Task BootstrapTaskAsync() {
+ private async Task BootstrapTaskAsync()
+ {
if (_cts.IsCancellationRequested) return;
if (_cts.IsCancellationRequested) return;
@@ -60,11 +64,14 @@ namespace Cap.Consistency
if (_cts.IsCancellationRequested) return;
- foreach (var item in Servers) {
- try {
+ foreach (var item in Servers)
+ {
+ try
+ {
item.Start();
}
- catch (Exception) {
+ catch (Exception)
+ {
}
}
@@ -72,9 +79,12 @@ namespace Cap.Consistency
_cts.Dispose();
}
- public virtual Task BootstrapCoreAsync() {
- _appLifetime.ApplicationStopping.Register(() => {
- foreach (var item in Servers) {
+ public virtual Task BootstrapCoreAsync()
+ {
+ _appLifetime.ApplicationStopping.Register(() =>
+ {
+ foreach (var item in Servers)
+ {
item.Dispose();
}
});
diff --git a/src/Cap.Consistency/IBootstrapper.cs b/src/DotNetCore.CAP/IBootstrapper.cs
similarity index 90%
rename from src/Cap.Consistency/IBootstrapper.cs
rename to src/DotNetCore.CAP/IBootstrapper.cs
index b47238c..aacd1dc 100644
--- a/src/Cap.Consistency/IBootstrapper.cs
+++ b/src/DotNetCore.CAP/IBootstrapper.cs
@@ -1,6 +1,6 @@
using System.Threading.Tasks;
-namespace Cap.Consistency
+namespace DotNetCore.CAP
{
///
/// Represents bootstrapping logic. For example, adding initial state to the storage or querying certain entities.
diff --git a/src/Cap.Consistency/IConsistencyMessageStore.cs b/src/DotNetCore.CAP/ICapMessageStore.cs
similarity index 93%
rename from src/Cap.Consistency/IConsistencyMessageStore.cs
rename to src/DotNetCore.CAP/ICapMessageStore.cs
index 6a8389c..d115621 100644
--- a/src/Cap.Consistency/IConsistencyMessageStore.cs
+++ b/src/DotNetCore.CAP/ICapMessageStore.cs
@@ -1,15 +1,14 @@
-using System;
-using System.Threading;
+using System.Threading;
using System.Threading.Tasks;
-using Cap.Consistency.Infrastructure;
+using DotNetCore.CAP.Infrastructure;
-namespace Cap.Consistency
+namespace DotNetCore.CAP
{
///
/// Provides an abstraction for a store which manages consistent message.
///
///
- public interface IConsistencyMessageStore
+ public interface ICapMessageStore
{
///
/// Finds and returns a message, if any, who has the specified .
@@ -20,7 +19,6 @@ namespace Cap.Consistency
/// The that represents the asynchronous operation, containing the message matching the specified if it exists.
///
Task FindByIdAsync(string messageId, CancellationToken cancellationToken);
-
///
/// Creates a new message in a store as an asynchronous operation.
@@ -56,6 +54,6 @@ namespace Cap.Consistency
Task GetFirstEnqueuedMessageAsync(CancellationToken cancellationToken);
- // void ChangeState(ConsistencyMessage message, MessageStatus status);
+ // void ChangeState(ConsistencyMessage message, MessageStatus status);
}
}
\ No newline at end of file
diff --git a/src/Cap.Consistency/IProducerClient.Default.cs b/src/DotNetCore.CAP/ICapProducerService.Default.cs
similarity index 67%
rename from src/Cap.Consistency/IProducerClient.Default.cs
rename to src/DotNetCore.CAP/ICapProducerService.Default.cs
index 52ead5b..c685a07 100644
--- a/src/Cap.Consistency/IProducerClient.Default.cs
+++ b/src/DotNetCore.CAP/ICapProducerService.Default.cs
@@ -1,34 +1,36 @@
using System;
using System.Threading;
using System.Threading.Tasks;
-using Cap.Consistency.Infrastructure;
+using DotNetCore.CAP.Infrastructure;
using Microsoft.Extensions.Logging;
-namespace Cap.Consistency
+namespace DotNetCore.CAP
{
- public class DefaultProducerClient : IProducerClient
+ public class DefaultProducerService : ICapProducerService
{
- private readonly IConsistencyMessageStore _store;
+ private readonly ICapMessageStore _store;
private readonly ILogger _logger;
private readonly CancellationTokenSource _cts;
- public DefaultProducerClient(
- IConsistencyMessageStore store,
- ILogger logger) {
-
+ public DefaultProducerService(
+ ICapMessageStore store,
+ ILogger logger)
+ {
_store = store;
_logger = logger;
_cts = new CancellationTokenSource();
}
- public Task SendAsync(string topic, string content) {
+ public Task SendAsync(string topic, string content)
+ {
if (topic == null) throw new ArgumentNullException(nameof(topic));
if (content == null) throw new ArgumentNullException(nameof(content));
return StoreMessage(topic, content);
}
- public Task SendAsync(string topic, T obj) {
+ public Task SendAsync(string topic, T obj)
+ {
if (topic == null) throw new ArgumentNullException(nameof(topic));
var content = Helper.ToJson(obj);
@@ -38,9 +40,10 @@ namespace Cap.Consistency
return StoreMessage(topic, content);
}
- private async Task StoreMessage(string topic, string content) {
-
- var message = new ConsistencyMessage {
+ private async Task StoreMessage(string topic, string content)
+ {
+ var message = new ConsistencyMessage
+ {
Topic = topic,
Payload = content
};
@@ -49,9 +52,10 @@ namespace Cap.Consistency
WaitHandleEx.PulseEvent.Set();
- if (_logger.IsEnabled(LogLevel.Debug)) {
+ if (_logger.IsEnabled(LogLevel.Debug))
+ {
_logger.LogDebug("Enqueuing a topic to be store. topic:{topic}, content:{content}", topic, content);
}
}
}
-}
+}
\ No newline at end of file
diff --git a/src/DotNetCore.CAP/ICapProducerService.cs b/src/DotNetCore.CAP/ICapProducerService.cs
new file mode 100644
index 0000000..cddf4dc
--- /dev/null
+++ b/src/DotNetCore.CAP/ICapProducerService.cs
@@ -0,0 +1,9 @@
+using System.Threading.Tasks;
+
+namespace DotNetCore.CAP
+{
+ public interface ICapProducerService
+ {
+ Task SendAsync(string topic, string content);
+ }
+}
\ No newline at end of file
diff --git a/src/Cap.Consistency/Consumer/IConsumerClient.cs b/src/DotNetCore.CAP/IConsumerClient.cs
similarity index 82%
rename from src/Cap.Consistency/Consumer/IConsumerClient.cs
rename to src/DotNetCore.CAP/IConsumerClient.cs
index fb5e98f..619e14a 100644
--- a/src/Cap.Consistency/Consumer/IConsumerClient.cs
+++ b/src/DotNetCore.CAP/IConsumerClient.cs
@@ -1,9 +1,9 @@
using System;
using System.Collections.Generic;
using System.Text;
-using Cap.Consistency.Infrastructure;
+using DotNetCore.CAP.Infrastructure;
-namespace Cap.Consistency.Consumer
+namespace DotNetCore.CAP
{
public interface IConsumerClient : IDisposable
{
diff --git a/src/Cap.Consistency/Consumer/IConsumerClientFactory.cs b/src/DotNetCore.CAP/IConsumerClientFactory.cs
similarity index 87%
rename from src/Cap.Consistency/Consumer/IConsumerClientFactory.cs
rename to src/DotNetCore.CAP/IConsumerClientFactory.cs
index 6ac5fc4..6fa9932 100644
--- a/src/Cap.Consistency/Consumer/IConsumerClientFactory.cs
+++ b/src/DotNetCore.CAP/IConsumerClientFactory.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
-namespace Cap.Consistency.Consumer
+namespace DotNetCore.CAP
{
public interface IConsumerClientFactory
{
diff --git a/src/Cap.Consistency/Consumer/ConsumerHandler.cs b/src/DotNetCore.CAP/IConsumerHandler.Default.cs
similarity index 94%
rename from src/Cap.Consistency/Consumer/ConsumerHandler.cs
rename to src/DotNetCore.CAP/IConsumerHandler.Default.cs
index 4155d7f..b25d3ab 100644
--- a/src/Cap.Consistency/Consumer/ConsumerHandler.cs
+++ b/src/DotNetCore.CAP/IConsumerHandler.Default.cs
@@ -3,13 +3,13 @@ using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
-using Cap.Consistency.Abstractions;
-using Cap.Consistency.Infrastructure;
-using Cap.Consistency.Internal;
+using DotNetCore.CAP.Abstractions;
+using DotNetCore.CAP.Infrastructure;
+using DotNetCore.CAP.Internal;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
-namespace Cap.Consistency.Consumer
+namespace DotNetCore.CAP
{
public class ConsumerHandler : IConsumerHandler, IDisposable
{
@@ -21,7 +21,7 @@ namespace Cap.Consistency.Consumer
private readonly MethodMatcherCache _selector;
private readonly ConsistencyOptions _options;
- private readonly IConsistencyMessageStore _messageStore;
+ private readonly ICapMessageStore _messageStore;
private readonly CancellationTokenSource _cts;
public event EventHandler MessageReceieved;
@@ -35,7 +35,7 @@ namespace Cap.Consistency.Consumer
IConsumerInvokerFactory consumerInvokerFactory,
IConsumerClientFactory consumerClientFactory,
ILoggerFactory loggerFactory,
- IConsistencyMessageStore messageStore,
+ ICapMessageStore messageStore,
MethodMatcherCache selector,
IOptions options) {
_selector = selector;
diff --git a/src/Cap.Consistency/Consumer/IConsumerHandler.cs b/src/DotNetCore.CAP/IConsumerHandler.cs
similarity index 64%
rename from src/Cap.Consistency/Consumer/IConsumerHandler.cs
rename to src/DotNetCore.CAP/IConsumerHandler.cs
index 5ada307..d5d50e4 100644
--- a/src/Cap.Consistency/Consumer/IConsumerHandler.cs
+++ b/src/DotNetCore.CAP/IConsumerHandler.cs
@@ -1,7 +1,6 @@
-namespace Cap.Consistency.Consumer
+namespace DotNetCore.CAP
{
public interface IConsumerHandler : IProcessingServer
{
-
}
}
\ No newline at end of file
diff --git a/src/DotNetCore.CAP/IConsumerService.cs b/src/DotNetCore.CAP/IConsumerService.cs
new file mode 100644
index 0000000..1e2316e
--- /dev/null
+++ b/src/DotNetCore.CAP/IConsumerService.cs
@@ -0,0 +1,6 @@
+namespace DotNetCore.CAP
+{
+ public interface IConsumerService
+ {
+ }
+}
\ No newline at end of file
diff --git a/src/DotNetCore.CAP/IProcessingServer.cs b/src/DotNetCore.CAP/IProcessingServer.cs
new file mode 100644
index 0000000..ff79c4e
--- /dev/null
+++ b/src/DotNetCore.CAP/IProcessingServer.cs
@@ -0,0 +1,9 @@
+using System;
+
+namespace DotNetCore.CAP
+{
+ public interface IProcessingServer : IDisposable
+ {
+ void Start();
+ }
+}
\ No newline at end of file
diff --git a/src/Cap.Consistency/Infrastructure/ConsistencyMessage.cs b/src/DotNetCore.CAP/Infrastructure/ConsistencyMessage.cs
similarity index 93%
rename from src/Cap.Consistency/Infrastructure/ConsistencyMessage.cs
rename to src/DotNetCore.CAP/Infrastructure/ConsistencyMessage.cs
index a3bef62..26a73ac 100644
--- a/src/Cap.Consistency/Infrastructure/ConsistencyMessage.cs
+++ b/src/DotNetCore.CAP/Infrastructure/ConsistencyMessage.cs
@@ -1,6 +1,6 @@
using System;
-namespace Cap.Consistency.Infrastructure
+namespace DotNetCore.CAP.Infrastructure
{
///
/// The default implementation of which uses a string as a primary key.
@@ -13,7 +13,8 @@ namespace Cap.Consistency.Infrastructure
///
/// The Id property is initialized to from a new GUID string value.
///
- public ConsistencyMessage() {
+ public ConsistencyMessage()
+ {
Id = Guid.NewGuid().ToString();
SendTime = DateTime.Now;
UpdateTime = SendTime;
diff --git a/src/Cap.Consistency/Infrastructure/ConsistencyOptions.cs b/src/DotNetCore.CAP/Infrastructure/ConsistencyOptions.cs
similarity index 82%
rename from src/Cap.Consistency/Infrastructure/ConsistencyOptions.cs
rename to src/DotNetCore.CAP/Infrastructure/ConsistencyOptions.cs
index 963ba89..3a0fe12 100644
--- a/src/Cap.Consistency/Infrastructure/ConsistencyOptions.cs
+++ b/src/DotNetCore.CAP/Infrastructure/ConsistencyOptions.cs
@@ -1,6 +1,6 @@
-using Cap.Consistency.Job;
+using DotNetCore.CAP.Job;
-namespace Cap.Consistency.Infrastructure
+namespace DotNetCore.CAP.Infrastructure
{
///
/// Represents all the options you can use to configure the system.
diff --git a/src/Cap.Consistency/Infrastructure/DeliverMessage.cs b/src/DotNetCore.CAP/Infrastructure/DeliverMessage.cs
similarity index 74%
rename from src/Cap.Consistency/Infrastructure/DeliverMessage.cs
rename to src/DotNetCore.CAP/Infrastructure/DeliverMessage.cs
index e5c59c3..5ea868b 100644
--- a/src/Cap.Consistency/Infrastructure/DeliverMessage.cs
+++ b/src/DotNetCore.CAP/Infrastructure/DeliverMessage.cs
@@ -1,8 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace Cap.Consistency.Infrastructure
+namespace DotNetCore.CAP.Infrastructure
{
public class DeliverMessage
{
@@ -14,9 +10,8 @@ namespace Cap.Consistency.Infrastructure
///
public string MessageKey { get; set; }
-
public byte[] Body { get; set; }
public string Value { get; set; }
}
-}
+}
\ No newline at end of file
diff --git a/src/Cap.Consistency/Infrastructure/Helper.cs b/src/DotNetCore.CAP/Infrastructure/Helper.cs
similarity index 72%
rename from src/Cap.Consistency/Infrastructure/Helper.cs
rename to src/DotNetCore.CAP/Infrastructure/Helper.cs
index aa65bd9..eb841f7 100644
--- a/src/Cap.Consistency/Infrastructure/Helper.cs
+++ b/src/DotNetCore.CAP/Infrastructure/Helper.cs
@@ -1,32 +1,34 @@
using System;
-using System.Collections.Generic;
-using System.Text;
using Newtonsoft.Json;
-namespace Cap.Consistency.Infrastructure
+namespace DotNetCore.CAP.Infrastructure
{
internal static class Helper
{
private static readonly DateTime Epoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
private static JsonSerializerSettings SerializerSettings;
- public static void SetSerializerSettings(JsonSerializerSettings setting) {
+ public static void SetSerializerSettings(JsonSerializerSettings setting)
+ {
SerializerSettings = setting;
}
- public static string ToJson(object value) {
+ public static string ToJson(object value)
+ {
return value != null
? JsonConvert.SerializeObject(value, SerializerSettings)
: null;
}
- public static T FromJson(string value) {
+ public static T FromJson(string value)
+ {
return value != null
? JsonConvert.DeserializeObject(value, SerializerSettings)
: default(T);
}
- public static object FromJson(string value, Type type) {
+ public static object FromJson(string value, Type type)
+ {
if (type == null) throw new ArgumentNullException(nameof(type));
return value != null
@@ -34,13 +36,15 @@ namespace Cap.Consistency.Infrastructure
: null;
}
- public static long ToTimestamp(DateTime value) {
+ public static long ToTimestamp(DateTime value)
+ {
var elapsedTime = value - Epoch;
return (long)elapsedTime.TotalSeconds;
}
- public static DateTime FromTimestamp(long value) {
+ public static DateTime FromTimestamp(long value)
+ {
return Epoch.AddSeconds(value);
}
}
-}
+}
\ No newline at end of file
diff --git a/src/Cap.Consistency/Infrastructure/IConsumerExcutorSelector.cs b/src/DotNetCore.CAP/Infrastructure/IConsumerExcutorSelector.cs
similarity index 65%
rename from src/Cap.Consistency/Infrastructure/IConsumerExcutorSelector.cs
rename to src/DotNetCore.CAP/Infrastructure/IConsumerExcutorSelector.cs
index d72d621..a23bfd5 100644
--- a/src/Cap.Consistency/Infrastructure/IConsumerExcutorSelector.cs
+++ b/src/DotNetCore.CAP/Infrastructure/IConsumerExcutorSelector.cs
@@ -1,9 +1,7 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using Cap.Consistency.Abstractions;
+using System.Collections.Generic;
+using DotNetCore.CAP.Abstractions;
-namespace Cap.Consistency.Infrastructure
+namespace DotNetCore.CAP.Infrastructure
{
public interface IConsumerExcutorSelector
{
@@ -11,4 +9,4 @@ namespace Cap.Consistency.Infrastructure
ConsumerExecutorDescriptor SelectBestCandidate(string key, IReadOnlyList executeDescriptor);
}
-}
+}
\ No newline at end of file
diff --git a/src/DotNetCore.CAP/Infrastructure/IConsumerInvokerFactory.cs b/src/DotNetCore.CAP/Infrastructure/IConsumerInvokerFactory.cs
new file mode 100644
index 0000000..de2153b
--- /dev/null
+++ b/src/DotNetCore.CAP/Infrastructure/IConsumerInvokerFactory.cs
@@ -0,0 +1,9 @@
+using DotNetCore.CAP.Abstractions;
+
+namespace DotNetCore.CAP.Infrastructure
+{
+ public interface IConsumerInvokerFactory
+ {
+ IConsumerInvoker CreateInvoker(ConsumerContext actionContext);
+ }
+}
\ No newline at end of file
diff --git a/src/Cap.Consistency/Infrastructure/WaitHandleEx.cs b/src/DotNetCore.CAP/Infrastructure/WaitHandleEx.cs
similarity index 80%
rename from src/Cap.Consistency/Infrastructure/WaitHandleEx.cs
rename to src/DotNetCore.CAP/Infrastructure/WaitHandleEx.cs
index bf1c055..439c984 100644
--- a/src/Cap.Consistency/Infrastructure/WaitHandleEx.cs
+++ b/src/DotNetCore.CAP/Infrastructure/WaitHandleEx.cs
@@ -1,24 +1,25 @@
using System;
-using System.Collections.Generic;
-using System.Text;
using System.Threading;
using System.Threading.Tasks;
-namespace Cap.Consistency.Infrastructure
+namespace DotNetCore.CAP.Infrastructure
{
public static class WaitHandleEx
{
public static readonly AutoResetEvent PulseEvent = new AutoResetEvent(true);
- public static Task WaitAnyAsync(WaitHandle handle1, WaitHandle handle2, TimeSpan timeout) {
+ public static Task WaitAnyAsync(WaitHandle handle1, WaitHandle handle2, TimeSpan timeout)
+ {
var t1 = handle1.WaitOneAsync(timeout);
var t2 = handle2.WaitOneAsync(timeout);
return Task.WhenAny(t1, t2);
}
- public static async Task WaitOneAsync(this WaitHandle handle, TimeSpan timeout) {
+ public static async Task WaitOneAsync(this WaitHandle handle, TimeSpan timeout)
+ {
RegisteredWaitHandle registeredHandle = null;
- try {
+ try
+ {
var tcs = new TaskCompletionSource();
registeredHandle = ThreadPool.RegisterWaitForSingleObject(
handle,
@@ -28,11 +29,13 @@ namespace Cap.Consistency.Infrastructure
true);
return await tcs.Task;
}
- finally {
- if (registeredHandle != null) {
+ finally
+ {
+ if (registeredHandle != null)
+ {
registeredHandle.Unregister(null);
}
}
}
}
-}
+}
\ No newline at end of file
diff --git a/src/Cap.Consistency/Internal/ConsumerExcutorSelector.cs b/src/DotNetCore.CAP/Internal/ConsumerExcutorSelector.cs
similarity index 68%
rename from src/Cap.Consistency/Internal/ConsumerExcutorSelector.cs
rename to src/DotNetCore.CAP/Internal/ConsumerExcutorSelector.cs
index 25ebe36..14bfece 100644
--- a/src/Cap.Consistency/Internal/ConsumerExcutorSelector.cs
+++ b/src/DotNetCore.CAP/Internal/ConsumerExcutorSelector.cs
@@ -2,39 +2,41 @@
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
-using System.Text;
-using Cap.Consistency.Abstractions;
-using Cap.Consistency.Consumer;
-using Cap.Consistency.Infrastructure;
+using DotNetCore.CAP.Abstractions;
+using DotNetCore.CAP.Infrastructure;
using Microsoft.Extensions.DependencyInjection;
-namespace Cap.Consistency.Internal
+namespace DotNetCore.CAP.Internal
{
public class ConsumerExcutorSelector : IConsumerExcutorSelector
{
private readonly IServiceProvider _serviceProvider;
- public ConsumerExcutorSelector(IServiceProvider serviceProvider) {
+ public ConsumerExcutorSelector(IServiceProvider serviceProvider)
+ {
_serviceProvider = serviceProvider;
}
- public ConsumerExecutorDescriptor SelectBestCandidate(string key, IReadOnlyList executeDescriptor) {
+ public ConsumerExecutorDescriptor SelectBestCandidate(string key, IReadOnlyList executeDescriptor)
+ {
return executeDescriptor.FirstOrDefault(x => x.Attribute.Name == key);
}
- public IReadOnlyList SelectCandidates(TopicContext context) {
-
+ public IReadOnlyList SelectCandidates(TopicContext context)
+ {
var consumerServices = context.ServiceProvider.GetServices();
var executorDescriptorList = new List();
- foreach (var service in consumerServices) {
+ foreach (var service in consumerServices)
+ {
var typeInfo = service.GetType().GetTypeInfo();
- if (!typeof(IConsumerService).GetTypeInfo().IsAssignableFrom(typeInfo)) {
+ if (!typeof(IConsumerService).GetTypeInfo().IsAssignableFrom(typeInfo))
+ {
continue;
}
- foreach (var method in typeInfo.DeclaredMethods) {
-
+ foreach (var method in typeInfo.DeclaredMethods)
+ {
var topicAttr = method.GetCustomAttribute(true);
if (topicAttr == null) continue;
@@ -44,16 +46,20 @@ namespace Cap.Consistency.Internal
return executorDescriptorList;
}
- private ConsumerExecutorDescriptor InitDescriptor(TopicAttribute attr,
- MethodInfo methodInfo, TypeInfo implType
- ) {
- var descriptor = new ConsumerExecutorDescriptor();
- descriptor.Attribute = attr;
- descriptor.MethodInfo = methodInfo;
- descriptor.ImplTypeInfo = implType;
+ private ConsumerExecutorDescriptor InitDescriptor(
+ TopicAttribute attr,
+ MethodInfo methodInfo,
+ TypeInfo implType)
+ {
+ var descriptor = new ConsumerExecutorDescriptor()
+ {
+ Attribute = attr,
+ MethodInfo = methodInfo,
+ ImplTypeInfo = implType
+ };
return descriptor;
}
}
-}
+}
\ No newline at end of file
diff --git a/src/Cap.Consistency/Internal/ConsumerInvoker.cs b/src/DotNetCore.CAP/Internal/ConsumerInvoker.cs
similarity index 81%
rename from src/Cap.Consistency/Internal/ConsumerInvoker.cs
rename to src/DotNetCore.CAP/Internal/ConsumerInvoker.cs
index 1960591..6d52d20 100644
--- a/src/Cap.Consistency/Internal/ConsumerInvoker.cs
+++ b/src/DotNetCore.CAP/Internal/ConsumerInvoker.cs
@@ -1,15 +1,12 @@
using System;
-using System.Collections.Generic;
-using System.Reflection;
using System.Text;
using System.Threading.Tasks;
-using Cap.Consistency.Abstractions;
-using Cap.Consistency.Abstractions.ModelBinding;
+using DotNetCore.CAP.Abstractions;
+using DotNetCore.CAP.Abstractions.ModelBinding;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
-using Newtonsoft.Json;
-namespace Cap.Consistency.Internal
+namespace DotNetCore.CAP.Internal
{
public class ConsumerInvoker : IConsumerInvoker
{
@@ -22,8 +19,8 @@ namespace Cap.Consistency.Internal
public ConsumerInvoker(ILogger logger,
IServiceProvider serviceProvider,
IModelBinder modelBinder,
- ConsumerContext consumerContext) {
-
+ ConsumerContext consumerContext)
+ {
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
_serviceProvider = serviceProvider;
_modelBinder = modelBinder;
@@ -32,43 +29,45 @@ namespace Cap.Consistency.Internal
_consumerContext.ConsumerDescriptor.ImplTypeInfo);
}
-
- public Task InvokeAsync() {
- try {
- using (_logger.BeginScope("consumer invoker begin")) {
-
+ public Task InvokeAsync()
+ {
+ try
+ {
+ using (_logger.BeginScope("consumer invoker begin"))
+ {
_logger.LogDebug("Executing consumer Topic: {0}", _consumerContext.ConsumerDescriptor.Attribute);
- try {
+ try
+ {
var obj = ActivatorUtilities.GetServiceOrCreateInstance(_serviceProvider, _consumerContext.ConsumerDescriptor.ImplTypeInfo.AsType());
var bodyString = Encoding.UTF8.GetString(_consumerContext.DeliverMessage.Body);
- if (_executor.MethodParameters.Length > 0) {
+ if (_executor.MethodParameters.Length > 0)
+ {
var firstParameter = _executor.MethodParameters[0];
- var bindingContext = ModelBindingContext.CreateBindingContext(bodyString,
+ var bindingContext = ModelBindingContext.CreateBindingContext(bodyString,
firstParameter.Name, firstParameter.ParameterType);
_modelBinder.BindModelAsync(bindingContext);
_executor.Execute(obj, bindingContext.Result);
-
}
- else {
+ else
+ {
_executor.Execute(obj);
}
return Task.CompletedTask;
}
- finally {
-
+ finally
+ {
_logger.LogDebug("Executed consumer method .");
}
}
}
- finally {
-
+ finally
+ {
}
}
-
}
-}
+}
\ No newline at end of file
diff --git a/src/Cap.Consistency/Internal/ConsumerInvokerFactory.cs b/src/DotNetCore.CAP/Internal/ConsumerInvokerFactory.cs
similarity index 75%
rename from src/Cap.Consistency/Internal/ConsumerInvokerFactory.cs
rename to src/DotNetCore.CAP/Internal/ConsumerInvokerFactory.cs
index 2659969..37349df 100644
--- a/src/Cap.Consistency/Internal/ConsumerInvokerFactory.cs
+++ b/src/DotNetCore.CAP/Internal/ConsumerInvokerFactory.cs
@@ -1,12 +1,10 @@
using System;
-using System.Collections.Generic;
-using System.Text;
-using Cap.Consistency.Abstractions;
-using Cap.Consistency.Abstractions.ModelBinding;
-using Cap.Consistency.Infrastructure;
+using DotNetCore.CAP.Abstractions;
+using DotNetCore.CAP.Abstractions.ModelBinding;
+using DotNetCore.CAP.Infrastructure;
using Microsoft.Extensions.Logging;
-namespace Cap.Consistency.Internal
+namespace DotNetCore.CAP.Internal
{
public class ConsumerInvokerFactory : IConsumerInvokerFactory
{
@@ -17,15 +15,15 @@ namespace Cap.Consistency.Internal
public ConsumerInvokerFactory(
ILoggerFactory loggerFactory,
IModelBinder modelBinder,
- IServiceProvider serviceProvider) {
-
+ IServiceProvider serviceProvider)
+ {
_logger = loggerFactory.CreateLogger();
_modelBinder = modelBinder;
_serviceProvider = serviceProvider;
}
- public IConsumerInvoker CreateInvoker(ConsumerContext consumerContext) {
-
+ public IConsumerInvoker CreateInvoker(ConsumerContext consumerContext)
+ {
var context = new ConsumerInvokerContext(consumerContext);
context.Result = new ConsumerInvoker(_logger, _serviceProvider, _modelBinder, consumerContext);
@@ -33,4 +31,4 @@ namespace Cap.Consistency.Internal
return context.Result;
}
}
-}
+}
\ No newline at end of file
diff --git a/src/Cap.Consistency/Internal/ConsumerMethodExecutor.cs b/src/DotNetCore.CAP/Internal/ConsumerMethodExecutor.cs
similarity index 72%
rename from src/Cap.Consistency/Internal/ConsumerMethodExecutor.cs
rename to src/DotNetCore.CAP/Internal/ConsumerMethodExecutor.cs
index cd04476..b33cc71 100644
--- a/src/Cap.Consistency/Internal/ConsumerMethodExecutor.cs
+++ b/src/DotNetCore.CAP/Internal/ConsumerMethodExecutor.cs
@@ -1,26 +1,28 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
+using System.Collections.Generic;
-namespace Cap.Consistency.Internal
+namespace DotNetCore.CAP.Internal
{
public class ConsumerMethodExecutor
{
public static object[] PrepareArguments(
IDictionary actionParameters,
- ObjectMethodExecutor actionMethodExecutor) {
+ ObjectMethodExecutor actionMethodExecutor)
+ {
var declaredParameterInfos = actionMethodExecutor.MethodParameters;
var count = declaredParameterInfos.Length;
- if (count == 0) {
+ if (count == 0)
+ {
return null;
}
var arguments = new object[count];
- for (var index = 0; index < count; index++) {
+ for (var index = 0; index < count; index++)
+ {
var parameterInfo = declaredParameterInfos[index];
object value;
- if (!actionParameters.TryGetValue(parameterInfo.Name, out value)) {
+ if (!actionParameters.TryGetValue(parameterInfo.Name, out value))
+ {
value = actionMethodExecutor.GetDefaultValueForParameter(index);
}
@@ -30,4 +32,4 @@ namespace Cap.Consistency.Internal
return arguments;
}
}
-}
+}
\ No newline at end of file
diff --git a/src/Cap.Consistency/Internal/DefaultModelBinder.cs b/src/DotNetCore.CAP/Internal/DefaultModelBinder.cs
similarity index 76%
rename from src/Cap.Consistency/Internal/DefaultModelBinder.cs
rename to src/DotNetCore.CAP/Internal/DefaultModelBinder.cs
index b9ba0df..d162ccc 100644
--- a/src/Cap.Consistency/Internal/DefaultModelBinder.cs
+++ b/src/DotNetCore.CAP/Internal/DefaultModelBinder.cs
@@ -1,39 +1,40 @@
using System;
-using System.Collections.Generic;
using System.Linq.Expressions;
using System.Reflection;
-using System.Text;
using System.Threading.Tasks;
-using Cap.Consistency.Abstractions.ModelBinding;
+using DotNetCore.CAP.Abstractions.ModelBinding;
using Newtonsoft.Json;
-namespace Cap.Consistency.Internal
+namespace DotNetCore.CAP.Internal
{
public class DefaultModelBinder : IModelBinder
{
private Func
/// The minute in which the schedule will be activated (0-59).
- public static string Hourly(int minute) {
+ public static string Hourly(int minute)
+ {
return string.Format("{0} * * * *", minute);
}
///
/// Returns cron expression that fires every day at 00:00 UTC.
///
- public static string Daily() {
+ public static string Daily()
+ {
return Daily(hour: 0);
}
@@ -40,7 +42,8 @@ namespace Cap.Consistency.Job
/// the specified hour in UTC.
///
/// The hour in which the schedule will be activated (0-23).
- public static string Daily(int hour) {
+ public static string Daily(int hour)
+ {
return Daily(hour, minute: 0);
}
@@ -50,14 +53,16 @@ namespace Cap.Consistency.Job
///
/// The hour in which the schedule will be activated (0-23).
/// The minute in which the schedule will be activated (0-59).
- public static string Daily(int hour, int minute) {
+ public static string Daily(int hour, int minute)
+ {
return string.Format("{0} {1} * * *", minute, hour);
}
///
/// Returns cron expression that fires every week at Monday, 00:00 UTC.
///
- public static string Weekly() {
+ public static string Weekly()
+ {
return Weekly(DayOfWeek.Monday);
}
@@ -66,7 +71,8 @@ namespace Cap.Consistency.Job
/// day of the week.
///
/// The day of week in which the schedule will be activated.
- public static string Weekly(DayOfWeek dayOfWeek) {
+ public static string Weekly(DayOfWeek dayOfWeek)
+ {
return Weekly(dayOfWeek, hour: 0);
}
@@ -76,7 +82,8 @@ namespace Cap.Consistency.Job
///
/// The day of week in which the schedule will be activated.
/// The hour in which the schedule will be activated (0-23).
- public static string Weekly(DayOfWeek dayOfWeek, int hour) {
+ public static string Weekly(DayOfWeek dayOfWeek, int hour)
+ {
return Weekly(dayOfWeek, hour, minute: 0);
}
@@ -87,7 +94,8 @@ namespace Cap.Consistency.Job
/// The day of week in which the schedule will be activated.
/// The hour in which the schedule will be activated (0-23).
/// The minute in which the schedule will be activated (0-59).
- public static string Weekly(DayOfWeek dayOfWeek, int hour, int minute) {
+ public static string Weekly(DayOfWeek dayOfWeek, int hour, int minute)
+ {
return string.Format("{0} {1} * * {2}", minute, hour, (int)dayOfWeek);
}
@@ -95,7 +103,8 @@ namespace Cap.Consistency.Job
/// Returns cron expression that fires every month at 00:00 UTC of the first
/// day of month.
///
- public static string Monthly() {
+ public static string Monthly()
+ {
return Monthly(day: 1);
}
@@ -104,7 +113,8 @@ namespace Cap.Consistency.Job
/// day of month.
///
/// The day of month in which the schedule will be activated (1-31).
- public static string Monthly(int day) {
+ public static string Monthly(int day)
+ {
return Monthly(day, hour: 0);
}
@@ -114,7 +124,8 @@ namespace Cap.Consistency.Job
///
/// The day of month in which the schedule will be activated (1-31).
/// The hour in which the schedule will be activated (0-23).
- public static string Monthly(int day, int hour) {
+ public static string Monthly(int day, int hour)
+ {
return Monthly(day, hour, minute: 0);
}
@@ -125,14 +136,16 @@ namespace Cap.Consistency.Job
/// The day of month in which the schedule will be activated (1-31).
/// The hour in which the schedule will be activated (0-23).
/// The minute in which the schedule will be activated (0-59).
- public static string Monthly(int day, int hour, int minute) {
+ public static string Monthly(int day, int hour, int minute)
+ {
return string.Format("{0} {1} {2} * *", minute, hour, day);
}
///
/// Returns cron expression that fires every year on Jan, 1st at 00:00 UTC.
///
- public static string Yearly() {
+ public static string Yearly()
+ {
return Yearly(month: 1);
}
@@ -141,7 +154,8 @@ namespace Cap.Consistency.Job
/// of the specified month.
///
/// The month in which the schedule will be activated (1-12).
- public static string Yearly(int month) {
+ public static string Yearly(int month)
+ {
return Yearly(month, day: 1);
}
@@ -151,7 +165,8 @@ namespace Cap.Consistency.Job
///
/// The month in which the schedule will be activated (1-12).
/// The day of month in which the schedule will be activated (1-31).
- public static string Yearly(int month, int day) {
+ public static string Yearly(int month, int day)
+ {
return Yearly(month, day, hour: 0);
}
@@ -162,7 +177,8 @@ namespace Cap.Consistency.Job
/// The month in which the schedule will be activated (1-12).
/// The day of month in which the schedule will be activated (1-31).
/// The hour in which the schedule will be activated (0-23).
- public static string Yearly(int month, int day, int hour) {
+ public static string Yearly(int month, int day, int hour)
+ {
return Yearly(month, day, hour, minute: 0);
}
@@ -174,8 +190,9 @@ namespace Cap.Consistency.Job
/// The day of month in which the schedule will be activated (1-31).
/// The hour in which the schedule will be activated (0-23).
/// The minute in which the schedule will be activated (0-59).
- public static string Yearly(int month, int day, int hour, int minute) {
+ public static string Yearly(int month, int day, int hour, int minute)
+ {
return string.Format("{0} {1} {2} {3} *", minute, hour, day, month);
}
}
-}
+}
\ No newline at end of file
diff --git a/src/Cap.Consistency/Job/CronJob.cs b/src/DotNetCore.CAP/Job/CronJob.cs
similarity index 79%
rename from src/Cap.Consistency/Job/CronJob.cs
rename to src/DotNetCore.CAP/Job/CronJob.cs
index f85c529..f05fd50 100644
--- a/src/Cap.Consistency/Job/CronJob.cs
+++ b/src/DotNetCore.CAP/Job/CronJob.cs
@@ -1,25 +1,26 @@
using System;
-using System.Collections.Generic;
-using System.Text;
-namespace Cap.Consistency.Job
+namespace DotNetCore.CAP.Job
{
///
/// Represents a cron job to be executed at specified intervals of time.
///
public class CronJob
{
- public CronJob() {
+ public CronJob()
+ {
Id = Guid.NewGuid().ToString();
}
public CronJob(string cron)
- : this() {
+ : this()
+ {
Cron = cron;
}
public CronJob(string cron, DateTime lastRun)
- : this(cron) {
+ : this(cron)
+ {
LastRun = lastRun;
}
@@ -33,4 +34,4 @@ namespace Cap.Consistency.Job
public DateTime LastRun { get; set; }
}
-}
+}
\ No newline at end of file
diff --git a/src/Cap.Consistency/Job/CronJobRegistry.Default.cs b/src/DotNetCore.CAP/Job/CronJobRegistry.Default.cs
similarity index 71%
rename from src/Cap.Consistency/Job/CronJobRegistry.Default.cs
rename to src/DotNetCore.CAP/Job/CronJobRegistry.Default.cs
index 4f6345c..e124f73 100644
--- a/src/Cap.Consistency/Job/CronJobRegistry.Default.cs
+++ b/src/DotNetCore.CAP/Job/CronJobRegistry.Default.cs
@@ -1,19 +1,17 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using Cap.Consistency.Infrastructure;
+using DotNetCore.CAP.Infrastructure;
using Microsoft.Extensions.Options;
-namespace Cap.Consistency.Job
+namespace DotNetCore.CAP.Job
{
public class DefaultCronJobRegistry : CronJobRegistry
{
private readonly ConsistencyOptions _options;
- public DefaultCronJobRegistry(IOptions options) {
+ public DefaultCronJobRegistry(IOptions options)
+ {
_options = options.Value;
RegisterJob(nameof(DefaultCronJobRegistry), _options.CronExp, RetryBehavior.DefaultRetry);
}
}
-}
+}
\ No newline at end of file
diff --git a/src/Cap.Consistency/Job/CronJobRegistry.cs b/src/DotNetCore.CAP/Job/CronJobRegistry.cs
similarity index 90%
rename from src/Cap.Consistency/Job/CronJobRegistry.cs
rename to src/DotNetCore.CAP/Job/CronJobRegistry.cs
index b87abad..8647ad9 100644
--- a/src/Cap.Consistency/Job/CronJobRegistry.cs
+++ b/src/DotNetCore.CAP/Job/CronJobRegistry.cs
@@ -1,21 +1,22 @@
using System;
using System.Collections.Generic;
using System.Reflection;
-using System.Text;
using NCrontab;
-namespace Cap.Consistency.Job
+namespace DotNetCore.CAP.Job
{
public abstract class CronJobRegistry
{
private List _entries;
- public CronJobRegistry() {
+ public CronJobRegistry()
+ {
_entries = new List();
}
protected void RegisterJob(string name, string cron, RetryBehavior retryBehavior = null)
- where T : IJob {
+ where T : IJob
+ {
RegisterJob(name, typeof(T), cron, retryBehavior);
}
@@ -26,7 +27,8 @@ namespace Cap.Consistency.Job
/// The job's type.
/// The cron expression to use.
/// The to use.
- protected void RegisterJob(string name, Type jobType, string cron, RetryBehavior retryBehavior = null) {
+ protected void RegisterJob(string name, Type jobType, string cron, RetryBehavior retryBehavior = null)
+ {
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException(nameof(cron));
if (jobType == null) throw new ArgumentNullException(nameof(jobType));
if (cron == null) throw new ArgumentNullException(nameof(cron));
@@ -34,7 +36,8 @@ namespace Cap.Consistency.Job
CrontabSchedule.TryParse(cron);
- if (!typeof(IJob).GetTypeInfo().IsAssignableFrom(jobType)) {
+ if (!typeof(IJob).GetTypeInfo().IsAssignableFrom(jobType))
+ {
throw new ArgumentException(
"Cron jobs should extend IJob.", nameof(jobType));
}
@@ -46,7 +49,8 @@ namespace Cap.Consistency.Job
public class Entry
{
- public Entry(string name, Type jobType, string cron) {
+ public Entry(string name, Type jobType, string cron)
+ {
Name = name;
JobType = jobType;
Cron = cron;
@@ -61,4 +65,4 @@ namespace Cap.Consistency.Job
public RetryBehavior RetryBehavior { get; set; }
}
}
-}
+}
\ No newline at end of file
diff --git a/src/Cap.Consistency/Job/IJob.CapJob.cs b/src/DotNetCore.CAP/Job/IJob.CapJob.cs
similarity index 63%
rename from src/Cap.Consistency/Job/IJob.CapJob.cs
rename to src/DotNetCore.CAP/Job/IJob.CapJob.cs
index 0c6a4f4..08a3c59 100644
--- a/src/Cap.Consistency/Job/IJob.CapJob.cs
+++ b/src/DotNetCore.CAP/Job/IJob.CapJob.cs
@@ -1,18 +1,15 @@
using System;
-using System.Collections.Generic;
-using System.Text;
using System.Threading.Tasks;
-namespace Cap.Consistency.Job
+namespace DotNetCore.CAP.Job
{
public class CapJob : IJob
{
-
- public Task ExecuteAsync() {
-
+ public Task ExecuteAsync()
+ {
Console.WriteLine("当前时间:" + DateTime.Now.ToString());
return Task.CompletedTask;
}
}
-}
+}
\ No newline at end of file
diff --git a/src/Cap.Consistency/Job/IJob.cs b/src/DotNetCore.CAP/Job/IJob.cs
similarity index 52%
rename from src/Cap.Consistency/Job/IJob.cs
rename to src/DotNetCore.CAP/Job/IJob.cs
index f72c614..64518ad 100644
--- a/src/Cap.Consistency/Job/IJob.cs
+++ b/src/DotNetCore.CAP/Job/IJob.cs
@@ -1,9 +1,6 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-using System.Threading.Tasks;
+using System.Threading.Tasks;
-namespace Cap.Consistency.Job
+namespace DotNetCore.CAP.Job
{
public interface IJob
{
@@ -12,4 +9,4 @@ namespace Cap.Consistency.Job
///
Task ExecuteAsync();
}
-}
+}
\ No newline at end of file
diff --git a/src/Cap.Consistency/Job/IProcessingServer.Job.cs b/src/DotNetCore.CAP/Job/IProcessingServer.Job.cs
similarity index 80%
rename from src/Cap.Consistency/Job/IProcessingServer.Job.cs
rename to src/DotNetCore.CAP/Job/IProcessingServer.Job.cs
index a91ac88..bffbc83 100644
--- a/src/Cap.Consistency/Job/IProcessingServer.Job.cs
+++ b/src/DotNetCore.CAP/Job/IProcessingServer.Job.cs
@@ -3,13 +3,13 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
-using Cap.Consistency.Infrastructure;
-using Cap.Consistency.Job;
+using DotNetCore.CAP.Infrastructure;
+using DotNetCore.CAP.Job;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
-namespace Cap.Consistency
+namespace DotNetCore.CAP
{
public class JobProcessingServer : IProcessingServer, IDisposable
{
@@ -29,8 +29,8 @@ namespace Cap.Consistency
ILoggerFactory loggerFactory,
IServiceProvider provider,
DefaultCronJobRegistry defaultJobRegistry,
- IOptions options) {
-
+ IOptions options)
+ {
_logger = logger;
_loggerFactory = loggerFactory;
_provider = provider;
@@ -39,8 +39,8 @@ namespace Cap.Consistency
_cts = new CancellationTokenSource();
}
- public void Start() {
-
+ public void Start()
+ {
var processorCount = Environment.ProcessorCount;
processorCount = 1;
_processors = GetProcessors(processorCount);
@@ -57,40 +57,50 @@ namespace Cap.Consistency
_compositeTask = Task.WhenAll(processorTasks);
}
- public void Dispose() {
- if (_disposed) {
+ public void Dispose()
+ {
+ if (_disposed)
+ {
return;
}
_disposed = true;
_logger.ServerShuttingDown();
_cts.Cancel();
- try {
+ try
+ {
_compositeTask.Wait((int)TimeSpan.FromSeconds(60).TotalMilliseconds);
}
- catch (AggregateException ex) {
+ catch (AggregateException ex)
+ {
var innerEx = ex.InnerExceptions[0];
- if (!(innerEx is OperationCanceledException)) {
+ if (!(innerEx is OperationCanceledException))
+ {
_logger.ExpectedOperationCanceledException(innerEx);
}
}
}
- private IJobProcessor InfiniteRetry(IJobProcessor inner) {
+ private IJobProcessor InfiniteRetry(IJobProcessor inner)
+ {
return new InfiniteRetryProcessor(inner, _loggerFactory);
}
- private IJobProcessor[] GetProcessors(int processorCount) {
-
+ private IJobProcessor[] GetProcessors(int processorCount)
+ {
var returnedProcessors = new List();
- for (int i = 0; i < processorCount; i++) {
+ for (int i = 0; i < processorCount; i++)
+ {
var processors = _provider.GetServices();
- foreach (var processor in processors) {
- if (processor is CronJobProcessor) {
+ foreach (var processor in processors)
+ {
+ if (processor is CronJobProcessor)
+ {
if (i == 0) // only add first cronJob
returnedProcessors.Add(processor);
}
- else {
+ else
+ {
returnedProcessors.Add(processor);
}
}
@@ -99,4 +109,4 @@ namespace Cap.Consistency
return returnedProcessors.ToArray();
}
}
-}
+}
\ No newline at end of file
diff --git a/src/Cap.Consistency/Job/IProcessor.CronJob.cs b/src/DotNetCore.CAP/Job/IProcessor.CronJob.cs
similarity index 81%
rename from src/Cap.Consistency/Job/IProcessor.CronJob.cs
rename to src/DotNetCore.CAP/Job/IProcessor.CronJob.cs
index 3c35350..423e64e 100644
--- a/src/Cap.Consistency/Job/IProcessor.CronJob.cs
+++ b/src/DotNetCore.CAP/Job/IProcessor.CronJob.cs
@@ -2,12 +2,11 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
-using System.Text;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
-namespace Cap.Consistency.Job
+namespace DotNetCore.CAP.Job
{
public class CronJobProcessor : IJobProcessor
{
@@ -18,8 +17,8 @@ namespace Cap.Consistency.Job
public CronJobProcessor(
DefaultCronJobRegistry jobRegistry,
ILogger logger,
- IServiceProvider provider) {
-
+ IServiceProvider provider)
+ {
_jobRegistry = jobRegistry;
_logger = logger;
_provider = provider;
@@ -27,17 +26,20 @@ namespace Cap.Consistency.Job
public override string ToString() => nameof(CronJobProcessor);
- public Task ProcessAsync(ProcessingContext context) {
+ public Task ProcessAsync(ProcessingContext context)
+ {
if (context == null) throw new ArgumentNullException(nameof(context));
return ProcessCoreAsync(context);
}
- private async Task ProcessCoreAsync(ProcessingContext context) {
+ private async Task ProcessCoreAsync(ProcessingContext context)
+ {
//var storage = context.Storage;
//var jobs = await GetJobsAsync(storage);
var jobs = GetJobs();
- if (!jobs.Any()) {
+ if (!jobs.Any())
+ {
_logger.CronJobsNotFound();
// This will cancel this processor.
@@ -48,52 +50,61 @@ namespace Cap.Consistency.Job
context.ThrowIfStopping();
var computedJobs = Compute(jobs, context.CronJobRegistry.Build());
- if (context.IsStopping) {
+ if (context.IsStopping)
+ {
return;
}
await Task.WhenAll(computedJobs.Select(j => RunAsync(j, context)));
}
- private async Task RunAsync(ComputedCronJob computedJob, ProcessingContext context) {
+ private async Task RunAsync(ComputedCronJob computedJob, ProcessingContext context)
+ {
//var storage = context.Storage;
var retryBehavior = computedJob.RetryBehavior;
- while (!context.IsStopping) {
+ while (!context.IsStopping)
+ {
var now = DateTime.UtcNow;
var due = ComputeDue(computedJob, now);
var timeSpan = due - now;
- if (timeSpan.TotalSeconds > 0) {
+ if (timeSpan.TotalSeconds > 0)
+ {
await context.WaitAsync(timeSpan);
}
context.ThrowIfStopping();
- using (var scopedContext = context.CreateScope()) {
+ using (var scopedContext = context.CreateScope())
+ {
var provider = scopedContext.Provider;
var job = provider.GetService();
var success = true;
- try {
+ try
+ {
var sw = Stopwatch.StartNew();
await job.ExecuteAsync();
sw.Stop();
computedJob.Retries = 0;
_logger.CronJobExecuted(computedJob.Job.Name, sw.Elapsed.TotalSeconds);
}
- catch (Exception ex) {
+ catch (Exception ex)
+ {
success = false;
- if (computedJob.Retries == 0) {
+ if (computedJob.Retries == 0)
+ {
computedJob.FirstTry = DateTime.UtcNow;
}
computedJob.Retries++;
_logger.CronJobFailed(computedJob.Job.Name, ex);
}
- if (success) {
+ if (success)
+ {
//var connection = provider.GetRequiredService();
//await connection.AttachCronJobAsync(computedJob.Job);
@@ -105,24 +116,28 @@ namespace Cap.Consistency.Job
}
}
- private DateTime ComputeDue(ComputedCronJob computedJob, DateTime now) {
+ private DateTime ComputeDue(ComputedCronJob computedJob, DateTime now)
+ {
computedJob.UpdateNext(now);
var retryBehavior = computedJob.RetryBehavior ?? RetryBehavior.DefaultRetry;
var retries = computedJob.Retries;
- if (retries == 0) {
+ if (retries == 0)
+ {
return computedJob.Next;
}
var realNext = computedJob.Schedule.GetNextOccurrence(now);
- if (!retryBehavior.Retry) {
+ if (!retryBehavior.Retry)
+ {
// No retry. If job failed before, we don't care, just schedule it next as usual.
return realNext;
}
- if (retries >= retryBehavior.RetryCount) {
+ if (retries >= retryBehavior.RetryCount)
+ {
// Max retries. Just schedule it for the next occurance.
return realNext;
}
@@ -131,11 +146,14 @@ namespace Cap.Consistency.Job
return computedJob.FirstTry.AddSeconds(retryBehavior.RetryIn(retries));
}
- private CronJob[] GetJobs() {
+ private CronJob[] GetJobs()
+ {
var cronJobs = new List();
var entries = _jobRegistry.Build() ?? new CronJobRegistry.Entry[0];
- foreach (var entry in entries) {
- cronJobs.Add(new CronJob {
+ foreach (var entry in entries)
+ {
+ cronJobs.Add(new CronJob
+ {
Name = entry.Name,
TypeName = entry.JobType.AssemblyQualifiedName,
Cron = entry.Cron,
@@ -148,9 +166,10 @@ namespace Cap.Consistency.Job
private ComputedCronJob[] Compute(IEnumerable jobs, CronJobRegistry.Entry[] entries)
=> jobs.Select(j => CreateComputedCronJob(j, entries)).ToArray();
- private ComputedCronJob CreateComputedCronJob(CronJob job, CronJobRegistry.Entry[] entries) {
+ private ComputedCronJob CreateComputedCronJob(CronJob job, CronJobRegistry.Entry[] entries)
+ {
var entry = entries.First(e => e.Name == job.Name);
return new ComputedCronJob(job, entry);
}
}
-}
+}
\ No newline at end of file
diff --git a/src/Cap.Consistency/Job/IProcessor.InfiniteRetry.cs b/src/DotNetCore.CAP/Job/IProcessor.InfiniteRetry.cs
similarity index 74%
rename from src/Cap.Consistency/Job/IProcessor.InfiniteRetry.cs
rename to src/DotNetCore.CAP/Job/IProcessor.InfiniteRetry.cs
index 5147241..90c61f3 100644
--- a/src/Cap.Consistency/Job/IProcessor.InfiniteRetry.cs
+++ b/src/DotNetCore.CAP/Job/IProcessor.InfiniteRetry.cs
@@ -1,10 +1,8 @@
using System;
-using System.Collections.Generic;
-using System.Text;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
-namespace Cap.Consistency.Job
+namespace DotNetCore.CAP.Job
{
public class InfiniteRetryProcessor : IJobProcessor
{
@@ -13,22 +11,28 @@ namespace Cap.Consistency.Job
public InfiniteRetryProcessor(
IJobProcessor inner,
- ILoggerFactory loggerFactory) {
+ ILoggerFactory loggerFactory)
+ {
_inner = inner;
_logger = loggerFactory.CreateLogger();
}
public override string ToString() => _inner.ToString();
- public async Task ProcessAsync(ProcessingContext context) {
- while (!context.IsStopping) {
- try {
+ public async Task ProcessAsync(ProcessingContext context)
+ {
+ while (!context.IsStopping)
+ {
+ try
+ {
await _inner.ProcessAsync(context);
}
- catch (OperationCanceledException) {
+ catch (OperationCanceledException)
+ {
return;
}
- catch (Exception ex) {
+ catch (Exception ex)
+ {
_logger.LogWarning(
1,
ex,
@@ -37,4 +41,4 @@ namespace Cap.Consistency.Job
}
}
}
-}
+}
\ No newline at end of file
diff --git a/src/DotNetCore.CAP/Job/IProcessor.cs b/src/DotNetCore.CAP/Job/IProcessor.cs
new file mode 100644
index 0000000..d7ffc76
--- /dev/null
+++ b/src/DotNetCore.CAP/Job/IProcessor.cs
@@ -0,0 +1,9 @@
+using System.Threading.Tasks;
+
+namespace DotNetCore.CAP.Job
+{
+ public interface IJobProcessor
+ {
+ Task ProcessAsync(ProcessingContext context);
+ }
+}
\ No newline at end of file
diff --git a/src/Cap.Consistency/Job/ProcessingContext.cs b/src/DotNetCore.CAP/Job/ProcessingContext.cs
similarity index 75%
rename from src/Cap.Consistency/Job/ProcessingContext.cs
rename to src/DotNetCore.CAP/Job/ProcessingContext.cs
index 65d5fff..6b72073 100644
--- a/src/Cap.Consistency/Job/ProcessingContext.cs
+++ b/src/DotNetCore.CAP/Job/ProcessingContext.cs
@@ -1,31 +1,32 @@
using System;
-using System.Collections.Generic;
-using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
-namespace Cap.Consistency.Job
+namespace DotNetCore.CAP.Job
{
public class ProcessingContext : IDisposable
{
private IServiceScope _scope;
- private ProcessingContext(ProcessingContext other) {
+ private ProcessingContext(ProcessingContext other)
+ {
Provider = other.Provider;
//Storage = other.Storage;
CronJobRegistry = other.CronJobRegistry;
CancellationToken = other.CancellationToken;
}
- public ProcessingContext() {
+ public ProcessingContext()
+ {
}
public ProcessingContext(
IServiceProvider provider,
//IStorage storage,
CronJobRegistry cronJobRegistry,
- CancellationToken cancellationToken) {
+ CancellationToken cancellationToken)
+ {
Provider = provider;
//Storage = storage;
CronJobRegistry = cronJobRegistry;
@@ -44,23 +45,28 @@ namespace Cap.Consistency.Job
public void ThrowIfStopping() => CancellationToken.ThrowIfCancellationRequested();
- public ProcessingContext CreateScope() {
+ public ProcessingContext CreateScope()
+ {
var serviceScope = Provider.CreateScope();
- return new ProcessingContext(this) {
+ return new ProcessingContext(this)
+ {
_scope = serviceScope,
Provider = serviceScope.ServiceProvider
};
}
- public Task WaitAsync(TimeSpan timeout) {
+ public Task WaitAsync(TimeSpan timeout)
+ {
return Task.Delay(timeout, CancellationToken);
}
- public void Dispose() {
- if (_scope != null) {
+ public void Dispose()
+ {
+ if (_scope != null)
+ {
_scope.Dispose();
}
}
}
-}
+}
\ No newline at end of file
diff --git a/src/Cap.Consistency/Job/RetryBehavior.cs b/src/DotNetCore.CAP/Job/RetryBehavior.cs
similarity index 90%
rename from src/Cap.Consistency/Job/RetryBehavior.cs
rename to src/DotNetCore.CAP/Job/RetryBehavior.cs
index 14a5e60..111158e 100644
--- a/src/Cap.Consistency/Job/RetryBehavior.cs
+++ b/src/DotNetCore.CAP/Job/RetryBehavior.cs
@@ -1,8 +1,6 @@
using System;
-using System.Collections.Generic;
-using System.Text;
-namespace Cap.Consistency.Job
+namespace DotNetCore.CAP.Job
{
public class RetryBehavior
{
@@ -16,7 +14,8 @@ namespace Cap.Consistency.Job
private Func _retryInThunk;
- static RetryBehavior() {
+ static RetryBehavior()
+ {
DefaultRetryCount = 25;
DefaultRetryInThunk = retries =>
(int)Math.Round(Math.Pow(retries - 1, 4) + 15 + (_random.Next(30) * (retries)));
@@ -26,7 +25,8 @@ namespace Cap.Consistency.Job
}
public RetryBehavior(bool retry)
- : this(retry, DefaultRetryCount, DefaultRetryInThunk) {
+ : this(retry, DefaultRetryCount, DefaultRetryInThunk)
+ {
}
///
@@ -35,8 +35,10 @@ namespace Cap.Consistency.Job
/// Whether to retry.
/// The maximum retry count.
/// The retry in function to use.
- public RetryBehavior(bool retry, int retryCount, Func retryInThunk) {
- if (retry) {
+ public RetryBehavior(bool retry, int retryCount, Func retryInThunk)
+ {
+ if (retry)
+ {
if (retryCount < 0) throw new ArgumentOutOfRangeException(nameof(retryCount), "Can't be negative.");
}
@@ -62,8 +64,9 @@ namespace Cap.Consistency.Job
///
/// The current retry count.
/// The seconds to delay.
- public int RetryIn(int retries) {
+ public int RetryIn(int retries)
+ {
return _retryInThunk(retries);
}
}
-}
+}
\ No newline at end of file
diff --git a/src/Cap.Consistency/LoggerExtensions.cs b/src/DotNetCore.CAP/LoggerExtensions.cs
similarity index 90%
rename from src/Cap.Consistency/LoggerExtensions.cs
rename to src/DotNetCore.CAP/LoggerExtensions.cs
index 77d0e3a..fe87ef7 100644
--- a/src/Cap.Consistency/LoggerExtensions.cs
+++ b/src/DotNetCore.CAP/LoggerExtensions.cs
@@ -1,10 +1,10 @@
using System;
using System.Collections.Generic;
using System.Linq;
-using Cap.Consistency.Job;
+using DotNetCore.CAP.Job;
using Microsoft.Extensions.Logging;
-namespace Cap.Consistency
+namespace DotNetCore.CAP
{
internal static class LoggerExtensions
{
@@ -17,7 +17,8 @@ namespace Cap.Consistency
private static Action _cronJobExecuted;
private static Action _cronJobFailed;
- static LoggerExtensions() {
+ static LoggerExtensions()
+ {
_serverStarting = LoggerMessage.Define(
LogLevel.Debug,
1,
@@ -52,37 +53,41 @@ namespace Cap.Consistency
LogLevel.Warning,
4,
"Cron job '{jobName}' failed to execute.");
-
-
}
- public static void ServerStarting(this ILogger logger, int machineProcessorCount, int processorCount) {
+ public static void ServerStarting(this ILogger logger, int machineProcessorCount, int processorCount)
+ {
_serverStarting(logger, machineProcessorCount, processorCount, null);
}
- public static void ServerShuttingDown(this ILogger logger) {
+ public static void ServerShuttingDown(this ILogger logger)
+ {
_serverShuttingDown(logger, null);
}
- public static void ExpectedOperationCanceledException(this ILogger logger, Exception ex) {
+ public static void ExpectedOperationCanceledException(this ILogger logger, Exception ex)
+ {
_expectedOperationCanceledException(logger, ex.Message, ex);
}
- public static void CronJobsNotFound(this ILogger logger) {
+ public static void CronJobsNotFound(this ILogger logger)
+ {
_cronJobsNotFound(logger, null);
}
- public static void CronJobsScheduling(this ILogger logger, IEnumerable jobs) {
+ public static void CronJobsScheduling(this ILogger logger, IEnumerable jobs)
+ {
_cronJobsScheduling(logger, jobs.Count(), null);
}
- public static void CronJobExecuted(this ILogger logger, string name, double seconds) {
+ public static void CronJobExecuted(this ILogger logger, string name, double seconds)
+ {
_cronJobExecuted(logger, name, seconds, null);
}
- public static void CronJobFailed(this ILogger logger, string name, Exception ex) {
+ public static void CronJobFailed(this ILogger logger, string name, Exception ex)
+ {
_cronJobFailed(logger, name, ex);
}
-
}
}
\ No newline at end of file
diff --git a/src/Cap.Consistency/OperateResult.cs b/src/DotNetCore.CAP/OperateResult.cs
similarity index 95%
rename from src/Cap.Consistency/OperateResult.cs
rename to src/DotNetCore.CAP/OperateResult.cs
index f51e3dd..eecfcc7 100644
--- a/src/Cap.Consistency/OperateResult.cs
+++ b/src/DotNetCore.CAP/OperateResult.cs
@@ -1,7 +1,7 @@
using System.Collections.Generic;
using System.Linq;
-namespace Cap.Consistency
+namespace DotNetCore.CAP
{
///
/// Represents the result of an consistent message operation.
@@ -37,9 +37,11 @@ namespace Cap.Consistency
///
/// An optional array of s which caused the operation to fail.
/// An indicating a failed operation, with a list of if applicable.
- public static OperateResult Failed(params OperateError[] errors) {
+ public static OperateResult Failed(params OperateError[] errors)
+ {
var result = new OperateResult { Succeeded = false };
- if (errors != null) {
+ if (errors != null)
+ {
result._errors.AddRange(errors);
}
return result;
@@ -53,7 +55,8 @@ namespace Cap.Consistency
/// If the operation was successful the ToString() will return "Succeeded" otherwise it returned
/// "Failed : " followed by a comma delimited list of error codes from its collection, if any.
///
- public override string ToString() {
+ public override string ToString()
+ {
return Succeeded ?
"Succeeded" :
string.Format("{0} : {1}", "Failed", string.Join(",", Errors.Select(x => x.Code).ToList()));
diff --git a/src/Cap.Consistency/TopicContext.cs b/src/DotNetCore.CAP/TopicContext.cs
similarity index 78%
rename from src/Cap.Consistency/TopicContext.cs
rename to src/DotNetCore.CAP/TopicContext.cs
index d24552a..90a3990 100644
--- a/src/Cap.Consistency/TopicContext.cs
+++ b/src/DotNetCore.CAP/TopicContext.cs
@@ -1,22 +1,22 @@
using System;
using System.Threading;
-namespace Cap.Consistency
+namespace DotNetCore.CAP
{
public class TopicContext
{
- public TopicContext() {
-
+ public TopicContext()
+ {
}
- public TopicContext(IServiceProvider provider, CancellationToken cancellationToken) {
+ public TopicContext(IServiceProvider provider, CancellationToken cancellationToken)
+ {
ServiceProvider = provider;
CancellationToken = cancellationToken;
}
-
public IServiceProvider ServiceProvider { get; set; }
public CancellationToken CancellationToken { get; }
}
-}
+}
\ No newline at end of file
diff --git a/test/Cap.Consistency.EntityFrameworkCore.Test/Properties/AssemblyInfo.cs b/test/Cap.Consistency.EntityFrameworkCore.Test/Properties/AssemblyInfo.cs
deleted file mode 100644
index dc7c879..0000000
--- a/test/Cap.Consistency.EntityFrameworkCore.Test/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using System.Reflection;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("Cap.Consistency.EntityFrameworkCore.Test")]
-[assembly: AssemblyTrademark("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("7442c942-1ddc-40e4-8f1b-654e721eaa45")]
\ No newline at end of file
diff --git a/test/Cap.Consistency.EntityFrameworkCore.Test/DbUtil.cs b/test/DotNetCore.CAP.EntityFrameworkCore.Test/DbUtil.cs
similarity index 95%
rename from test/Cap.Consistency.EntityFrameworkCore.Test/DbUtil.cs
rename to test/DotNetCore.CAP.EntityFrameworkCore.Test/DbUtil.cs
index 91482d6..d5fd010 100644
--- a/test/Cap.Consistency.EntityFrameworkCore.Test/DbUtil.cs
+++ b/test/DotNetCore.CAP.EntityFrameworkCore.Test/DbUtil.cs
@@ -2,7 +2,7 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
-namespace Cap.Consistency.EntityFrameworkCore.Test
+namespace DotNetCore.CAP.EntityFrameworkCore.Test
{
public static class DbUtil
{
diff --git a/test/Cap.Consistency.EntityFrameworkCore.Test/DefaultPocoTest.cs b/test/DotNetCore.CAP.EntityFrameworkCore.Test/DefaultPocoTest.cs
similarity index 94%
rename from test/Cap.Consistency.EntityFrameworkCore.Test/DefaultPocoTest.cs
rename to test/DotNetCore.CAP.EntityFrameworkCore.Test/DefaultPocoTest.cs
index 73066d3..da9d022 100644
--- a/test/Cap.Consistency.EntityFrameworkCore.Test/DefaultPocoTest.cs
+++ b/test/DotNetCore.CAP.EntityFrameworkCore.Test/DefaultPocoTest.cs
@@ -1,13 +1,13 @@
//using System.Threading.Tasks;
-//using Cap.Consistency.Infrastructure;
-//using Cap.Consistency.Store;
+//using DotNetCore.CAP.Infrastructure;
+//using DotNetCore.CAP.Store;
//using Microsoft.AspNetCore.Builder.Internal;
//using Microsoft.AspNetCore.Testing.xunit;
//using Microsoft.EntityFrameworkCore;
//using Microsoft.Extensions.DependencyInjection;
//using Xunit;
-//namespace Cap.Consistency.EntityFrameworkCore.Test
+//namespace DotNetCore.CAP.EntityFrameworkCore.Test
//{
// public class DefaultPocoTest : IClassFixture
// {
diff --git a/test/Cap.Consistency.EntityFrameworkCore.Test/Cap.Consistency.EntityFrameworkCore.Test.csproj b/test/DotNetCore.CAP.EntityFrameworkCore.Test/DotNetCore.CAP.EntityFrameworkCore.Test.csproj
similarity index 86%
rename from test/Cap.Consistency.EntityFrameworkCore.Test/Cap.Consistency.EntityFrameworkCore.Test.csproj
rename to test/DotNetCore.CAP.EntityFrameworkCore.Test/DotNetCore.CAP.EntityFrameworkCore.Test.csproj
index 408bff1..5475214 100644
--- a/test/Cap.Consistency.EntityFrameworkCore.Test/Cap.Consistency.EntityFrameworkCore.Test.csproj
+++ b/test/DotNetCore.CAP.EntityFrameworkCore.Test/DotNetCore.CAP.EntityFrameworkCore.Test.csproj
@@ -3,8 +3,8 @@
netcoreapp1.1
true
- Cap.Consistency.EntityFrameworkCore.Test
- Cap.Consistency.EntityFrameworkCore.Test
+ DotNetCore.CAP.EntityFrameworkCore.Test
+ DotNetCore.CAP.EntityFrameworkCore.Test
true
$(PackageTargetFallback);dnxcore50;portable-net451+win8
1.1.1
@@ -18,8 +18,8 @@
-
-
+
+
diff --git a/test/Cap.Consistency.EntityFrameworkCore.Test/MessageStoreTest.cs b/test/DotNetCore.CAP.EntityFrameworkCore.Test/MessageStoreTest.cs
similarity index 95%
rename from test/Cap.Consistency.EntityFrameworkCore.Test/MessageStoreTest.cs
rename to test/DotNetCore.CAP.EntityFrameworkCore.Test/MessageStoreTest.cs
index 36f722d..dbc70ad 100644
--- a/test/Cap.Consistency.EntityFrameworkCore.Test/MessageStoreTest.cs
+++ b/test/DotNetCore.CAP.EntityFrameworkCore.Test/MessageStoreTest.cs
@@ -1,16 +1,16 @@
//using System;
//using System.Linq;
//using System.Threading.Tasks;
-//using Cap.Consistency.Infrastructure;
-//using Cap.Consistency.Store;
-//using Cap.Consistency.Test;
+//using DotNetCore.CAP.Infrastructure;
+//using DotNetCore.CAP.Store;
+//using DotNetCore.CAP.Test;
//using Microsoft.AspNetCore.Testing;
//using Microsoft.AspNetCore.Testing.xunit;
//using Microsoft.EntityFrameworkCore;
//using Microsoft.Extensions.DependencyInjection;
//using Xunit;
-//namespace Cap.Consistency.EntityFrameworkCore.Test
+//namespace DotNetCore.CAP.EntityFrameworkCore.Test
//{
// public class MessageStoreTest : MessageManagerTestBase, IClassFixture
// {
diff --git a/test/Cap.Consistency.EntityFrameworkCore.Test/MessageStoreWithGenericsTest.cs b/test/DotNetCore.CAP.EntityFrameworkCore.Test/MessageStoreWithGenericsTest.cs
similarity index 92%
rename from test/Cap.Consistency.EntityFrameworkCore.Test/MessageStoreWithGenericsTest.cs
rename to test/DotNetCore.CAP.EntityFrameworkCore.Test/MessageStoreWithGenericsTest.cs
index 3275c16..e99ee6a 100644
--- a/test/Cap.Consistency.EntityFrameworkCore.Test/MessageStoreWithGenericsTest.cs
+++ b/test/DotNetCore.CAP.EntityFrameworkCore.Test/MessageStoreWithGenericsTest.cs
@@ -1,12 +1,12 @@
//using System;
-//using Cap.Consistency.Infrastructure;
-//using Cap.Consistency.Store;
-//using Cap.Consistency.Test;
+//using DotNetCore.CAP.Infrastructure;
+//using DotNetCore.CAP.Store;
+//using DotNetCore.CAP.Test;
//using Microsoft.AspNetCore.Testing;
//using Microsoft.Extensions.DependencyInjection;
//using Xunit;
-//namespace Cap.Consistency.EntityFrameworkCore.Test
+//namespace DotNetCore.CAP.EntityFrameworkCore.Test
//{
// public class MessageStoreWithGenericsTest : MessageManagerTestBase, IClassFixture
// {
diff --git a/src/Cap.Consistency.EntityFrameworkCore/Properties/AssemblyInfo.cs b/test/DotNetCore.CAP.EntityFrameworkCore.Test/Properties/AssemblyInfo.cs
similarity index 84%
rename from src/Cap.Consistency.EntityFrameworkCore/Properties/AssemblyInfo.cs
rename to test/DotNetCore.CAP.EntityFrameworkCore.Test/Properties/AssemblyInfo.cs
index 32dd556..a995715 100644
--- a/src/Cap.Consistency.EntityFrameworkCore/Properties/AssemblyInfo.cs
+++ b/test/DotNetCore.CAP.EntityFrameworkCore.Test/Properties/AssemblyInfo.cs
@@ -6,7 +6,7 @@ using System.Runtime.InteropServices;
// associated with an assembly.
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("Cap.Consistency.EntityFrameworkCore")]
+[assembly: AssemblyProduct("DotNetCore.CAP.EntityFrameworkCore.Test")]
[assembly: AssemblyTrademark("")]
// Setting ComVisible to false makes the types in this assembly not visible
@@ -15,4 +15,4 @@ using System.Runtime.InteropServices;
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("96111249-c4c3-4dc9-a887-32d583723ab1")]
\ No newline at end of file
+[assembly: Guid("7442c942-1ddc-40e4-8f1b-654e721eaa45")]
\ No newline at end of file
diff --git a/test/Cap.Consistency.EntityFrameworkCore.Test/Utilities/ScratchDatabaseFixture.cs b/test/DotNetCore.CAP.EntityFrameworkCore.Test/Utilities/ScratchDatabaseFixture.cs
similarity index 91%
rename from test/Cap.Consistency.EntityFrameworkCore.Test/Utilities/ScratchDatabaseFixture.cs
rename to test/DotNetCore.CAP.EntityFrameworkCore.Test/Utilities/ScratchDatabaseFixture.cs
index 1cb0ed9..ed832d2 100644
--- a/test/Cap.Consistency.EntityFrameworkCore.Test/Utilities/ScratchDatabaseFixture.cs
+++ b/test/DotNetCore.CAP.EntityFrameworkCore.Test/Utilities/ScratchDatabaseFixture.cs
@@ -1,7 +1,7 @@
using System;
using Microsoft.EntityFrameworkCore.Internal;
-namespace Cap.Consistency.EntityFrameworkCore.Test
+namespace DotNetCore.CAP.EntityFrameworkCore.Test
{
public class ScratchDatabaseFixture : IDisposable
{
diff --git a/test/Cap.Consistency.EntityFrameworkCore.Test/Utilities/SqlServerTestStore.cs b/test/DotNetCore.CAP.EntityFrameworkCore.Test/Utilities/SqlServerTestStore.cs
similarity index 98%
rename from test/Cap.Consistency.EntityFrameworkCore.Test/Utilities/SqlServerTestStore.cs
rename to test/DotNetCore.CAP.EntityFrameworkCore.Test/Utilities/SqlServerTestStore.cs
index 7130b84..aee9e0e 100644
--- a/test/Cap.Consistency.EntityFrameworkCore.Test/Utilities/SqlServerTestStore.cs
+++ b/test/DotNetCore.CAP.EntityFrameworkCore.Test/Utilities/SqlServerTestStore.cs
@@ -4,7 +4,7 @@ using System.Data.SqlClient;
using System.IO;
using System.Threading;
-namespace Cap.Consistency.EntityFrameworkCore.Test
+namespace DotNetCore.CAP.EntityFrameworkCore.Test
{
public class SqlServerTestStore : IDisposable
{
diff --git a/test/Cap.Consistency.EntityFrameworkCore.Test/Utilities/TestEnvironment.cs b/test/DotNetCore.CAP.EntityFrameworkCore.Test/Utilities/TestEnvironment.cs
similarity index 91%
rename from test/Cap.Consistency.EntityFrameworkCore.Test/Utilities/TestEnvironment.cs
rename to test/DotNetCore.CAP.EntityFrameworkCore.Test/Utilities/TestEnvironment.cs
index 70536d5..328925e 100644
--- a/test/Cap.Consistency.EntityFrameworkCore.Test/Utilities/TestEnvironment.cs
+++ b/test/DotNetCore.CAP.EntityFrameworkCore.Test/Utilities/TestEnvironment.cs
@@ -1,7 +1,7 @@
using System.IO;
using Microsoft.Extensions.Configuration;
-namespace Cap.Consistency.EntityFrameworkCore.Test
+namespace DotNetCore.CAP.EntityFrameworkCore.Test
{
public class TestEnvironment
{
diff --git a/test/Cap.Consistency.EntityFrameworkCore.Test/config.json b/test/DotNetCore.CAP.EntityFrameworkCore.Test/config.json
similarity index 100%
rename from test/Cap.Consistency.EntityFrameworkCore.Test/config.json
rename to test/DotNetCore.CAP.EntityFrameworkCore.Test/config.json
diff --git a/test/Cap.Consistency.Test/ConsistencyBuilderTest.cs b/test/DotNetCore.CAP.Test/ConsistencyBuilderTest.cs
similarity index 94%
rename from test/Cap.Consistency.Test/ConsistencyBuilderTest.cs
rename to test/DotNetCore.CAP.Test/ConsistencyBuilderTest.cs
index cd26072..3613f66 100644
--- a/test/Cap.Consistency.Test/ConsistencyBuilderTest.cs
+++ b/test/DotNetCore.CAP.Test/ConsistencyBuilderTest.cs
@@ -1,12 +1,12 @@
//using System;
//using System.Threading;
//using System.Threading.Tasks;
-//using Cap.Consistency.Infrastructure;
-//using Cap.Consistency.Store;
+//using DotNetCore.CAP.Infrastructure;
+//using DotNetCore.CAP.Store;
//using Microsoft.Extensions.DependencyInjection;
//using Xunit;
-//namespace Cap.Consistency.Test
+//namespace DotNetCore.CAP.Test
//{
// public class ConsistencyBuilderTest
// {
diff --git a/test/Cap.Consistency.Test/ConsistencyMessageManagerTest.cs b/test/DotNetCore.CAP.Test/ConsistencyMessageManagerTest.cs
similarity index 96%
rename from test/Cap.Consistency.Test/ConsistencyMessageManagerTest.cs
rename to test/DotNetCore.CAP.Test/ConsistencyMessageManagerTest.cs
index 726e50f..1c2ba66 100644
--- a/test/Cap.Consistency.Test/ConsistencyMessageManagerTest.cs
+++ b/test/DotNetCore.CAP.Test/ConsistencyMessageManagerTest.cs
@@ -1,15 +1,15 @@
//using System;
//using System.Threading;
//using System.Threading.Tasks;
-//using Cap.Consistency.Infrastructure;
-//using Cap.Consistency.Store;
+//using DotNetCore.CAP.Infrastructure;
+//using DotNetCore.CAP.Store;
//using Microsoft.AspNetCore.Http;
//using Microsoft.Extensions.DependencyInjection;
//using Microsoft.Extensions.Logging;
//using Moq;
//using Xunit;
-//namespace Cap.Consistency.Test
+//namespace DotNetCore.CAP.Test
//{
// public class ConsistencyMessageManagerTest
// {
diff --git a/test/Cap.Consistency.Test/ConsistencyOptionsTest.cs b/test/DotNetCore.CAP.Test/ConsistencyOptionsTest.cs
similarity index 60%
rename from test/Cap.Consistency.Test/ConsistencyOptionsTest.cs
rename to test/DotNetCore.CAP.Test/ConsistencyOptionsTest.cs
index 7737493..b9484aa 100644
--- a/test/Cap.Consistency.Test/ConsistencyOptionsTest.cs
+++ b/test/DotNetCore.CAP.Test/ConsistencyOptionsTest.cs
@@ -1,4 +1,4 @@
-namespace Cap.Consistency.Test
+namespace CDotNetCore.CAPTest
{
public class ConsistencyOptionsTest
{
diff --git a/test/Cap.Consistency.Test/Cap.Consistency.Test.csproj b/test/DotNetCore.CAP.Test/DotNetCore.CAP.Test.csproj
similarity index 87%
rename from test/Cap.Consistency.Test/Cap.Consistency.Test.csproj
rename to test/DotNetCore.CAP.Test/DotNetCore.CAP.Test.csproj
index 9f7439a..e08279c 100644
--- a/test/Cap.Consistency.Test/Cap.Consistency.Test.csproj
+++ b/test/DotNetCore.CAP.Test/DotNetCore.CAP.Test.csproj
@@ -3,8 +3,8 @@
netcoreapp1.1
true
- Cap.Consistency.Test
- Cap.Consistency.Test
+ DotNetCore.CAP.Test
+ DotNetCore.CAP.Test
true
$(PackageTargetFallback);dnxcore50;portable-net451+win8
1.1.1
@@ -15,7 +15,7 @@
-
+
diff --git a/test/Cap.Consistency.Test/NoopMessageStore.cs b/test/DotNetCore.CAP.Test/NoopMessageStore.cs
similarity index 92%
rename from test/Cap.Consistency.Test/NoopMessageStore.cs
rename to test/DotNetCore.CAP.Test/NoopMessageStore.cs
index 1e36733..b2117bf 100644
--- a/test/Cap.Consistency.Test/NoopMessageStore.cs
+++ b/test/DotNetCore.CAP.Test/NoopMessageStore.cs
@@ -1,10 +1,10 @@
//using System;
//using System.Threading;
//using System.Threading.Tasks;
-//using Cap.Consistency.Infrastructure;
-//using Cap.Consistency.Store;
+//using DotNetCore.CAP.Infrastructure;
+//using DotNetCore.CAP.Store;
-//namespace Cap.Consistency.Test
+//namespace DotNetCore.CAP.Test
//{
// public class NoopMessageStore : IConsistencyMessageStore
// {
diff --git a/test/Cap.Consistency.Test/OperateResultTest.cs b/test/DotNetCore.CAP.Test/OperateResultTest.cs
similarity index 94%
rename from test/Cap.Consistency.Test/OperateResultTest.cs
rename to test/DotNetCore.CAP.Test/OperateResultTest.cs
index 23cea34..e11d1c8 100644
--- a/test/Cap.Consistency.Test/OperateResultTest.cs
+++ b/test/DotNetCore.CAP.Test/OperateResultTest.cs
@@ -1,7 +1,7 @@
using System.Linq;
using Xunit;
-namespace Cap.Consistency.Test
+namespace DotNetCore.CAP.Test
{
public class OperateResultTest
{
diff --git a/test/Shared/MessageManagerTestBase.cs b/test/Shared/MessageManagerTestBase.cs
index f4a8bec..4766bf5 100644
--- a/test/Shared/MessageManagerTestBase.cs
+++ b/test/Shared/MessageManagerTestBase.cs
@@ -4,15 +4,15 @@
//using System.Linq.Expressions;
//using System.Security.Claims;
//using System.Threading.Tasks;
-//using Cap.Consistency.Infrastructure;
-//using Cap.Consistency.Store;
+//using DotNetCore.CAP.Infrastructure;
+//using DotNetCore.CAP.Store;
//using Microsoft.AspNetCore.Builder;
//using Microsoft.AspNetCore.Http;
//using Microsoft.Extensions.DependencyInjection;
//using Microsoft.Extensions.Logging;
//using Xunit;
-//namespace Cap.Consistency.Test
+//namespace DotNetCore.CAP.Test
//{
// public abstract class MessageManagerTestBase : MessageManagerTestBase
// where TMessage : ConsistencyMessage
diff --git a/test/Shared/TestConsistencyMessage.cs b/test/Shared/TestConsistencyMessage.cs
index 5e51692..b3501ac 100644
--- a/test/Shared/TestConsistencyMessage.cs
+++ b/test/Shared/TestConsistencyMessage.cs
@@ -1,7 +1,7 @@
using System;
-using Cap.Consistency.Infrastructure;
+using DotNetCore.CAP.Infrastructure;
-namespace Cap.Consistency.Test
+namespace DotNetCore.CAP.Test
{
}
diff --git a/test/Shared/TestLogger.cs b/test/Shared/TestLogger.cs
index a7b64e0..a280176 100644
--- a/test/Shared/TestLogger.cs
+++ b/test/Shared/TestLogger.cs
@@ -2,7 +2,7 @@ using System;
using System.Collections.Generic;
using Microsoft.Extensions.Logging;
-namespace Cap.Consistency.Test
+namespace DotNetCore.CAP.Test
{
public interface ITestLogger
{