Search Results for

    Show / Hide Table of Contents

    Class ActorPathFormatter

    Built-in IAkkaMessagePackFormatter<T> for ActorPath.

    Inheritance
    object
    ActorPathFormatter
    Implements
    IAkkaMessagePackFormatter<ActorPath>
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: Akka.Serialization.V2
    Assembly: Akka.Serialization.V2.dll
    Syntax
    public sealed class ActorPathFormatter : IAkkaMessagePackFormatter<ActorPath>
    Remarks

    Writes a single transport-aware MessagePack string, mirroring how the generator already serializes IActorRef fields. Address resolution order:

    1. the thread-static transport context (Serialization.CurrentTransportInformation, read directly with a null check — no exception is thrown or caught on the non-transport path), which is set whenever serialization runs underneath Akka.Serialization.Serialization (as it does for everything that goes through ActorSystem.Serialization);
    2. otherwise, when this formatter was constructed with an ExtendedActorSystem — which generated serializers do automatically, since the generator prefers the ExtendedActorSystem constructor — the system's Provider.DefaultAddress, so paths written outside any transport scope are still remotely resolvable, matching Serialization.SerializedActorPath semantics;
    3. otherwise ToSerializationFormat() (address as-is).

    This formatter is transport-sensitive: SizeOf(ActorPath) and Write(ref MessagePackWriter, ActorPath) each read the thread-static transport context independently, so both must run under the same transport scope on the same thread for the exact-size contract to hold. The generated serializers and the Artery encode path do this naturally (size and write happen within one serialization scope); only callers that hand-roll sizing on a different thread or scope can tear.

    Constructors

    | Edit this page View Source

    ActorPathFormatter()

    Initializes a new instance of the ActorPathFormatter class without system context: outside a transport scope, paths are written via ToSerializationFormat() (address as-is).

    Declaration
    public ActorPathFormatter()
    | Edit this page View Source

    ActorPathFormatter(ExtendedActorSystem)

    Initializes a new instance of the ActorPathFormatter class with system context: outside a transport scope, paths are written with the system's default address (Provider.DefaultAddress) so they remain remotely resolvable. Generated serializers use this constructor automatically.

    Declaration
    public ActorPathFormatter(ExtendedActorSystem system)
    Parameters
    Type Name Description
    ExtendedActorSystem system

    The actor system whose default address anchors non-transport writes.

    Methods

    | Edit this page View Source

    Read(ref MessagePackReader)

    Reads a ActorPath value previously written by Write(ref MessagePackWriter, T).

    Declaration
    public ActorPath Read(ref MessagePackReader reader)
    Parameters
    Type Name Description
    MessagePackReader reader

    The MessagePack reader cursor.

    Returns
    Type Description
    ActorPath
    | Edit this page View Source

    SizeOf(ActorPath)

    Returns the exact encoded byte count for value, or UnknownSize when the exact size cannot be cheaply computed.

    Declaration
    public int SizeOf(ActorPath value)
    Parameters
    Type Name Description
    ActorPath value

    The value whose encoded size is being computed.

    Returns
    Type Description
    int
    Remarks

    For transport-sensitive formatters (anything whose encoding consults the thread-static transport context, such as ActorPathFormatter), SizeOf(T) and Write(ref MessagePackWriter, T) read that context independently: both calls must run under the same transport scope on the same thread for the exact-size contract to hold. The generated serializers and the Artery encode path satisfy this naturally by sizing and writing within one serialization scope.

    | Edit this page View Source

    Write(ref MessagePackWriter, ActorPath)

    Writes value to writer.

    Declaration
    public void Write(ref MessagePackWriter writer, ActorPath value)
    Parameters
    Type Name Description
    MessagePackWriter writer

    The MessagePack writer cursor.

    ActorPath value

    The value to write. Never null/absent for non-nullable fields.

    Remarks

    Write MUST produce exactly ONE top-level MessagePack value; wrap multiple values in a single array or map. The generated map framing and the unknown-field forward-compatibility path (reader.Skip()) both depend on one field id mapping to one MessagePack value — multiple top-level values desync older readers during rolling upgrades.

    Implements

    IAkkaMessagePackFormatter<T>

    Extension Methods

    ObjectExtensions.IsDefaultForType<T>(T)
    ObjectExtensions.AsOption<T>(T)
    Extensions.AsInstanceOf<T>(object)
    In this article
    • githubEdit this page
    • View Source
    Back to top
    Contribute
    • Project Chat
    • Discussion Forum
    • Source Code
    Support
    • Akka.NET Support Plans
    • Akka.NET Observability Tools
    • Akka.NET Training & Consulting
    Maintained By
    • Petabridge - The Akka.NET Company
    • Learn Akka.NET