Skip to content
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

Added Serialization.DeserializeActorRef method #7237

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ private static string ShardIdMessageFromBinary(byte[] bytes)

private IActorRef ResolveActorRef(string path)
{
return system.Provider.ResolveActorRef(path);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm writing docs for the new Akka.NET website on IActorRef serialization and it's very disjointed - we use Serialization.SerializedActorPath to serialize actors and ExtendedActorSystem.Provider.DeserializeActorRef. I wanted to put an access point for both of these functions (actor reference serialization and deserialization) so it makes more sense to end-users trying to handle this problem on their own.

return system.Serialization.DeserializeActorRef(path);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5228,6 +5228,7 @@ namespace Akka.Serialization
public void AddSerializer(string name, Akka.Serialization.Serializer serializer) { }
public object Deserialize(byte[] bytes, int serializerId, System.Type type) { }
public object Deserialize(byte[] bytes, int serializerId, string manifest) { }
public Akka.Actor.IActorRef DeserializeActorRef(string path) { }
public Akka.Serialization.Serializer FindSerializerFor(object obj, string defaultSerializerName = null) { }
public Akka.Serialization.Serializer FindSerializerForType(System.Type objectType, string defaultSerializerName = null) { }
public static Akka.Serialization.Information GetCurrentTransportInformation() { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5218,6 +5218,7 @@ namespace Akka.Serialization
public void AddSerializer(string name, Akka.Serialization.Serializer serializer) { }
public object Deserialize(byte[] bytes, int serializerId, System.Type type) { }
public object Deserialize(byte[] bytes, int serializerId, string manifest) { }
public Akka.Actor.IActorRef DeserializeActorRef(string path) { }
public Akka.Serialization.Serializer FindSerializerFor(object obj, string defaultSerializerName = null) { }
public Akka.Serialization.Serializer FindSerializerForType(System.Type objectType, string defaultSerializerName = null) { }
public static Akka.Serialization.Information GetCurrentTransportInformation() { }
Expand Down
13 changes: 12 additions & 1 deletion src/core/Akka/Serialization/Serialization.cs
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,17 @@ public Serializer FindSerializerForType(Type objectType, string defaultSerialize
AddSerializationMap(type, serializer);
return serializer;
}

/// <summary>
/// Deserializes an <see cref="IActorRef"/> from its string representation.
/// </summary>
/// <param name="path">The serialized path of the actor represented as a string.</param>
/// <returns>The <see cref="IActorRef"/>. If no such actor exists, it will be (equivalent to) a dead letter reference.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public IActorRef DeserializeActorRef(string path)
{
return System.Provider.ResolveActorRef(path);
}

/// <summary>
/// The serialized path of an actorRef, based on the current transport serialization information.
Expand All @@ -589,7 +600,7 @@ public Serializer FindSerializerForType(Type objectType, string defaultSerialize
public static string SerializedActorPath(IActorRef actorRef)
{
if (Equals(actorRef, ActorRefs.NoSender))
return String.Empty;
return string.Empty;

var path = actorRef.Path;
ExtendedActorSystem originalSystem = null;
Expand Down
Loading