Skip to content

Commit

Permalink
Added CORS support
Browse files Browse the repository at this point in the history
  • Loading branch information
jezzsantos committed Dec 26, 2023
1 parent c1ebfbf commit 1d4a622
Show file tree
Hide file tree
Showing 22 changed files with 265 additions and 217 deletions.

This file was deleted.

49 changes: 0 additions & 49 deletions src/Infrastructure.Common/Recording/ForwardToAncillaryApiUsages.cs

This file was deleted.

2 changes: 0 additions & 2 deletions src/Infrastructure.Common/Recording/RecorderOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ public enum MetricReporterOption
{
None = 0,
Cloud = 1,
ForwardToAncillaryApi = 3
}

/// <summary>
Expand All @@ -160,5 +159,4 @@ public enum UsageReporterOption
{
None = 0,
ReliableQueue = 1,
ForwardToAncillaryApi = 2
}
16 changes: 14 additions & 2 deletions src/Infrastructure.Hosting.Common/Recording/HostRecorder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,23 @@ private void Dispose(bool disposing)
(_crashReporter as IDisposable)?.Dispose();
// ReSharper disable once SuspiciousTypeConversion.Global
(_metricsReporter as IDisposable)?.Dispose();
// ReSharper disable once SuspiciousTypeConversion.Global
(_usageReporter as IDisposable)?.Dispose();
}
}

public override string ToString()
{
var builder = new StringBuilder();
builder.AppendFormat("{0}: ", GetType().Name);
builder.AppendFormat("Crashes-> {0}, ", _crashReporter.GetType().Name);
builder.AppendFormat("Audits -> {0}, ", _auditReporter.GetType().Name);
builder.AppendFormat("Usages -> {0}, ", _usageReporter.GetType().Name);
builder.AppendFormat("Metrics -> {0}", _metricsReporter.GetType().Name);

return builder.ToString();
}

