Skip to content

Commit

Permalink
Merge pull request #1177 from Henr1k80/master
Browse files Browse the repository at this point in the history
Performance tweaks
  • Loading branch information
mookid8000 authored Sep 16, 2024
2 parents 6cd6831 + 659c6ce commit ebd1bd0
Show file tree
Hide file tree
Showing 76 changed files with 148 additions and 129 deletions.
2 changes: 1 addition & 1 deletion Rebus/Activation/BuiltinHandlerActivator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public BuiltinHandlerActivator Handle<TMessage>(Func<TMessage, Task> handlerFunc
return this;
}

class Handler<TMessage> : IHandleMessages<TMessage>
sealed class Handler<TMessage> : IHandleMessages<TMessage>
{
readonly Func<IBus, TMessage, Task> _handlerFunction;
readonly Func<IBus> _getBus;
Expand Down
2 changes: 1 addition & 1 deletion Rebus/Activation/EmptyActivator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Rebus.Activation;

class EmptyActivator : IHandlerActivator
sealed class EmptyActivator : IHandlerActivator
{
public Task<IEnumerable<IHandleMessages<TMessage>>> GetHandlers<TMessage>(TMessage message, ITransactionContext transactionContext) =>
Task.FromResult(Enumerable.Empty<IHandleMessages<TMessage>>());
Expand Down
2 changes: 1 addition & 1 deletion Rebus/Auditing/Messages/AuditingHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Rebus.Auditing.Messages;

class AuditingHelper
sealed class AuditingHelper
{
readonly ITransport _transport;
readonly IRebusTime _rebusTime;
Expand Down
2 changes: 1 addition & 1 deletion Rebus/Auditing/Messages/IncomingAuditingStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Rebus.Auditing.Messages;
/// Implementation of <see cref="IIncomingStep"/> and <see cref="IOutgoingStep"/> that handles message auditing
/// </summary>
[StepDocumentation("Wraps the execution of the entire receive pipeline and forwards a copy of the current transport message to the configured audit queue if processing was successful, including some useful headers.")]
class IncomingAuditingStep : IIncomingStep, IInitializable
sealed class IncomingAuditingStep : IIncomingStep, IInitializable
{
readonly AuditingHelper _auditingHelper;
readonly ITransport _transport;
Expand Down
2 changes: 1 addition & 1 deletion Rebus/Auditing/Messages/OutgoingAuditingStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ namespace Rebus.Auditing.Messages;
/// Implementation of <see cref="IIncomingStep"/> and <see cref="IOutgoingStep"/> that handles message auditing
/// </summary>
[StepDocumentation("Forwards a copy of published messages to the configured audit queue, including some useful headers.")]
class OutgoingAuditingStep : IOutgoingStep, IInitializable
sealed class OutgoingAuditingStep : IOutgoingStep, IInitializable
{
readonly AuditingHelper _auditingHelper;
readonly ITransport _transport;
Expand Down
2 changes: 1 addition & 1 deletion Rebus/Auditing/Sagas/LoggerSagaSnapperShotter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Rebus.Auditing.Sagas;

class LoggerSagaSnapperShotter : ISagaSnapshotStorage
sealed class LoggerSagaSnapperShotter : ISagaSnapshotStorage
{
readonly ILog _log;

Expand Down
2 changes: 1 addition & 1 deletion Rebus/Auditing/Sagas/SaveSagaDataSnapshotStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
namespace Rebus.Auditing.Sagas;

[StepDocumentation("Saves a snapshot of each piece of saga data to the selected snapshot storage.")]
class SaveSagaDataSnapshotStep : IIncomingStep
sealed class SaveSagaDataSnapshotStep : IIncomingStep
{
readonly ISagaSnapshotStorage _sagaSnapshotStorage;
readonly ITransport _transport;
Expand Down
2 changes: 1 addition & 1 deletion Rebus/Bus/Advanced/AsyncHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static void RunSync(Func<Task> task)
/// <summary>
/// Synchronization context that can be "pumped" in order to have it execute continuations posted back to it
/// </summary>
class CustomSynchronizationContext : SynchronizationContext
sealed class CustomSynchronizationContext : SynchronizationContext
{
readonly ConcurrentQueue<Tuple<SendOrPostCallback, object>> _items = new();
readonly AutoResetEvent _workItemsWaiting = new(initialState: false);
Expand Down
14 changes: 7 additions & 7 deletions Rebus/Bus/AdvancedRebusBus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ namespace Rebus.Bus;
/// </summary>
public partial class RebusBus
{
class AdvancedApi : IAdvancedApi
sealed class AdvancedApi : IAdvancedApi
{
readonly RebusBus _rebusBus;
readonly IRebusTime _rebusTime;
Expand All @@ -43,7 +43,7 @@ public AdvancedApi(RebusBus rebusBus, IRebusTime rebusTime)
public ISyncBus SyncBus => new SyncApi(_rebusBus);
}

class TransportMessageApi : ITransportMessageApi
sealed class TransportMessageApi : ITransportMessageApi
{
readonly RebusBus _rebusBus;
readonly IRebusTime _rebusTime;
Expand Down Expand Up @@ -104,7 +104,7 @@ TransportMessage GetCloneOfCurrentTransportMessage(IDictionary<string, string> o
}
}

class SyncApi : ISyncBus
sealed class SyncApi : ISyncBus
{
readonly RebusBus _rebusBus;

Expand Down Expand Up @@ -164,7 +164,7 @@ public void Publish(object eventMessage, IDictionary<string, string> optionalHea
}
}

class RoutingApi : IRoutingApi
sealed class RoutingApi : IRoutingApi
{
readonly RebusBus _rebusBus;
readonly IRebusTime _rebusTime;
Expand Down Expand Up @@ -217,7 +217,7 @@ public Task SendRoutingSlip(Itinerary itinerary, object message, IDictionary<str
destinationAddresses.Add(itinerary.GetReturnAddress);
}

var first = destinationAddresses.First();
var first = destinationAddresses[0];
var rest = destinationAddresses.Skip(1);

var value = string.Join(";", rest);
Expand All @@ -230,7 +230,7 @@ public Task SendRoutingSlip(Itinerary itinerary, object message, IDictionary<str
}
}

class WorkersApi : IWorkersApi
sealed class WorkersApi : IWorkersApi
{
readonly RebusBus _rebusBus;

Expand All @@ -247,7 +247,7 @@ public void SetNumberOfWorkers(int numberOfWorkers)
}
}

class TopicsApi : ITopicsApi
sealed class TopicsApi : ITopicsApi
{
readonly RebusBus _rebusBus;

Expand Down
2 changes: 1 addition & 1 deletion Rebus/Compression/UnzippingSerializerDecorator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace Rebus.Compression;

class UnzippingSerializerDecorator : ZipDecoratorBase, ISerializer
sealed class UnzippingSerializerDecorator : ZipDecoratorBase, ISerializer
{
readonly ISerializer _serializer;
readonly Zipper _zipper;
Expand Down
2 changes: 1 addition & 1 deletion Rebus/Compression/ZippingSerializerDecorator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace Rebus.Compression;

class ZippingSerializerDecorator : ZipDecoratorBase, ISerializer
sealed class ZippingSerializerDecorator : ZipDecoratorBase, ISerializer
{
readonly ISerializer _serializer;
readonly Zipper _zipper;
Expand Down
2 changes: 1 addition & 1 deletion Rebus/Config/DefaultCorrelationErrorHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Rebus.Config;

class DefaultCorrelationErrorHandler : ICorrelationErrorHandler
sealed class DefaultCorrelationErrorHandler : ICorrelationErrorHandler
{
readonly ILog _log;

Expand Down
2 changes: 1 addition & 1 deletion Rebus/Config/DelayedStartupConfigurationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static IBusStarter Create(this RebusConfigurer configurer)
return new BusStarter(bus, desiredNumberOfWorkersWhenStarted);
}

class BusStarter : IBusStarter
sealed class BusStarter : IBusStarter
{
readonly IBus _bus;
readonly int _desiredNumberOfWorkersWhenStarted;
Expand Down
6 changes: 3 additions & 3 deletions Rebus/Config/OneWayClientBusDecorator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Rebus.Config;

class OneWayClientBusDecorator : IBus
sealed class OneWayClientBusDecorator : IBus
{
readonly AdvancedApiDecorator _advancedApiDecorator;
readonly IBus _innerBus;
Expand Down Expand Up @@ -44,7 +44,7 @@ public OneWayClientBusDecorator(IBus innerBus, IRebusLoggerFactory rebusLoggerFa

public void Dispose() => _innerBus.Dispose();

class AdvancedApiDecorator : IAdvancedApi
sealed class AdvancedApiDecorator : IAdvancedApi
{
readonly IAdvancedApi _innerAdvancedApi;
readonly IRebusLoggerFactory _rebusLoggerFactory;
Expand All @@ -68,7 +68,7 @@ public AdvancedApiDecorator(IAdvancedApi innerAdvancedApi, IRebusLoggerFactory r
public ISyncBus SyncBus => _innerAdvancedApi.SyncBus;
}

class OneWayClientWorkersApi : IWorkersApi
sealed class OneWayClientWorkersApi : IWorkersApi
{
readonly ILog _log;

Expand Down
4 changes: 2 additions & 2 deletions Rebus/DataBus/ClaimCheck/HydrateIncomingMessageStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ public async Task Process(IncomingStepContext context, Func<Task> next)

if (transportMessage.Headers.TryGetValue(Headers.MessagePayloadAttachmentId, out var attachmentId))
{
using var destination = new MemoryStream();
using var source = await _dataBus.OpenRead(attachmentId);


using var destination = new MemoryStream();
await source.CopyToAsync(destination);

var body = destination.ToArray();
Expand Down
2 changes: 1 addition & 1 deletion Rebus/DataBus/DataBusIncomingStep.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Rebus.DataBus;

class DataBusIncomingStep : IIncomingStep
sealed class DataBusIncomingStep : IIncomingStep
{
public const string DataBusStorageKey = "rebus-databus-storage";

Expand Down
2 changes: 1 addition & 1 deletion Rebus/DataBus/DefaultDataBus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

namespace Rebus.DataBus;

class DefaultDataBus : IDataBus
sealed class DefaultDataBus : IDataBus
{
readonly IDataBusStorage _dataBusStorage;
readonly IDataBusStorageManagement _dataBusStorageManagement;
Expand Down
2 changes: 1 addition & 1 deletion Rebus/DataBus/FileSystem/Retrier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Rebus.DataBus.FileSystem;

class Retrier
sealed class Retrier
{
readonly ILog _log;

Expand Down
2 changes: 1 addition & 1 deletion Rebus/DataBus/InMem/InMemDataBusStorage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace Rebus.DataBus.InMem;

class InMemDataBusStorage : IDataBusStorage, IDataBusStorageManagement
sealed class InMemDataBusStorage : IDataBusStorage, IDataBusStorageManagement
{
readonly InMemDataStore _dataStore;
readonly IRebusTime _rebusTime;
Expand Down
2 changes: 1 addition & 1 deletion Rebus/DataBus/InMem/InMemDataStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void Reset()
_data.Clear();
}

class InMemBlob
sealed class InMemBlob
{
public InMemBlob(Dictionary<string, string> metadata, byte[] data)
{
Expand Down
2 changes: 1 addition & 1 deletion Rebus/Encryption/AesEncryptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Rebus.Encryption;
/// <summary>
/// Helps with encrypting/decrypting byte arrays, using the <see cref="Aes"/> algorithm
/// </summary>
class AesEncryptor : IAsyncEncryptor
sealed class AesEncryptor : IAsyncEncryptor
{
readonly IEncryptionKeyProvider _keyProvider;

Expand Down
2 changes: 1 addition & 1 deletion Rebus/Encryption/DefaultAsyncEncryptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Rebus.Encryption;
/// <summary>
/// Default implementation of <see cref="IAsyncEncryptor"/> which wraps an instance of <see cref="IEncryptor"/>.
/// </summary>
class DefaultAsyncEncryptor : IAsyncEncryptor
sealed class DefaultAsyncEncryptor : IAsyncEncryptor
{
readonly IEncryptor _encryptor;

Expand Down
2 changes: 1 addition & 1 deletion Rebus/Encryption/RijndaelEncryptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace Rebus.Encryption;
/// <summary>
/// Helps with encrypting/decrypting byte arrays, using the <see cref="RijndaelManaged"/> algorithm (which is actually AES with 256 bits key size)
/// </summary>
class RijndaelEncryptor : IAsyncEncryptor
sealed class RijndaelEncryptor : IAsyncEncryptor
{
readonly IEncryptionKeyProvider _keyProvider;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Rebus.ExclusiveLocks;
/// <summary>
/// ConcurrentDictionary implementation of <see cref="IExclusiveAccessLock"/>
/// </summary>
class ConcurrentDictionaryExclusiveAccessLock : IExclusiveAccessLock
sealed class ConcurrentDictionaryExclusiveAccessLock : IExclusiveAccessLock
{
static readonly Task<bool> TrueResult = Task.FromResult(true);
static readonly Task<bool> FalseResult = Task.FromResult(false);
Expand Down
6 changes: 3 additions & 3 deletions Rebus/Handlers/InternalHandlersContributor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Rebus.Handlers;
/// Decoration of <see cref="IHandlerActivator"/> that adds a few special handlers when an incoming message can be recognized
/// as a special Rebus message
/// </summary>
class InternalHandlersContributor : IHandlerActivator
sealed class InternalHandlersContributor : IHandlerActivator
{
readonly IHandlerActivator _innerHandlerActivator;
readonly Dictionary<Type, IHandleMessages[]> _internalHandlers;
Expand Down Expand Up @@ -48,7 +48,7 @@ IEnumerable<IHandleMessages<TMessage>> GetOwnHandlersFor<TMessage>()
: Enumerable.Empty<IHandleMessages<TMessage>>();
}

class SubscribeRequestHandler : IHandleMessages<SubscribeRequest>
sealed class SubscribeRequestHandler : IHandleMessages<SubscribeRequest>
{
readonly ISubscriptionStorage _subscriptionStorage;

Expand All @@ -63,7 +63,7 @@ public async Task Handle(SubscribeRequest message)
}
}

class UnsubscribeRequestHandler : IHandleMessages<UnsubscribeRequest>
sealed class UnsubscribeRequestHandler : IHandleMessages<UnsubscribeRequest>
{
readonly ISubscriptionStorage _subscriptionStorage;

Expand Down
12 changes: 5 additions & 7 deletions Rebus/Injection/Injectionist.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ namespace Rebus.Injection;
/// </summary>
public class Injectionist
{
class Handler
sealed class Handler
{
public Handler()
{
Expand Down Expand Up @@ -96,9 +96,7 @@ static bool ResolverHaveRegistrationFor<TService>(bool primary, Dictionary<Type,
{
var key = typeof(TService);

if (!resolvers.ContainsKey(key)) return false;

var handler = resolvers[key];
if (!resolvers.TryGetValue(key, out var handler)) return false;

if (handler.PrimaryResolver != null) return true;

Expand Down Expand Up @@ -147,7 +145,7 @@ protected Resolver(bool isDecorator)
public bool IsDecorator { get; private set; }
}

class Resolver<TService> : Resolver
sealed class Resolver<TService> : Resolver
{
readonly Func<IResolutionContext, TService> _resolver;
readonly string _description;
Expand Down Expand Up @@ -175,7 +173,7 @@ public override string ToString()
}
}

class ResolutionContext : IResolutionContext
sealed class ResolutionContext : IResolutionContext
{
readonly Dictionary<Type, int> _decoratorDepth = new Dictionary<Type, int>();
readonly Dictionary<Type, Handler> _resolvers;
Expand Down Expand Up @@ -253,6 +251,6 @@ public TService Get<TService>()
}
}

public IEnumerable TrackedInstances => _resolvedInstances.ToList();
public IEnumerable TrackedInstances => _resolvedInstances.ToArray();
}
}
2 changes: 1 addition & 1 deletion Rebus/Logging/ConsoleLoggerFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public bool ShowTimestamps
/// </summary>
protected override ILog GetLogger(Type type) => Loggers.GetOrAdd(type, _ => new ConsoleLogger(type, _colors, this, _showTimestamps));

class ConsoleLogger : ILog
sealed class ConsoleLogger : ILog
{
readonly LoggingColors _loggingColors;
readonly ConsoleLoggerFactory _factory;
Expand Down
2 changes: 1 addition & 1 deletion Rebus/Logging/NullLoggerFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ protected override ILog GetLogger(Type type)
return Logger;
}

class NullLogger : ILog
sealed class NullLogger : ILog
{
public void Debug(string message, params object[] objs)
{
Expand Down
2 changes: 1 addition & 1 deletion Rebus/Logging/TraceLoggerFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ protected override ILog GetLogger(Type type)
return new TraceLogger(type, this);
}

class TraceLogger : ILog
sealed class TraceLogger : ILog
{
readonly Type _type;
readonly TraceLoggerFactory _loggerFactory;
Expand Down
Loading

0 comments on commit ebd1bd0

Please sign in to comment.