Skip to content

Commit

Permalink
Deprecating Service Remoting V1 stack
Browse files Browse the repository at this point in the history
This is the first step towards moving to Service Remoting V2 completely. 

All code that is part of the Service Remoting V1 stack have been marked as obsolete and will be removed in the future.
In parts of the code that reference code form both the V1 and V2 stack, pragmas are used to suppress CS0618 (obsolete) warnings, so that the SDK packages can be built. Once the transition to V2 is fully complete, this suppression will not be needed.

From now on, when using service or actor remoting, it is necessary to specify the remoting stack explicitly using assembly attributes, otherwise an exception will be raised. User who are already using V2 stack will not see a difference after upgrading to the new SDK. Users who are still using V1 stack by default will have to make a conscious decision to continue using V1 stack or to upgrade to V2 when upgrading to the new SDK.
  • Loading branch information
plave0 authored Feb 25, 2025
1 parent bdf3d05 commit d8da8df
Show file tree
Hide file tree
Showing 94 changed files with 549 additions and 71 deletions.
1 change: 1 addition & 0 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

<ItemGroup>
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
<PackageVersion Include="inspector" Version="0.1.30" />
<PackageVersion Include="Microsoft.AspNetCore.Diagnostics" Version="2.1.1" />
<PackageVersion Include="Microsoft.AspNetCore.Hosting" Version="2.1.1" />
<PackageVersion Include="Microsoft.AspNetCore.Http" Version="2.1.34" /> <!-- Transitive dependency -->
Expand Down
2 changes: 1 addition & 1 deletion properties/service_fabric_common.props
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<!-- TODO: Versions numbers are changed here manually for now, Integrate this with GitVersion. -->
<MajorVersion>8</MajorVersion>
<MinorVersion>0</MinorVersion>
<BuildVersion>10</BuildVersion>
<BuildVersion>11</BuildVersion>
<Revision>0</Revision>

