-
Notifications
You must be signed in to change notification settings - Fork 26
Enable Integrated Mode #2786
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
Merged
Enable Integrated Mode #2786
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
7f8d1bb
Split application settings and host settings
mikeminutillo e55481d
Extract App from Host
mikeminutillo 12235ac
Extract core from host
mikeminutillo ed453f2
Add public API documentation
mikeminutillo dca04e2
Rename Settings to make it clear in other contexts
mikeminutillo a137919
Skip AutomaticVersionRange on MS Dependency
mikeminutillo adea759
Expect an additional nuget
mikeminutillo 411bd9c
Serving files off disk is optional
mikeminutillo 1c846d4
Indicate to UI if running in embedded mode
mikeminutillo d9ae162
Adjust SP UI when embedded
mikeminutillo 8e41237
Cleanup
mikeminutillo 2337efa
Update StaticMiddlewareTests.cs
mikeminutillo 0564938
Use passed ServiceControl url if embedded
mikeminutillo 924fccc
Allow serving constants file anonymously
mikeminutillo 689c3b1
Remove unused method
mikeminutillo e40dbd9
Remove unused method 2
mikeminutillo ec2027c
Apply suggestions from code review
mikeminutillo db6ba53
Cleanup
mikeminutillo 381fb16
Fix whitespace
mikeminutillo d6d3607
Put hosting extension in namespace
mikeminutillo dea8d9a
Change embedded to integrated
mikeminutillo ebe4049
Update to .NET 10
mikeminutillo bdb4f34
Fix dotnet versions used for actions
mikeminutillo 1ae0d00
Use global json file
mikeminutillo a04eb47
Rename ServicePulse.Core to Particular.ServicePulse.Core
mikeminutillo ffb6f3d
Address comments
mikeminutillo 5936aeb
Push package to testing feed
mikeminutillo 27da5ce
Update package description
mikeminutillo 72c4de7
Update labels and annotations for .NET 10 docker images
mikeminutillo df6437d
Update embedded file provider
mikeminutillo af439d8
Fix flaky sorting tests
mikeminutillo 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 |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| { | ||
| "sdk": { | ||
| "version": "8.0.400", | ||
| "version": "10.0.0", | ||
| "allowPrerelease": false, | ||
| "rollForward": "latestFeature" | ||
| } | ||
| } |
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
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
2 changes: 1 addition & 1 deletion
2
src/Particular.PlatformSample.ServicePulse/Particular.PlatformSample.ServicePulse.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
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,30 @@ | ||
| namespace ServicePulse; | ||
|
|
||
| using System.Reflection; | ||
|
|
||
| class ConstantsFile | ||
| { | ||
| public static string GetContent(ServicePulseSettings settings) | ||
| { | ||
| var version = GetVersionInformation(); | ||
|
|
||
| var constantsFile = $$""" | ||
| window.defaultConfig = { | ||
| default_route: '{{settings.DefaultRoute}}', | ||
| version: '{{version}}', | ||
| service_control_url: '{{settings.ServiceControlUrl}}', | ||
| monitoring_urls: ['{{settings.MonitoringUrl ?? "!"}}'], | ||
| showPendingRetry: {{settings.ShowPendingRetry.ToString().ToLower()}}, | ||
| isIntegrated: {{settings.IsIntegrated.ToString().ToLower()}} | ||
| } | ||
| """; | ||
|
|
||
| return constantsFile; | ||
| } | ||
|
|
||
| static string GetVersionInformation() | ||
| => typeof(ConstantsFile).Assembly | ||
| .GetCustomAttributes<AssemblyMetadataAttribute>() | ||
| .SingleOrDefault(attribute => attribute.Key == "MajorMinorPatch") | ||
| ?.Value ?? "0.0.0"; | ||
| } |
24 changes: 24 additions & 0 deletions
24
src/Particular.ServicePulse.Core/Particular.ServicePulse.Core.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,24 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFramework>net10.0</TargetFramework> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <Nullable>enable</Nullable> | ||
| <Description>Particular ServicePulse binaries for use by integrated ServicePulse. Not intended for use outside of ServiceControl.</Description> | ||
| <GenerateEmbeddedFilesManifest>true</GenerateEmbeddedFilesManifest> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="10.0.3" AutomaticVersionRange="false" /> | ||
| <PackageReference Include="Particular.Packaging" Version="4.5.0" PrivateAssets="All" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <FrameworkReference Include="Microsoft.AspNetCore.App" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup> | ||
| <EmbeddedResource Include="..\Frontend\dist\**\*" Exclude="..\Frontend\dist\js\**\*" LinkBase="wwwroot" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> |
37 changes: 37 additions & 0 deletions
37
src/Particular.ServicePulse.Core/ServicePulseHostingExtensions.cs
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,37 @@ | ||
| namespace ServicePulse; | ||
|
|
||
| using System.Net.Mime; | ||
| using Microsoft.AspNetCore.Builder; | ||
| using Microsoft.AspNetCore.Http; | ||
| using Microsoft.Extensions.FileProviders; | ||
|
|
||
| /// <summary> | ||
| /// Extensions for hosting ServicePulse within a WebApplication. | ||
| /// </summary> | ||
| public static class ServicePulseHostingExtensions | ||
| { | ||
| /// <summary> | ||
| /// Adds ServicePulse static file serving and configuration endpoint to the WebApplication. | ||
| /// </summary> | ||
| public static void UseServicePulse(this WebApplication app, ServicePulseSettings settings, IFileProvider? overrideFileProvider = null) | ||
| { | ||
| var manifestEmbeddedFileProvider = new ManifestEmbeddedFileProvider(typeof(ServicePulseHostingExtensions).Assembly, "wwwroot"); | ||
| IFileProvider fileProvider = overrideFileProvider is null | ||
| ? manifestEmbeddedFileProvider | ||
| : new CompositeFileProvider(overrideFileProvider, manifestEmbeddedFileProvider); | ||
|
|
||
| var defaultFilesOptions = new DefaultFilesOptions { FileProvider = fileProvider }; | ||
| app.UseDefaultFiles(defaultFilesOptions); | ||
|
|
||
| var staticFileOptions = new StaticFileOptions { FileProvider = fileProvider }; | ||
| app.UseStaticFiles(staticFileOptions); | ||
|
|
||
| var constantsFile = ConstantsFile.GetContent(settings); | ||
|
|
||
| app.MapGet("/js/app.constants.js", (HttpContext context) => | ||
| { | ||
| context.Response.ContentType = MediaTypeNames.Text.JavaScript; | ||
| return constantsFile; | ||
| }).AllowAnonymous(); | ||
| } | ||
| } |
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.
I had a thought that all the app constants should be loaded in a dedicated module, so that the direct window reference is constrained to a single location and can be changed out more easily