COROIO: coroio/actors/actorid.hpp Source File
COROIO
Loading...
Searching...
No Matches
actorid.hpp
1#pragma once
2
3#include <cstdint>
4#include <string>
5
6namespace NNet {
7namespace NActors {
8
10using TLocalActorId = uint32_t;
11
13using TNodeId = uint16_t;
14
16using TCookie = uint16_t;
17
19using TMessageId = uint32_t;
20
32class TActorId {
33public:
35 TActorId() = default;
36
38 bool operator==(const TActorId&) const noexcept = default;
39
44 operator bool() const {
45 return !((NodeId_ == 0) & (ActorId_ == 0) & (Cookie_ == 0));
46 }
47
49 TNodeId NodeId() const {
50 return NodeId_;
51 }
52
54 TLocalActorId ActorId() const {
55 return ActorId_;
56 }
57
59 TCookie Cookie() const {
60 return Cookie_;
61 }
62
67 std::string ToString() const {
68 return "ActorId:"
69 + std::to_string(NodeId_) + ":"
70 + std::to_string(ActorId_) + ":"
71 + std::to_string(Cookie_);
72 }
73
80 TActorId(TNodeId nodeId, TLocalActorId actorId, TCookie cookie)
81 : NodeId_(nodeId)
82 , ActorId_(actorId)
83 , Cookie_(cookie)
84 { }
85
86private:
87 TLocalActorId ActorId_ = 0;
88 TNodeId NodeId_ = 0;
89 TCookie Cookie_ = 0;
90};
91
98struct THeader {
101 TMessageId MessageId = 0;
102 uint32_t Size = 0;
103};
104
105} // namespace NActors
106} // namespace NNet
Globally unique identifier for actors across a distributed system.
Definition actorid.hpp:32
bool operator==(const TActorId &) const noexcept=default
Compares node, local actor identifier, and incarnation cookie.
TNodeId NodeId() const
Get the node ID component.
Definition actorid.hpp:49
TCookie Cookie() const
Get the cookie component.
Definition actorid.hpp:59
TActorId()=default
Default constructor creates an invalid actor ID.
TActorId(TNodeId nodeId, TLocalActorId actorId, TCookie cookie)
Construct actor ID with specific components.
Definition actorid.hpp:80
std::string ToString() const
Convert actor ID to a human-readable string.
Definition actorid.hpp:67
TLocalActorId ActorId() const
Get the local actor ID component.
Definition actorid.hpp:54
Wire header prepended to every remote actor message.
Definition actorid.hpp:98
TActorId Recipient
Destination actor.
Definition actorid.hpp:100
TMessageId MessageId
Message type discriminator.
Definition actorid.hpp:101
uint32_t Size
Payload size in bytes.
Definition actorid.hpp:102
TActorId Sender
Originating actor.
Definition actorid.hpp:99