</PropertyGroup>
Expand Down
4 changes: 4 additions & 0 deletions src/FabActUtil/Generator/ManifestGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -561,10 +561,12 @@ private static Dictionary<string, Func<ActorTypeInformation, string>> GetGenerat
{
var generatedNameFunctions = new Dictionary<string, Func<ActorTypeInformation, string>>();
#if !DotNetCoreClr
#pragma warning disable 618
if (Helper.IsRemotingV1(actorTypeInfo.RemotingListenerVersion))
{
generatedNameFunctions.Add(GeneratedServiceEndpointName, GetFabricServiceEndpointName);
}
#pragma warning restore 618
#endif
if (Helper.IsRemotingV2(actorTypeInfo.RemotingListenerVersion))
{
Expand All @@ -583,6 +585,7 @@ private static List<EndpointType> CreateEndpointResourceBasedOnRemotingServer(Ac
{
var endpoints = new List<EndpointType>();
#if !DotNetCoreClr
#pragma warning disable 618
if (Helper.IsRemotingV1(actorTypeInfo.RemotingListenerVersion))
{
endpoints.Add(
Expand All @@ -591,6 +594,7 @@ private static List<EndpointType> CreateEndpointResourceBasedOnRemotingServer(Ac
Name = GetFabricServiceEndpointName(actorTypeInfo),
});
}
#pragma warning restore 618
#endif
if (Helper.IsRemotingV2(actorTypeInfo.RemotingListenerVersion))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

namespace Microsoft.ServiceFabric.Actors.Remoting.V1.Wcf.Client
{
using System;
using System.Collections.Generic;
using System.ServiceModel.Channels;
using Microsoft.ServiceFabric.Actors.Remoting.Client;
Expand All @@ -20,6 +21,7 @@ namespace Microsoft.ServiceFabric.Actors.Remoting.V1.Wcf.Client
/// to communicate with an actor service and actors hosted by it, using actor and service interfaces that are remoted via
/// <see cref="Microsoft.ServiceFabric.Actors.Remoting.V1.Wcf.Runtime.WcfActorServiceRemotingListener"/>.
/// </summary>
[Obsolete(Services.Remoting.DeprecationMessage.RemotingV1)]
public class WcfActorRemotingClientFactory : WcfServiceRemotingClientFactory
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace Microsoft.ServiceFabric.Actors.Remoting.V1.Wcf.Runtime
/// An <see cref="IServiceRemotingListener"/> that uses
/// Windows Communication Foundation to provide interface remoting for actor services.
/// </summary>
[Obsolete(Services.Remoting.DeprecationMessage.RemotingV1)]
public class WcfActorServiceRemotingListener : WcfServiceRemotingListener
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public long CloseTimeoutInMilliSeconds
/// that can be used with <see cref="ActorProxyFactory"/> to
/// generate actor proxy to talk to the actor over remoted actor interface.
/// </returns>
[Obsolete(Services.Remoting.DeprecationMessage.RemotingV1)]
public override Microsoft.ServiceFabric.Services.Remoting.V1.Client.IServiceRemotingClientFactory CreateServiceRemotingClientFactory(
Microsoft.ServiceFabric.Services.Remoting.V1.IServiceRemotingCallbackClient callbackClient)
{
Expand Down Expand Up @@ -151,6 +152,7 @@ public override IServiceRemotingClientFactory CreateServiceRemotingClientFactory
/// An <see cref="IServiceRemotingListener"/>
/// for the specified actor service.
/// </returns>
[Obsolete(Services.Remoting.DeprecationMessage.RemotingV1)]
public override IServiceRemotingListener CreateServiceRemotingListener(
ActorService actorService)
{
Expand Down
2 changes: 2 additions & 0 deletions src/Microsoft.ServiceFabric.Actors/ActorReference.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ private static ActorReference GetActorReference(object actor)
if (actor is IActorProxy actorProxy)
{
#if !DotNetCoreClr
#pragma warning disable 618
if (actorProxy.ActorServicePartitionClient != null)
{
return new ActorReference()
Expand All @@ -94,6 +95,7 @@ private static ActorReference GetActorReference(object actor)
ListenerName = actorProxy.ActorServicePartitionClient.ListenerName,
};
}
#pragma warning restore 618
#endif
return new ActorReference()
{
Expand Down
18 changes: 18 additions & 0 deletions src/Microsoft.ServiceFabric.Actors/Client/ActorProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ public abstract class ActorProxy : ProxyBase, IActorProxy
private RemotingClientVersion remotingClient;

#if !DotNetCoreClr
[Obsolete(Services.Remoting.DeprecationMessage.RemotingV1)]
private Remoting.V1.Builder.ActorProxyGeneratorWith proxyGeneratorWith;
[Obsolete(Services.Remoting.DeprecationMessage.RemotingV1)]
private Remoting.V1.Client.ActorServicePartitionClient servicePartitionClient;
#endif

Expand All @@ -49,7 +51,9 @@ public ActorId ActorId
#if !DotNetCoreClr
if (!(Helper.IsEitherRemotingV2(this.remotingClient)))
{
#pragma warning disable 618
return this.servicePartitionClient.ActorId;
#pragma warning restore 618
}
#endif
return this.servicePartitionClientV2.ActorId;
Expand All @@ -61,6 +65,7 @@ public ActorId ActorId
/// Gets the <see cref="Remoting.V1.Client.IActorServicePartitionClient"/> interface that this proxy is using to communicate with the actor.
/// </summary>
/// <value><see cref="Remoting.V1.Client.IActorServicePartitionClient"/> that this proxy is using to communicate with the actor.</value>
[Obsolete(Services.Remoting.DeprecationMessage.RemotingV1)]
public Remoting.V1.Client.IActorServicePartitionClient ActorServicePartitionClient
{
get { return this.servicePartitionClient; }
Expand Down Expand Up @@ -246,26 +251,31 @@ internal async Task UnsubscribeAsyncV2(Type eventType, object subscriber)

#if !DotNetCoreClr

[Obsolete(Services.Remoting.DeprecationMessage.RemotingV1)]
internal override DataContractSerializer GetRequestMessageBodySerializer(int interfaceId)
{
return this.proxyGeneratorWith.GetRequestMessageBodySerializer(interfaceId);
}

[Obsolete(Services.Remoting.DeprecationMessage.RemotingV1)]
internal override DataContractSerializer GetResponseMessageBodySerializer(int interfaceId)
{
return this.proxyGeneratorWith.GetResponseMessageBodySerializer(interfaceId);
}

[Obsolete(Services.Remoting.DeprecationMessage.RemotingV1)]
internal override object GetResponseMessageBodyValue(object responseMessageBody)
{
return ((Remoting.V1.ActorMessageBody)responseMessageBody).Value;
}

[Obsolete(Services.Remoting.DeprecationMessage.RemotingV1)]
internal override object CreateRequestMessageBody(object requestMessageBodyValue)
{
return new Remoting.V1.ActorMessageBody() { Value = requestMessageBodyValue };
}

[Obsolete(Services.Remoting.DeprecationMessage.RemotingV1)]
internal override Task<byte[]> InvokeAsync(
int interfaceId,
int methodId,
Expand All @@ -283,6 +293,7 @@ internal override Task<byte[]> InvokeAsync(
return this.servicePartitionClient.InvokeAsync(actorMsgHeaders, requestMsgBodyBytes, cancellationToken);
}

[Obsolete(Services.Remoting.DeprecationMessage.RemotingV1)]
internal override void Invoke(
int interfaceId,
int methodId,
Expand All @@ -293,6 +304,7 @@ internal override void Invoke(
throw new NotImplementedException();
}

[Obsolete(Services.Remoting.DeprecationMessage.RemotingV1)]
internal void Initialize(
Remoting.V1.Builder.ActorProxyGeneratorWith actorProxyGeneratorWith,
Remoting.V1.Client.ActorServicePartitionClient actorServicePartitionClient)
Expand All @@ -314,6 +326,7 @@ internal async Task SubscribeAsync(Type eventType, object subscriber, TimeSpan r
}

#if !DotNetCoreClr
#pragma warning disable 618
var actorId = this.servicePartitionClient.ActorId;
var info = Remoting.V1.Client.ActorEventSubscriberManager.Instance.RegisterSubscriber(
actorId,
Expand Down Expand Up @@ -345,6 +358,7 @@ internal async Task SubscribeAsync(Type eventType, object subscriber, TimeSpan r
}

this.ResubscribeAsync(info, resubscriptionInterval);
#pragma warning restore 618
#endif
}

Expand All @@ -356,6 +370,7 @@ internal async Task UnsubscribeAsync(Type eventType, object subscriber)
return;
}
#if !DotNetCoreClr
#pragma warning disable 618
var actorId = this.servicePartitionClient.ActorId;
if (Remoting.V1.Client.ActorEventSubscriberManager.Instance.TryUnregisterSubscriber(
actorId,
Expand All @@ -365,13 +380,15 @@ internal async Task UnsubscribeAsync(Type eventType, object subscriber)
{
await this.servicePartitionClient.UnsubscribeAsync(info.Subscriber.EventId, info.Id);
}
#pragma warning restore 618
#endif
}

#if !DotNetCoreClr
private void ResubscribeAsync(SubscriptionInfo info, TimeSpan resubscriptionInterval)
{
#pragma warning disable 4014
#pragma warning disable 618
// ReSharper disable once UnusedVariable
var ignore = Task.Run(
async () =>
Expand Down Expand Up @@ -399,6 +416,7 @@ private void ResubscribeAsync(SubscriptionInfo info, TimeSpan resubscriptionInte
}
});
}
#pragma warning restore 618
#endif

private void ResubscribeAsyncV2(SubscriptionInfo info, TimeSpan resubscriptionInterval)
Expand Down
25 changes: 17 additions & 8 deletions src/Microsoft.ServiceFabric.Actors/Client/ActorProxyFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class ActorProxyFactory : IActorProxyFactory
private readonly OperationRetrySettings retrySettings;

#if !DotNetCoreClr
[Obsolete(Services.Remoting.DeprecationMessage.RemotingV1)]
private Remoting.V1.Client.ActorProxyFactory proxyFactoryV1;
#endif
private Remoting.V2.Client.ActorProxyFactory proxyFactoryV2;
Expand All @@ -42,6 +43,7 @@ public ActorProxyFactory(OperationRetrySettings retrySettings = null)
/// </summary>
/// <param name="createServiceRemotingClientFactory">Factory method to create remoting communication client factory.</param>
/// <param name="retrySettings">Retry settings for the remote object calls made by proxy.</param>
[Obsolete(Services.Remoting.DeprecationMessage.RemotingV1)]
public ActorProxyFactory(
Func<Services.Remoting.V1.IServiceRemotingCallbackClient,
Services.Remoting.V1.Client.IServiceRemotingClientFactory>
Expand Down Expand Up @@ -198,10 +200,12 @@ public TServiceInterface CreateActorServiceProxy<TServiceInterface>(
public void Dispose()
{
#if !DotNetCoreClr
#pragma warning disable 618
if (this.proxyFactoryV1 != null)
{
this.proxyFactoryV1.Dispose();
}
#pragma warning restore 618
#endif
if (this.proxyFactoryV2 != null)
{
Expand All @@ -217,6 +221,7 @@ internal object CreateActorProxy(
{
this.GetOrSetProxyFactory(actorInterfaceType);
#if !DotNetCoreClr
#pragma warning disable 618
if (this.proxyFactoryV1 != null)
{
return this.proxyFactoryV1.CreateActorProxy(
Expand All @@ -225,6 +230,7 @@ internal object CreateActorProxy(
actorId,
this.OverrideListenerNameIfConditionMet(listenerName));
}
#pragma warning restore 618
#endif

return this.proxyFactoryV2.CreateActorProxy(
Expand All @@ -244,13 +250,14 @@ private IActorProxyFactory GetOrSetProxyFactory(Type actorInterfaceType)
#if !DotNetCoreClr

// Use provider to find the stack
#pragma warning disable 618
if (this.proxyFactoryV1 == null && this.proxyFactoryV2 == null)
{
lock (this.thisLock)
{
if (this.proxyFactoryV1 == null && this.proxyFactoryV2 == null)
{
var provider = this.GetProviderAttribute(actorInterfaceType);
if (this.proxyFactoryV1 == null && this.proxyFactoryV2 == null)
{
var provider = this.GetProviderAttribute(actorInterfaceType);
if (Helper.IsEitherRemotingV2(provider.RemotingClientVersion))
{
// We are overriding listenerName since using provider service can have multiple listener configured for upgrade cases
Expand All @@ -259,20 +266,22 @@ private IActorProxyFactory GetOrSetProxyFactory(Type actorInterfaceType)
new Remoting.V2.Client.ActorProxyFactory(provider.CreateServiceRemotingClientFactory, this.retrySettings);
return this.proxyFactoryV2;
}

this.proxyFactoryV1 =
this.proxyFactoryV1 =
new Remoting.V1.Client.ActorProxyFactory(provider.CreateServiceRemotingClientFactory, this.retrySettings);
return this.proxyFactoryV1;
}

return this.proxyFactoryV1;
#pragma warning restore 618
}
}
}

if (this.proxyFactoryV2 != null)
{
return this.proxyFactoryV2;
}

#pragma warning disable 618
return this.proxyFactoryV1;
#pragma warning restore 618

#else
if (this.proxyFactoryV2 == null)
Expand Down
3 changes: 3 additions & 0 deletions src/Microsoft.ServiceFabric.Actors/Client/IActorProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
// Licensed under the MIT License (MIT). See License.txt in the repo root for license information.
// ------------------------------------------------------------

using System;

namespace Microsoft.ServiceFabric.Actors.Client
{
/// <summary>
Expand All @@ -21,6 +23,7 @@ public interface IActorProxy
/// Gets <see cref="Remoting.V1.Client.IActorServicePartitionClient"/> that this proxy is using to communicate with the actor.
/// </summary>
/// <value><see cref="Remoting.V1.Client.IActorServicePartitionClient"/> that this proxy is using to communicate with the actor.</value>
[Obsolete(Services.Remoting.DeprecationMessage.RemotingV1)]
Remoting.V1.Client.IActorServicePartitionClient ActorServicePartitionClient { get; }
#endif

Expand Down
Loading

0 comments on commit d8da8df

Please sign in to comment.