Skip to content

Commit

Permalink
Sealed uninherited internal classes in Akka.Streams (#6940)
Browse files Browse the repository at this point in the history
Co-authored-by: Lehonti Ramos <lehonti@ramos>
Co-authored-by: Aaron Stannard <[email protected]>
  • Loading branch information
3 people authored Jan 4, 2024
1 parent 1c4f071 commit 5620f02
Show file tree
Hide file tree
Showing 18 changed files with 64 additions and 71 deletions.
2 changes: 1 addition & 1 deletion src/core/Akka.Cluster/ClusterActorRefProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public override Scope Copy()
///
/// Deployer of cluster-aware routers
/// </summary>
internal class ClusterDeployer : RemoteDeployer
internal sealed class ClusterDeployer : RemoteDeployer
{
/// <summary>
/// Initializes a new instance of the <see cref="ClusterDeployer"/> class.
Expand Down
18 changes: 9 additions & 9 deletions src/core/Akka.Remote/Endpoint.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void Dispatch(IInternalActorRef recipient, Address recipientAddress, SerializedM
/// <summary>
/// INTERNAL API
/// </summary>
internal class DefaultMessageDispatcher : IInboundMessageDispatcher
internal sealed class DefaultMessageDispatcher : IInboundMessageDispatcher
{
private readonly ExtendedActorSystem _system;
private readonly IRemoteActorRefProvider _provider;
Expand Down Expand Up @@ -398,7 +398,7 @@ public OversizedPayloadException(string message)
/// <summary>
/// INTERNAL API
/// </summary>
internal class ReliableDeliverySupervisor : ReceiveActor
internal sealed class ReliableDeliverySupervisor : ReceiveActor
{
#region Internal message classes

Expand Down Expand Up @@ -447,7 +447,7 @@ private TooLongIdle() { }
private readonly int? _refuseUid;
private readonly AkkaProtocolTransport _transport;
private readonly RemoteSettings _settings;
private AkkaPduCodec _codec;
private readonly AkkaPduCodec _codec;
private AkkaProtocolHandle _currentHandle;
private readonly ConcurrentDictionary<EndpointManager.Link, EndpointManager.ResendState> _receiveBuffers;

Expand Down Expand Up @@ -599,7 +599,7 @@ protected override void PostRestart(Exception reason)
/// TBD
/// </summary>
/// <exception cref="HopelessAssociation">TBD</exception>
protected void Receiving()
private void Receiving()
{
Receive<EndpointWriter.FlushAndStop>(_ =>
{
Expand Down Expand Up @@ -680,7 +680,7 @@ private void GoToActive()
/// <param name="writerTerminated">TBD</param>
/// <param name="earlyUngateRequested">TBD</param>
/// <exception cref="HopelessAssociation">TBD</exception>
protected void Gated(bool writerTerminated, bool earlyUngateRequested)
private void Gated(bool writerTerminated, bool earlyUngateRequested)
{
Receive<Terminated>(_ =>
{
Expand Down Expand Up @@ -740,7 +740,7 @@ protected void Gated(bool writerTerminated, bool earlyUngateRequested)
/// <summary>
/// TBD
/// </summary>
protected void IdleBehavior()
private void IdleBehavior()
{
Receive<IsIdle>(_ => Sender.Tell(Idle.Instance));
Receive<EndpointManager.Send>(send =>
Expand Down Expand Up @@ -772,7 +772,7 @@ protected void IdleBehavior()
/// <summary>
/// TBD
/// </summary>
protected void FlushWait()
private void FlushWait()
{
Receive<IsIdle>(_ => { }); // Do not reply, we will Terminate soon, which will do the inbound connection unstashing
Receive<Terminated>(_ =>
Expand Down Expand Up @@ -1015,7 +1015,7 @@ private void TryPublish(RemotingLifecycleEvent ev)
/// <summary>
/// INTERNAL API
/// </summary>
internal class EndpointWriter : EndpointActor
internal sealed class EndpointWriter : EndpointActor
{
/// <summary>
/// TBD
Expand Down Expand Up @@ -1876,7 +1876,7 @@ public OutboundAck(Ack ack)
/// <summary>
/// INTERNAL API
/// </summary>
internal class EndpointReader : EndpointActor
internal sealed class EndpointReader : EndpointActor
{
/// <summary>
/// TBD
Expand Down
7 changes: 3 additions & 4 deletions src/core/Akka.Remote/EndpointManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using Akka.Actor;
Expand All @@ -24,7 +23,7 @@ namespace Akka.Remote
/// <summary>
/// INTERNAL API
/// </summary>
internal class EndpointManager : ReceiveActor, IRequiresMessageQueue<IUnboundedMessageQueueSemantics>
internal sealed class EndpointManager : ReceiveActor, IRequiresMessageQueue<IUnboundedMessageQueueSemantics>
{

#region Policy definitions
Expand Down Expand Up @@ -701,7 +700,7 @@ into g
/// Message-processing behavior when the <see cref="EndpointManager"/> is able to accept
/// inbound association requests.
/// </summary>
protected void Accepting()
private void Accepting()
{
Receive<ManagementCommand>(mc =>
{
Expand Down Expand Up @@ -929,7 +928,7 @@ IActorRef CreateAndRegisterWritingEndpoint() => _endpoints.RegisterWritableEndpo
/// <summary>
/// TBD
/// </summary>
protected void Flushing()
private void Flushing()
{
Receive<Send>(send => Context.System.DeadLetters.Tell(send));
Receive<InboundAssociation>(
Expand Down
2 changes: 1 addition & 1 deletion src/core/Akka.Remote/EndpointRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Akka.Remote
/// <summary>
/// Not threadsafe - only to be used in HeadActor
/// </summary>
internal class EndpointRegistry
internal sealed class EndpointRegistry
{
private Dictionary<Address, (int, Deadline)> _addressToRefuseUid = new();
private readonly Dictionary<Address, (IActorRef, int)> _addressToReadonly = new();
Expand Down
9 changes: 4 additions & 5 deletions src/core/Akka.Remote/PhiAccrualFailureDetector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
//-----------------------------------------------------------------------

using System;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Linq;
using Akka.Actor;
Expand Down Expand Up @@ -38,9 +37,9 @@ public class PhiAccrualFailureDetector : FailureDetector
{
private readonly double _threshold;
private readonly int _maxSampleSize;
private TimeSpan _minStdDeviation;
private TimeSpan _acceptableHeartbeatPause;
private TimeSpan _firstHeartbeatEstimate;
private readonly TimeSpan _minStdDeviation;
private readonly TimeSpan _acceptableHeartbeatPause;
private readonly TimeSpan _firstHeartbeatEstimate;
private readonly Clock _clock;

/// <summary>
Expand Down Expand Up @@ -128,7 +127,7 @@ private HeartbeatHistory FirstHeartBeat
/// <summary>
/// Uses volatile memory and immutability for lockless concurrency.
/// </summary>
internal class AccrualState
internal sealed class AccrualState
{
/// <summary>
/// TBD
Expand Down
4 changes: 2 additions & 2 deletions src/core/Akka.Remote/RemoteDeploymentWatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Akka.Remote
/// Responsible for cleaning up child references of remote deployed actors when remote node
/// goes down (crash, network failure), i.e. triggered by Akka.Actor.Terminated.AddressTerminated
/// </summary>
internal class RemoteDeploymentWatcher : ReceiveActor, IRequiresMessageQueue<IUnboundedMessageQueueSemantics>
internal sealed class RemoteDeploymentWatcher : ReceiveActor, IRequiresMessageQueue<IUnboundedMessageQueueSemantics>
{

private readonly IDictionary<IActorRef, IInternalActorRef> _supervisors =
Expand Down Expand Up @@ -48,7 +48,7 @@ public RemoteDeploymentWatcher()
/// <summary>
/// TBD
/// </summary>
internal class WatchRemote
internal sealed class WatchRemote
{
/// <summary>
/// TBD
Expand Down
6 changes: 3 additions & 3 deletions src/core/Akka.Remote/RemoteMetricsExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ namespace Akka.Remote
/// Extension that keeps track of remote metrics, such
/// as max size of different message types.
/// </summary>
internal class RemoteMetricsExtension : ExtensionIdProvider<IRemoteMetrics>
internal sealed class RemoteMetricsExtension : ExtensionIdProvider<IRemoteMetrics>
{
/// <summary>
/// TBD
Expand Down Expand Up @@ -54,7 +54,7 @@ public static IRemoteMetrics Create(ExtendedActorSystem system)
/// <summary>
/// INTERNAL API
/// </summary>
internal class RemoteMetricsOn : IRemoteMetrics
internal sealed class RemoteMetricsOn : IRemoteMetrics
{
private readonly ILoggingAdapter _log;
private readonly long? _logFrameSizeExceeding;
Expand Down Expand Up @@ -124,7 +124,7 @@ private void Check(Type type, long payloadBytes, long newMax)
/// <summary>
/// INTERNAL API
/// </summary>
internal class RemoteMetricsOff : IRemoteMetrics
internal sealed class RemoteMetricsOff : IRemoteMetrics
{
/// <summary>
/// TBD
Expand Down
4 changes: 2 additions & 2 deletions src/core/Akka.Remote/Remoting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ internal sealed class Remoting : RemoteTransport
// a lazy val
private volatile Address _defaultAddress;

private IActorRef _transportSupervisor;
private readonly IActorRef _transportSupervisor;
private readonly EventPublisher _eventPublisher;

/// <summary>
Expand Down Expand Up @@ -435,7 +435,7 @@ public RegisterTransportActor(Props props, string name)
/// <summary>
/// Actor responsible for supervising the creation of all transport actors
/// </summary>
internal class TransportSupervisor : ReceiveActor
internal sealed class TransportSupervisor : ReceiveActor
{
private readonly SupervisorStrategy _strategy = new OneForOneStrategy(_ => Directive.Restart);
/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion src/core/Akka.Remote/RemotingLifecycleEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ public override string ToString()
///
/// Used for publishing remote lifecycle events to the <see cref="EventStream"/> of the provided <see cref="ActorSystem"/>.
/// </summary>
internal class EventPublisher
internal sealed class EventPublisher
{
/// <summary>
/// TBD
Expand Down
3 changes: 1 addition & 2 deletions src/core/Akka.Remote/Serialization/ExceptionSupport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.Serialization.Formatters;
using Akka.Actor;
using Akka.Util;
using Akka.Util.Internal;
Expand All @@ -18,7 +17,7 @@

namespace Akka.Remote.Serialization
{
internal class ExceptionSupport
internal sealed class ExceptionSupport
{
private readonly WrappedPayloadSupport _wrappedPayloadSupport;
private const BindingFlags All = BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public;
Expand Down
4 changes: 1 addition & 3 deletions src/core/Akka.Remote/Serialization/WrappedPayloadSupport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
//-----------------------------------------------------------------------

using Akka.Actor;
using Akka.Serialization;
using Akka.Util;
using Google.Protobuf;

namespace Akka.Remote.Serialization
{
internal class WrappedPayloadSupport
internal sealed class WrappedPayloadSupport
{
private readonly ExtendedActorSystem _system;

Expand Down
2 changes: 1 addition & 1 deletion src/core/Akka.Remote/Transport/AkkaPduCodec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ public abstract ByteString ConstructMessage(Address localAddress, IActorRef reci
/// <summary>
/// TBD
/// </summary>
internal class AkkaPduProtobuffCodec : AkkaPduCodec
internal sealed class AkkaPduProtobuffCodec : AkkaPduCodec
{
/// <summary>
/// TBD
Expand Down
24 changes: 12 additions & 12 deletions src/core/Akka.Remote/Transport/AkkaProtocolTransport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace Akka.Remote.Transport
/// this system over the network.
/// </para>
/// </summary>
internal class ProtocolTransportAddressPair
internal sealed class ProtocolTransportAddressPair
{
/// <summary>
/// Initializes a new instance of the <see cref="ProtocolTransportAddressPair"/> class.
Expand Down Expand Up @@ -184,7 +184,7 @@ public async Task<AkkaProtocolHandle> Associate(Address remoteAddress, int? refu
/// <summary>
/// TBD
/// </summary>
internal class AkkaProtocolManager : ActorTransportAdapterManager
internal sealed class AkkaProtocolManager : ActorTransportAdapterManager
{
/// <summary>
/// TBD
Expand Down Expand Up @@ -290,7 +290,7 @@ private FailureDetector CreateTransportFailureDetector()
/// <summary>
/// TBD
/// </summary>
internal class AssociateUnderlyingRefuseUid : INoSerializationVerificationNeeded
internal sealed class AssociateUnderlyingRefuseUid : INoSerializationVerificationNeeded
{
/// <summary>
/// TBD
Expand Down Expand Up @@ -373,7 +373,7 @@ public override int GetHashCode()
/// <summary>
/// TBD
/// </summary>
internal class AkkaProtocolHandle : AbstractTransportAdapterHandle
internal sealed class AkkaProtocolHandle : AbstractTransportAdapterHandle
{
/// <summary>
/// TBD
Expand Down Expand Up @@ -444,7 +444,7 @@ public override bool Equals(object obj)
}

/// <inheritdoc/>
protected bool Equals(AkkaProtocolHandle other)
private bool Equals(AkkaProtocolHandle other)
{
return base.Equals(other) && Equals(HandshakeInfo, other.HandshakeInfo) && Equals(StateActor, other.StateActor);
}
Expand Down Expand Up @@ -484,9 +484,9 @@ internal enum AssociationState
/// <summary>
/// TBD
/// </summary>
internal class HeartbeatTimer : INoSerializationVerificationNeeded { }
internal sealed class HeartbeatTimer : INoSerializationVerificationNeeded { }

internal class HandshakeTimer : INoSerializationVerificationNeeded { }
internal sealed class HandshakeTimer : INoSerializationVerificationNeeded { }

/// <summary>
/// TBD
Expand Down Expand Up @@ -689,7 +689,7 @@ public ListenerReady(IHandleEventListener listener, AssociationHandle wrappedHan
/// <summary>
/// Message sent when a <see cref="FailureDetector.IsAvailable"/> returns false, signaling a transport timeout.
/// </summary>
internal class TimeoutReason
internal sealed class TimeoutReason
{
/// <summary>
/// TBD
Expand All @@ -715,17 +715,17 @@ public override string ToString()
/// <summary>
/// TBD
/// </summary>
internal class ForbiddenUidReason { }
internal sealed class ForbiddenUidReason { }

/// <summary>
/// INTERNAL API.
/// </summary>
internal class ProtocolStateActor : FSM<AssociationState, ProtocolStateData>
internal sealed class ProtocolStateActor : FSM<AssociationState, ProtocolStateData>
{
private readonly ILoggingAdapter _log = Context.GetLogger();
private readonly InitialProtocolStateData _initialData;
private readonly HandshakeInfo _localHandshakeInfo;
private int? _refuseUid;
private readonly int? _refuseUid;
private readonly AkkaProtocolSettings _settings;
private readonly Address _localAddress;
private readonly AkkaPduCodec _codec;
Expand Down Expand Up @@ -811,7 +811,7 @@ public ProtocolStateActor(HandshakeInfo handshakeInfo, AssociationHandle wrapped
/// </dd>
/// </dl>
/// </exception>
protected ProtocolStateActor(InitialProtocolStateData initialData, HandshakeInfo localHandshakeInfo, AkkaProtocolSettings settings, AkkaPduCodec codec, FailureDetector failureDetector, int? refuseUid)
private ProtocolStateActor(InitialProtocolStateData initialData, HandshakeInfo localHandshakeInfo, AkkaProtocolSettings settings, AkkaPduCodec codec, FailureDetector failureDetector, int? refuseUid)
{
_initialData = initialData;
_localHandshakeInfo = localHandshakeInfo;
Expand Down
Loading

0 comments on commit 5620f02

Please sign in to comment.