-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Support attaching to an existing request queue in HTTP.SYS #14182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
analogrelay
merged 16 commits into
dotnet:release/3.1-preview1
from
bkatms:bkress/httpsysexistingq
Oct 1, 2019
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
5495097
Initial port of old branch for existing queues #5866
bkatms ceaa798
Ref assemblies
Tratcher 720ffaf
Add sample app for manual testing
Tratcher ff1c096
Pull in other parts of old PR (Some tests failing)
Tratcher c2c39f8
Fix path base, get tests passing
Tratcher cb93d46
Remove controller mode
Tratcher d811b19
Explicit flags type
Tratcher 2bd891b
Rename Mode property. Add comments about what's settings apply.
Tratcher eff24ed
PathBase searching
Tratcher 1a8efc4
Reorder CreateOrAttach
Tratcher f95bff3
Remove outdated test
Tratcher 5880415
Do not add a default address
Tratcher 4f58c29
PR Cleanup
Tratcher 8bab6b5
Doc comments
Tratcher 9dc1ec6
Longest match test
Tratcher f0806c2
Include queue name in log
Tratcher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,74 @@ | ||
using System; | ||
using System.Xml.Schema; | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Server.HttpSys; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.Extensions.Logging; | ||
|
||
namespace QueueSharing | ||
{ | ||
public static class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
Console.Write("Create and (c)reate, (a)ttach to existing, or attach (o)r create? "); | ||
var key = Console.ReadKey(); | ||
Console.WriteLine(); | ||
var mode = RequestQueueMode.Create; | ||
switch (key.KeyChar) | ||
{ | ||
case 'a': | ||
mode = RequestQueueMode.Attach; | ||
break; | ||
case 'o': | ||
mode = RequestQueueMode.CreateOrAttach; | ||
break; | ||
case 'c': | ||
mode = RequestQueueMode.Create; | ||
break; | ||
default: | ||
Console.WriteLine("Unknown option, defaulting to (c)create."); | ||
break; | ||
} | ||
|
||
var host = new HostBuilder() | ||
.ConfigureLogging(factory => factory.AddConsole()) | ||
.ConfigureWebHost(webHost => | ||
{ | ||
webHost.UseHttpSys(options => | ||
{ | ||
// Skipping this to ensure the server works without any prefixes in attach mode. | ||
if (mode != RequestQueueMode.Attach) | ||
{ | ||
options.UrlPrefixes.Add("http://localhost:5002"); | ||
} | ||
options.RequestQueueName = "QueueName"; | ||
options.RequestQueueMode = mode; | ||
options.MaxAccepts = 1; // Better load rotation between instances. | ||
}).ConfigureServices(services => | ||
{ | ||
|
||
}).Configure(app => | ||
{ | ||
app.Run(async context => | ||
{ | ||
context.Response.ContentType = "text/plain"; | ||
// There's a strong connection affinity between processes. Close the connection so the next request can be dispatched to a random instance. | ||
// It appears to be round robin based and switch instances roughly every 30 requests when using new connections. | ||
// This seems related to the default MaxAccepts (5 * processor count). | ||
// I'm told this connection affinity does not apply to HTTP/2. | ||
context.Response.Headers["Connection"] = "close"; | ||
await context.Response.WriteAsync("Hello world from " + context.Request.Host + " at " + DateTime.Now); | ||
}); | ||
}); | ||
|
||
}) | ||
.Build(); | ||
|
||
host.Run(); | ||
} | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/Servers/HttpSys/samples/QueueSharing/QueueSharing.csproj
This file contains hidden or 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,14 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework> | ||
<OutputType>Exe</OutputType> | ||
<ServerGarbageCollection>true</ServerGarbageCollection> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<Reference Include="Microsoft.AspNetCore.Server.HttpSys" /> | ||
<Reference Include="Microsoft.Extensions.Hosting" /> | ||
<Reference Include="Microsoft.Extensions.Logging.Console" /> | ||
</ItemGroup> | ||
</Project> |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be a remark rather than summary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remarks aren't visible in most situations.