-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Throttle events over file system (#107)
- Loading branch information
Showing
48 changed files
with
693 additions
and
639 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -337,3 +337,4 @@ tools/** | |
!tools/packages.config | ||
|
||
__mismatch__/ | ||
*.Development.json |
3 changes: 2 additions & 1 deletion
3
src/Clients/AspNetCore.FunctionalTest/AspNetCore.FunctionalTest.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 12 additions & 33 deletions
45
src/Clients/AspNetCore.FunctionalTest/Controllers/ValuesController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,23 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using Microsoft.AspNetCore.Mvc; | ||
using static Thor.Hosting.AspNetCore.FunctionalTest.EventSources.ValuesEventSources; | ||
|
||
namespace Thor.Hosting.AspNetCore.FunctionalTest.Controllers | ||
{ | ||
[Route("api/[controller]")] | ||
[Route("[controller]")] | ||
public class ValuesController : Controller | ||
{ | ||
// GET api/values | ||
[HttpGet] | ||
public IEnumerable<string> Get() | ||
[HttpGet("{count}")] | ||
public string Get(int count) | ||
{ | ||
return new string[] { "value1", "value2" }; | ||
} | ||
|
||
// GET api/values/5 | ||
[HttpGet("{id}")] | ||
public string Get(int id) | ||
{ | ||
throw new InvalidOperationException(); | ||
|
||
//return "value"; | ||
} | ||
|
||
// POST api/values | ||
[HttpPost] | ||
public void Post([FromBody]string value) | ||
{ | ||
} | ||
|
||
// PUT api/values/5 | ||
[HttpPut("{id}")] | ||
public void Put(int id, [FromBody]string value) | ||
{ | ||
} | ||
var timer = Stopwatch.StartNew(); | ||
var processed = 0; | ||
for (processed = 0; processed < count; processed++) | ||
{ | ||
Log.RetrieveObject(processed); | ||
} | ||
|
||
// DELETE api/values/5 | ||
[HttpDelete("{id}")] | ||
public void Delete(int id) | ||
{ | ||
return $"{processed} {timer.Elapsed}"; | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/Clients/AspNetCore.FunctionalTest/EventSources/IValuesEventSources.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using System.Diagnostics.Tracing; | ||
using Thor.Core.Abstractions; | ||
|
||
namespace Thor.Hosting.AspNetCore.FunctionalTest.EventSources | ||
{ | ||
[EventSourceDefinition(Name = "AspNetCore-FunctionalTest")] | ||
public interface IValuesEventSources | ||
{ | ||
[Event(1, | ||
Level = EventLevel.Informational, | ||
Message = "Retrieve value for object {id}", | ||
Version = 1)] | ||
void RetrieveObject(int id); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
src/Clients/AspNetCore.FunctionalTest/EventSources/ValuesEventSources.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
using System; | ||
using System.Diagnostics.Tracing; | ||
using Thor.Core; | ||
using Thor.Core.Abstractions; | ||
using Thor.Core.Transmission.Abstractions; | ||
|
||
namespace Thor.Hosting.AspNetCore.FunctionalTest.EventSources | ||
{ | ||
|
||
[EventSource(Name = "AspNetCore-FunctionalTest")] | ||
[System.CodeDom.Compiler.GeneratedCodeAttribute("thor-generator", "1.0.0")] | ||
public sealed class ValuesEventSources | ||
: EventSourceBase | ||
, IValuesEventSources | ||
{ | ||
private ValuesEventSources() { } | ||
|
||
public static IValuesEventSources Log { get; } = new ValuesEventSources(); | ||
|
||
|
||
[NonEvent] | ||
public void RetrieveObject(int id) | ||
{ | ||
if (IsEnabled()) | ||
{ | ||
|
||
RetrieveObject(Application.Id, ActivityStack.Id, id); | ||
|
||
} | ||
} | ||
|
||
[Event(1, Level = EventLevel.Informational, Message = "Retrieve value for object {2}", Version = 1)] | ||
private void RetrieveObject(int applicationId, Guid activityId, int id) | ||
{ | ||
WriteCore(1, applicationId, activityId, id); | ||
} | ||
|
||
[NonEvent] | ||
private unsafe void WriteCore(int eventId, int applicationId, Guid activityId, int a) | ||
{ | ||
if (IsEnabled()) | ||
{ | ||
|
||
const short dataCount = 3; | ||
EventData* data = stackalloc EventData[dataCount]; | ||
data[0].DataPointer = (IntPtr)(&applicationId); | ||
data[0].Size = 4; | ||
data[1].DataPointer = (IntPtr)(&activityId); | ||
data[1].Size = 16; | ||
data[2].DataPointer = (IntPtr)(&a); | ||
data[2].Size = 4; | ||
|
||
WriteEventCore(eventId, dataCount, data); | ||
} | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 0 additions & 21 deletions
21
src/Clients/AspNetCore.FunctionalTest/appsettings.Development.json
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,24 @@ | ||
{ | ||
"Logging": { | ||
"IncludeScopes": false, | ||
"Debug": { | ||
"LogLevel": { | ||
"Default": "Warning" | ||
} | ||
}, | ||
"Console": { | ||
"LogLevel": { | ||
"Default": "Warning" | ||
} | ||
} | ||
}, | ||
{ | ||
"Tracing": { | ||
"ApplicationId": 1000, | ||
"Level": "Verbose", | ||
"BlobStorage": { | ||
//"AttachmentContainerName": "attach", | ||
"ConnectionString": "xxx" | ||
}, | ||
"ApplicationId": "432", | ||
"Level": "Informational", | ||
"EventHub": { | ||
"ConnectionString": "xxx" | ||
} | ||
"TransportType": "AmqpWebSockets" | ||
}, | ||
"ApplicationRootPath": null, | ||
"InProcess": "true", | ||
"Enabled": "true", | ||
|
||
"Forwarding": [ | ||
{ | ||
"Regex": "Microsoft.AspNetCore.Hosting.Internal.WebHost", | ||
"Level": "Warning" | ||
}, | ||
{ | ||
"Regex": "Microsoft.*", | ||
"Level": "Info" | ||
} | ||
], | ||
"SkipRequestFilter": "_health" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.CompilerServices; | ||
|
||
[assembly: InternalsVisibleTo("Thor.Core")] | ||
[assembly: InternalsVisibleTo("Thor.Core.Abstractions.Tests")] | ||
[assembly: InternalsVisibleTo("Thor.Core.Transmission.Abstractions")] | ||
[assembly: InternalsVisibleTo("Thor.Core.Transmission.BlobStorage")] | ||
[assembly: InternalsVisibleTo("Thor.Core.Transmission.EventHub")] | ||
[assembly: InternalsVisibleTo("Thor.Extensions.Http")] | ||
[assembly: InternalsVisibleTo("Thor.Extensions.HotChocolate")] | ||
[assembly: InternalsVisibleTo("Thor.Extensions.Http.Tests")] | ||
[assembly: InternalsVisibleTo("Thor.Extensions.HotChocolate.Tests")] | ||
[assembly: InternalsVisibleTo("Thor.Core.Session")] | ||
[assembly: InternalsVisibleTo("Thor.Core.Session")] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.CompilerServices; | ||
|
||
[assembly: InternalsVisibleTo("Thor.Extensions.Http.Tests")] | ||
[assembly: InternalsVisibleTo("Thor.Extensions.HotChocolate.Tests")] | ||
[assembly: InternalsVisibleTo("Thor.Core.Transmission.Abstractions.Tests")] | ||
[assembly: InternalsVisibleTo("Thor.Core.Transmission.Abstractions.Tests")] | ||
[assembly: InternalsVisibleTo("Thor.Core.Transmission.BlobStorage")] | ||
[assembly: InternalsVisibleTo("Thor.Core.Transmission.EventHub")] |
Oops, something went wrong.