Class ActorPathFormatter
Built-in IAkkaMessagePackFormatter<T> for ActorPath.
Implements
Inherited Members
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:
-
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 underneathAkka.Serialization.Serialization(as it does for everything that goes throughActorSystem.Serialization); -
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, matchingSerialization.SerializedActorPathsemantics; - 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 SourceActorPathFormatter()
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()
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 SourceRead(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 |
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.
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.
Edit this page