public void TraceDebug(ICallContext? context, string messageTemplate, params object[] templateArgs)
{
var (augmentedMessageTemplate, augmentedArguments) =
Expand Down Expand Up @@ -243,7 +257,6 @@ private static IMetricReporter GetMetricReporter(IDependencyContainer container,
#elif HOSTEDONAWS
new NullMetricReporter(),
#endif
MetricReporterOption.ForwardToAncillaryApi => new ForwardToAncillaryApiMetrics(container),
_ => throw new ArgumentOutOfRangeException(nameof(options.MetricReporting))
};
}
Expand All @@ -256,7 +269,6 @@ private static IUsageReporter GetUsageReporter(IDependencyContainer container,
UsageReporterOption.None => new NullUsageReporter(),
UsageReporterOption.ReliableQueue => new QueuedUsageReporter(container,
container.Resolve<IConfigurationSettings>().Platform),
UsageReporterOption.ForwardToAncillaryApi => new ForwardToAncillaryApiUsages(container),
_ => throw new ArgumentOutOfRangeException(nameof(options.MetricReporting))
};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#if TESTINGONLY
using System.Diagnostics.CodeAnalysis;
using Common;
using Common.Extensions;
using Domain.Interfaces;
using Infrastructure.Persistence.Interfaces;
using Infrastructure.Persistence.Interfaces.ApplicationServices;
Expand All @@ -13,13 +13,18 @@ namespace Infrastructure.Persistence.Common.ApplicationServices;
[ExcludeFromCodeCoverage]
public sealed partial class InProcessInMemStore
{
public InProcessInMemStore(Optional<IQueueStoreNotificationHandler> handler = default)
public static InProcessInMemStore Create(IQueueStoreNotificationHandler? handler = default)
{
if (handler.HasValue)
return new InProcessInMemStore(handler);
}

private InProcessInMemStore(IQueueStoreNotificationHandler? handler = default)
{
if (handler.Exists())
{
FireMessageQueueUpdated += (_, args) =>
{
handler.Value.HandleMessagesQueueUpdated(args.QueueName, args.MessageCount);
handler.HandleMessagesQueueUpdated(args.QueueName, args.MessageCount);
};
NotifyAllQueuedMessages();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public partial class LocalMachineJsonFileStore
private readonly string _rootPath;

public static LocalMachineJsonFileStore Create(ISettings settings,
Optional<IQueueStoreNotificationHandler> handler = default)
IQueueStoreNotificationHandler? handler = default)
{
var configPath = settings.GetString(PathSettingName);
var basePath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
Expand All @@ -32,7 +32,7 @@ public static LocalMachineJsonFileStore Create(ISettings settings,
return new LocalMachineJsonFileStore(path, handler);
}

private LocalMachineJsonFileStore(string rootPath, Optional<IQueueStoreNotificationHandler> handler = default)
private LocalMachineJsonFileStore(string rootPath, IQueueStoreNotificationHandler? handler = default)
{
rootPath.ThrowIfNotValuedParameter(nameof(rootPath));
if (rootPath.IsInvalidParameter(ValidateRootPath, nameof(rootPath),
Expand All @@ -43,11 +43,11 @@ private LocalMachineJsonFileStore(string rootPath, Optional<IQueueStoreNotificat

_rootPath = rootPath;

if (handler.HasValue)
if (handler.Exists())
{
FireMessageQueueUpdated += (_, args) =>
{
handler.Value.HandleMessagesQueueUpdated(args.QueueName, args.MessageCount);
handler.HandleMessagesQueueUpdated(args.QueueName, args.MessageCount);
};
NotifyAllQueuedMessages();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ public class AllInProcessInMemStoreSpecs : ICollectionFixture<InProcessInMemStor
[UsedImplicitly]
public class InProcessInMemStoreSpecSetup : StoreSpecSetupBase
{
public IBlobStore BlobStore { get; } = new InProcessInMemStore();
private readonly InProcessInMemStore _store = InProcessInMemStore.Create();

public IDataStore DataStore { get; } = new InProcessInMemStore();
public IBlobStore BlobStore => _store;

public IEventStore EventStore { get; } = new InProcessInMemStore();
public IDataStore DataStore => _store;

public IQueueStore QueueStore { get; } = new InProcessInMemStore();
public IEventStore EventStore => _store;

public IQueueStore QueueStore => _store;
}

[Trait("Category", "Integration.Storage")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,20 @@ public class AllLocalMachineJsonFileStoreSpecs : ICollectionFixture<LocalMachine
[UsedImplicitly]
public class LocalMachineJsonFileStoreSpecSetup : StoreSpecSetupBase
{
private readonly LocalMachineJsonFileStore _store;

public LocalMachineJsonFileStoreSpecSetup()
{
DataStore = LocalMachineJsonFileStore.Create(Settings);
BlobStore = LocalMachineJsonFileStore.Create(Settings);
QueueStore = LocalMachineJsonFileStore.Create(Settings);
EventStore = LocalMachineJsonFileStore.Create(Settings);
_store = LocalMachineJsonFileStore.Create(Settings);
}

public IBlobStore BlobStore { get; }
public IBlobStore BlobStore => _store;

public IDataStore DataStore { get; }
public IDataStore DataStore => _store;

public IEventStore EventStore { get; }
public IEventStore EventStore => _store;

public IQueueStore QueueStore { get; }
public IQueueStore QueueStore => _store;
}

[Trait("Category", "Integration.Storage")]
Expand Down
1 change: 1 addition & 0 deletions src/Infrastructure.Web.Api.Common/HttpConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public static class HttpHeaders
{
public const string Accept = "Accept";
public const string Authorization = "Authorization";
public const string ContentType = "Content-Type";
public const string HmacSignature = "X-Hub-Signature";
public const string RequestId = "Request-ID";
}
Expand Down
9 changes: 0 additions & 9 deletions src/Infrastructure.Web.Api.Common/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions src/Infrastructure.Web.Api.Common/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,4 @@
<data name="RequestExtensions_MissingRouteAttribute" xml:space="preserve">
<value>The request DTO type '{0}' is missing a '{1}' declared on the class</value>
</data>
<data name="WebApplicationExtensions_AddExceptionShielding_UnexpectedExceptionMessage" xml:space="preserve">
<value>An unexpected error occurred</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ public override void Dispose()
GC.SuppressFinalize(this);
}

public IEnumerable<string> MonitoredQueues => _monitorQueueMappings.Select(mqm => mqm.Key);

protected override async Task ExecuteAsync(CancellationToken cancellationToken)
{
await Task.Delay(StartInterval, cancellationToken);
Expand Down
Loading

0 comments on commit 1d4a622

Please sign in to comment.