Repository: Tochemey/goakt
Pull request #254 (2024-03-03 11:43:33)

refactor: provide a way to panic in message handler
Simple wrapper around panic


Patch:
diff --git a/actors/context.go b/actors/context.go
index 046946a..d0cb21a 100644
--- a/actors/context.go
+++ b/actors/context.go
@@ -130,6 +130,9 @@ type ReceiveContext interface {
 	Unhandled()
 	// RemoteReSpawn restarts an actor on a remote node.
 	RemoteReSpawn(host string, port int, name string)
+	// Err is used instead of panicking within a message handler.
+	// One can also call panic which is not the recommended way
+	Err(err error)
 }
 
 type receiveContext struct {
@@ -179,6 +182,13 @@ func (c *receiveContext) Self() PID {
 	return c.recipient
 }
 
+// Err is used instead of panicking within a message handler.
+// One can also call panic which is not the recommended way
+func (c *receiveContext) Err(err error) {
+	// this will be recovered
+	panic(err)
+}
+
 // Response sets the message response
 func (c *receiveContext) Response(resp proto.Message) {
 	c.mu.Lock()
@@ -254,18 +264,20 @@ func (c *receiveContext) Become(behavior Behavior) {
 // Stash enables an actor to temporarily buffer all or some messages that cannot or should not be handled using the actor’s current behavior
 func (c *receiveContext) Stash() {
 	c.mu.Lock()
+	recipient := c.recipient
 	defer c.mu.Unlock()
-	if err := c.recipient.stash(c); err != nil {
-		panic(err)
+	if err := recipient.stash(c); err != nil {
+		c.Err(err)
 	}
 }
 
 // Unstash unstashes the oldest message in the stash and prepends to the mailbox
 func (c *receiveContext) Unstash() {
 	c.mu.Lock()
+	recipient := c.recipient
 	defer c.mu.Unlock()
-	if err := c.recipient.unstash(); err != nil {
-		panic(err)
+	if err := recipient.unstash(); err != nil {
+		c.Err(err)
 	}
 }
 
@@ -273,20 +285,22 @@ func (c *receiveContext) Unstash() {
 // it keeps the messages in the same order as received, unstashing older messages before newer
 func (c *receiveContext) UnstashAll() {
 	c.mu.Lock()
+	recipient := c.recipient
 	defer c.mu.Unlock()
-	if err := c.recipient.unstashAll(); err != nil {
-		panic(err)
+	if err := recipient.unstashAll(); err != nil {
+		c.Err(err)
 	}
 }
 
 // Tell sends an asynchronous message to another PID
 func (c *receiveContext) Tell(to PID, message proto.Message) {
 	c.mu.Lock()
+	recipient := c.recipient
 	defer c.mu.Unlock()
 	// create a new context from the parent context
 	ctx := context.WithoutCancel(c.ctx)
 	// send the message to the recipient or let it crash
-	if err := c.recipient.Tell(ctx, to, message); err != nil {
+	if err := recipient.Tell(ctx, to, message); err != nil {
 		panic(err)
 	}
 }
@@ -297,12 +311,13 @@ func (c *receiveContext) Tell(to PID, message proto.Message) {
 // When BatchTell encounter a single message it will fall back to a Tell call.
 func (c *receiveContext) BatchTell(to PID, messages ...proto.Message) {
 	c.mu.Lock()
+	recipient := c.recipient
 	defer c.mu.Unlock()
 	// create a new context from the parent context
 	ctx := context.WithoutCancel(c.ctx)
 	// send the message to the recipient or let it crash
-	if err := c.recipient.BatchTell(ctx, to, messages...); err != nil {
-		panic(err)
+	if err := recipient.BatchTell(ctx, to, messages...); err != nil {
+		c.Err(err)
 	}
 }
 
@@ -311,13 +326,14 @@ func (c *receiveContext) BatchTell(to PID, messages ...proto.Message) {
 // It is recommended to set a good timeout to quickly receive response and try to avoid false positives
 func (c *receiveContext) Ask(to PID, message proto.Message) (response proto.Message) {
 	c.mu.Lock()
+	recipient := c.recipient
 	defer c.mu.Unlock()
 	// create a new context from the parent context
 	ctx := context.WithoutCancel(c.ctx)
 	// send the message to the recipient or let it crash
-	reply, err := c.recipient.Ask(ctx, to, message)
+	reply, err := recipient.Ask(ctx, to, message)
 	if err != nil {
-		panic(err)
+		c.Err(err)
 	}
 	return reply
 }
@@ -327,13 +343,14 @@ func (c *receiveContext) Ask(to PID, message proto.Message) (response proto.Mess
 // This is a design choice to follow the simple principle of one message at a time processing by actors.
 func (c *receiveContext) BatchAsk(to PID, messages ...proto.Message) (responses chan proto.Message) {
 	c.mu.Lock()
+	recipient := c.recipient
 	defer c.mu.Unlock()
 	// create a new context from the parent context
 	ctx := context.WithoutCancel(c.ctx)
 	// send the message to the recipient or let it crash
-	reply, err := c.recipient.BatchAsk(ctx, to, messages...)
+	reply, err := recipient.BatchAsk(ctx, to, messages...)
 	if err != nil {
-		panic(err)
+		c.Err(err)
 	}
 	return reply
 }
@@ -341,12 +358,13 @@ func (c *receiveContext) BatchAsk(to PID, messages ...proto.Message) (responses
 // RemoteTell sends a message to an actor remotely without expecting any reply
 func (c *receiveContext) RemoteTell(to *goaktpb.Address, message proto.Message) {
 	c.mu.Lock()
+	recipient := c.recipient
 	defer c.mu.Unlock()
 	// create a new context from the parent context
 	ctx := context.WithoutCancel(c.ctx)
 	// send the message to the recipient or let it crash
-	if err := c.recipient.RemoteTell(ctx, to, message); err != nil {
-		panic(err)
+	if err := recipient.RemoteTell(ctx, to, message); err != nil {
+		c.Err(err)
 	}
 }
 
@@ -354,13 +372,14 @@ func (c *receiveContext) RemoteTell(to *goaktpb.Address, message proto.Message)
 // immediately.
 func (c *receiveContext) RemoteAsk(to *goaktpb.Address, message proto.Message) (response *anypb.Any) {
 	c.mu.Lock()
+	recipient := c.recipient
 	defer c.mu.Unlock()
 	// create a new context from the parent context
 	ctx := context.WithoutCancel(c.ctx)
 	// send the message to the recipient or let it crash
-	reply, err := c.recipient.RemoteAsk(ctx, to, message)
+	reply, err := recipient.RemoteAsk(ctx, to, message)
 	if err != nil {
-		panic(err)
+		c.Err(err)
 	}
 	return reply
 }
@@ -369,12 +388,13 @@ func (c *receiveContext) RemoteAsk(to *goaktpb.Address, message proto.Message) (
 // Messages are processed one after the other in the order they are sent.
 func (c *receiveContext) RemoteBatchTell(to *goaktpb.Address, messages ...proto.Message) {
 	c.mu.Lock()
+	recipient := c.recipient
 	defer c.mu.Unlock()
 	// create a new context from the parent context
 	ctx := context.WithoutCancel(c.ctx)
 	// send the message to the recipient and let it crash
-	if err := c.recipient.RemoteBatchTell(ctx, to, messages...); err != nil {
-		panic(err)
+	if err := recipient.RemoteBatchTell(ctx, to, messages...); err != nil {
+		c.Err(err)
 	}
 }
 
@@ -383,13 +403,14 @@ func (c *receiveContext) RemoteBatchTell(to *goaktpb.Address, messages ...proto.
 // This can hinder performance if it is not properly used.
 func (c *receiveContext) RemoteBatchAsk(to *goaktpb.Address, messages ...proto.Message) (responses []*anypb.Any) {
 	c.mu.Lock()
+	recipient := c.recipient
 	defer c.mu.Unlock()
 	// create a new context from the parent context
 	ctx := context.WithoutCancel(c.ctx)
 	// send the message to the recipient or let it crash
-	replies, err := c.recipient.RemoteBatchAsk(ctx, to, messages...)
+	replies, err := recipient.RemoteBatchAsk(ctx, to, messages...)
 	if err != nil {
-		panic(err)
+		c.Err(err)
 	}
 	return replies
 }
@@ -398,13 +419,14 @@ func (c *receiveContext) RemoteBatchAsk(to *goaktpb.Address, messages ...proto.M
 // using the same actor system as the PID actor system
 func (c *receiveContext) RemoteLookup(host string, port int, name string) (addr *goaktpb.Address) {
 	c.mu.Lock()
+	recipient := c.recipient
 	defer c.mu.Unlock()
 	// create a new context from the parent context
 	ctx := context.WithoutCancel(c.ctx)
 	// perform the lookup or let it crash
-	remoteAddr, err := c.recipient.RemoteLookup(ctx, host, port, name)
+	remoteAddr, err := recipient.RemoteLookup(ctx, host, port, name)
 	if err != nil {
-		panic(err)
+		c.Err(err)
 	}
 	return remoteAddr
 }
@@ -414,24 +436,26 @@ func (c *receiveContext) RemoteLookup(host string, port int, name string) (addr
 // that can be configured. All child actors will be gracefully shutdown.
 func (c *receiveContext) Shutdown() {
 	c.mu.Lock()
+	recipient := c.recipient
 	defer c.mu.Unlock()
 	// create a new context from the parent context
 	ctx := context.WithoutCancel(c.ctx)
-	if err := c.recipient.Shutdown(ctx); err != nil {
-		panic(err)
+	if err := recipient.Shutdown(ctx); err != nil {
+		c.Err(err)
 	}
 }
 
 // Spawn creates a child actor or panic
 func (c *receiveContext) Spawn(name string, actor Actor) PID {
 	c.mu.Lock()
+	recipient := c.recipient
 	defer c.mu.Unlock()
 	// create a new context from the parent context
 	ctx := context.WithoutCancel(c.ctx)
 	// create the child actor or let it crash
-	pid, err := c.recipient.SpawnChild(ctx, name, actor)
+	pid, err := recipient.SpawnChild(ctx, name, actor)
 	if err != nil {
-		panic(err)
+		c.Err(err)
 	}
 	return pid
 }
@@ -446,10 +470,11 @@ func (c *receiveContext) Children() []PID {
 // Child returns the named child actor if it is alive
 func (c *receiveContext) Child(name string) PID {
 	c.mu.Lock()
+	recipient := c.recipient
 	defer c.mu.Unlock()
-	pid, err := c.recipient.Child(name)
+	pid, err := recipient.Child(name)
 	if err != nil {
-		panic(err)
+		c.Err(err)
 	}
 	return pid
 }
@@ -458,12 +483,13 @@ func (c *receiveContext) Child(name string) PID {
 // Nothing happens if child is already stopped. However, it panics when the child cannot be stopped.
 func (c *receiveContext) Stop(child PID) {
 	c.mu.Lock()
+	recipient := c.recipient
 	defer c.mu.Unlock()
 	// create a new context from the parent context
 	ctx := context.WithoutCancel(c.ctx)
-	err := c.recipient.Stop(ctx, child)
+	err := recipient.Stop(ctx, child)
 	if err != nil {
-		panic(err)
+		c.Err(err)
 	}
 }
 
@@ -511,11 +537,12 @@ func (c *receiveContext) Unhandled() {
 // RemoteReSpawn restarts an actor on a remote node.
 func (c *receiveContext) RemoteReSpawn(host string, port int, name string) {
 	c.mu.Lock()
+	recipient := c.recipient
 	defer c.mu.Unlock()
 	// create a new context from the parent context
 	ctx := context.WithoutCancel(c.ctx)
-	err := c.recipient.RemoteReSpawn(ctx, host, port, name)
+	err := recipient.RemoteReSpawn(ctx, host, port, name)
 	if err != nil {
-		panic(err)
+		c.Err(err)
 	}
 }
diff --git a/actors/pid.go b/actors/pid.go
index 3235400..5b83bd9 100644
--- a/actors/pid.go
+++ b/actors/pid.go
@@ -332,11 +332,9 @@ func newPID(ctx context.Context, actorPath *Path, actor Actor, opts ...pidOption
 	}
 
 	// push the started message into the actor mailbox
-	_ = Tell(ctx, pid, &goaktpb.Initialized{
-		Id:        pid.ActorPath().String(),
-		Timestamp: timestamppb.Now(),
-		Address:   pid.ActorPath().RemoteAddress(),
-	})
+	context := newReceiveContext(ctx, NoSender, pid, new(goaktpb.PostStart), true)
+	// put the message context in the mailbox of the recipient actor
+	pid.doReceive(context)
 
 	// return the actor reference
 	return pid, nil
@@ -370,18 +368,18 @@ func (p *pid) Child(name string) (PID, error) {
 // Children returns the list of all the children of the given actor that are still alive or an empty list
 func (p *pid) Children() []PID {
 	p.semaphore.RLock()
-	kiddos := p.children.List()
+	children := p.children.List()
 	p.semaphore.RUnlock()
 
 	// create the list of alive children
-	pids := make([]PID, 0, len(kiddos))
-	for _, child := range kiddos {
+	cids := make([]PID, 0, len(children))
+	for _, child := range children {
 		if child.IsRunning() {
-			pids = append(pids, child)
+			cids = append(cids, child)
 		}
 	}
 
-	return pids
+	return cids
 }
 
 // Stop forces the child Actor under the given name to terminate after it finishes processing its current message.
@@ -684,7 +682,7 @@ func (p *pid) Ask(ctx context.Context, to PID, message proto.Message) (response
 			span.RecordError(err)
 			// push the message as a deadletter
 			p.emitDeadletter(context, err)
-			return
+			return nil, err
 		}
 	}
 }
@@ -805,7 +803,7 @@ func (p *pid) BatchAsk(ctx context.Context, to PID, messages ...proto.Message) (
 				// push the message as a deadletter
 				p.emitDeadletter(messageContext, err)
 				// stop the whole processing
-				return
+				return nil, err
 			}
 		}
 	}
diff --git a/goaktpb/goakt.pb.go b/goaktpb/goakt.pb.go
index 1f6c481..d4c4514 100644
--- a/goaktpb/goakt.pb.go
+++ b/goaktpb/goakt.pb.go
@@ -680,22 +680,15 @@ func (*PoisonPill) Descriptor() ([]byte, []int) {
 	return file_goakt_goakt_proto_rawDescGZIP(), []int{10}
 }
 
-// Initialized is used when an actor has successfully initialized
-type Initialized struct {
+// PostStart is used when an actor has successfully started
+type PostStart struct {
 	state         protoimpl.MessageState
 	sizeCache     protoimpl.SizeCache
 	unknownFields protoimpl.UnknownFields
-
-	// Specifies the actor id
-	Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
-	// Specifies the timestamp
-	Timestamp *timestamppb.Timestamp `protobuf:"bytes,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"`
-	// Specifies the actor address
-	Address *Address `protobuf:"bytes,3,opt,name=address,proto3" json:"address,omitempty"`
 }
 
-func (x *Initialized) Reset() {
-	*x = Initialized{}
+func (x *PostStart) Reset() {
+	*x = PostStart{}
 	if protoimpl.UnsafeEnabled {
 		mi := &file_goakt_goakt_proto_msgTypes[11]
 		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@@ -703,13 +696,13 @@ func (x *Initialized) Reset() {
 	}
 }
 
-func (x *Initialized) String() string {
+func (x *PostStart) String() string {
 	return protoimpl.X.MessageStringOf(x)
 }
 
-func (*Initialized) ProtoMessage() {}
+func (*PostStart) ProtoMessage() {}
 
-func (x *Initialized) ProtoReflect() protoreflect.Message {
+func (x *PostStart) ProtoReflect() protoreflect.Message {
 	mi := &file_goakt_goakt_proto_msgTypes[11]
 	if protoimpl.UnsafeEnabled && x != nil {
 		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@@ -721,32 +714,11 @@ func (x *Initialized) ProtoReflect() protoreflect.Message {
 	return mi.MessageOf(x)
 }
 
-// Deprecated: Use Initialized.ProtoReflect.Descriptor instead.
-func (*Initialized) Descriptor() ([]byte, []int) {
+// Deprecated: Use PostStart.ProtoReflect.Descriptor instead.
+func (*PostStart) Descriptor() ([]byte, []int) {
 	return file_goakt_goakt_proto_rawDescGZIP(), []int{11}
 }
 
-func (x *Initialized) GetId() string {
-	if x != nil {
-		return x.Id
-	}
-	return ""
-}
-
-func (x *Initialized) GetTimestamp() *timestamppb.Timestamp {
-	if x != nil {
-		return x.Timestamp
-	}
-	return nil
-}
-
-func (x *Initialized) GetAddress() *Address {
-	if x != nil {
-		return x.Address
-	}
-	return nil
-}
-
 var File_goakt_goakt_proto protoreflect.FileDescriptor
 
 var file_goakt_goakt_proto_rawDesc = []byte{
@@ -830,24 +802,17 @@ var file_goakt_goakt_proto_rawDesc = []byte{
 	0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70,
 	0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x22, 0x0c, 0x0a, 0x0a, 0x54,
 	0x65, 0x72, 0x6d, 0x69, 0x6e, 0x61, 0x74, 0x65, 0x64, 0x22, 0x0c, 0x0a, 0x0a, 0x50, 0x6f, 0x69,
-	0x73, 0x6f, 0x6e, 0x50, 0x69, 0x6c, 0x6c, 0x22, 0x83, 0x01, 0x0a, 0x0b, 0x49, 0x6e, 0x69, 0x74,
-	0x69, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20,
-	0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x38, 0x0a, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73,
-	0x74, 0x61, 0x6d, 0x70, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x1a, 0x2e, 0x67, 0x6f, 0x6f,
-	0x67, 0x6c, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x54, 0x69, 0x6d,
-	0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x52, 0x09, 0x74, 0x69, 0x6d, 0x65, 0x73, 0x74, 0x61, 0x6d,
-	0x70, 0x12, 0x2a, 0x0a, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x18, 0x03, 0x20, 0x01,
-	0x28, 0x0b, 0x32, 0x10, 0x2e, 0x67, 0x6f, 0x61, 0x6b, 0x74, 0x70, 0x62, 0x2e, 0x41, 0x64, 0x64,
-	0x72, 0x65, 0x73, 0x73, 0x52, 0x07, 0x61, 0x64, 0x64, 0x72, 0x65, 0x73, 0x73, 0x42, 0x82, 0x01,
-	0x0a, 0x0b, 0x63, 0x6f, 0x6d, 0x2e, 0x67, 0x6f, 0x61, 0x6b, 0x74, 0x70, 0x62, 0x42, 0x0a, 0x47,
-	0x6f, 0x61, 0x6b, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x48, 0x02, 0x50, 0x01, 0x5a, 0x29, 0x67,
-	0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x74, 0x6f, 0x63, 0x68, 0x65, 0x6d,
-	0x65, 0x79, 0x2f, 0x67, 0x6f, 0x61, 0x6b, 0x74, 0x2f, 0x67, 0x6f, 0x61, 0x6b, 0x74, 0x70, 0x62,
-	0x3b, 0x67, 0x6f, 0x61, 0x6b, 0x74, 0x70, 0x62, 0xa2, 0x02, 0x03, 0x47, 0x58, 0x58, 0xaa, 0x02,
-	0x07, 0x47, 0x6f, 0x61, 0x6b, 0x74, 0x70, 0x62, 0xca, 0x02, 0x07, 0x47, 0x6f, 0x61, 0x6b, 0x74,
-	0x70, 0x62, 0xe2, 0x02, 0x13, 0x47, 0x6f, 0x61, 0x6b, 0x74, 0x70, 0x62, 0x5c, 0x47, 0x50, 0x42,
-	0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x07, 0x47, 0x6f, 0x61, 0x6b, 0x74,
-	0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+	0x73, 0x6f, 0x6e, 0x50, 0x69, 0x6c, 0x6c, 0x22, 0x0b, 0x0a, 0x09, 0x50, 0x6f, 0x73, 0x74, 0x53,
+	0x74, 0x61, 0x72, 0x74, 0x42, 0x82, 0x01, 0x0a, 0x0b, 0x63, 0x6f, 0x6d, 0x2e, 0x67, 0x6f, 0x61,
+	0x6b, 0x74, 0x70, 0x62, 0x42, 0x0a, 0x47, 0x6f, 0x61, 0x6b, 0x74, 0x50, 0x72, 0x6f, 0x74, 0x6f,
+	0x48, 0x02, 0x50, 0x01, 0x5a, 0x29, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d,
+	0x2f, 0x74, 0x6f, 0x63, 0x68, 0x65, 0x6d, 0x65, 0x79, 0x2f, 0x67, 0x6f, 0x61, 0x6b, 0x74, 0x2f,
+	0x67, 0x6f, 0x61, 0x6b, 0x74, 0x70, 0x62, 0x3b, 0x67, 0x6f, 0x61, 0x6b, 0x74, 0x70, 0x62, 0xa2,
+	0x02, 0x03, 0x47, 0x58, 0x58, 0xaa, 0x02, 0x07, 0x47, 0x6f, 0x61, 0x6b, 0x74, 0x70, 0x62, 0xca,
+	0x02, 0x07, 0x47, 0x6f, 0x61, 0x6b, 0x74, 0x70, 0x62, 0xe2, 0x02, 0x13, 0x47, 0x6f, 0x61, 0x6b,
+	0x74, 0x70, 0x62, 0x5c, 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea,
+	0x02, 0x07, 0x47, 0x6f, 0x61, 0x6b, 0x74, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
+	0x33,
 }
 
 var (
@@ -875,7 +840,7 @@ var file_goakt_goakt_proto_goTypes = []interface{}{
 	(*NodeLeft)(nil),              // 8: goaktpb.NodeLeft
 	(*Terminated)(nil),            // 9: goaktpb.Terminated
 	(*PoisonPill)(nil),            // 10: goaktpb.PoisonPill
-	(*Initialized)(nil),           // 11: goaktpb.Initialized
+	(*PostStart)(nil),             // 11: goaktpb.PostStart
 	(*anypb.Any)(nil),             // 12: google.protobuf.Any
 	(*timestamppb.Timestamp)(nil), // 13: google.protobuf.Timestamp
 }
@@ -897,13 +862,11 @@ var file_goakt_goakt_proto_depIdxs = []int32{
 	13, // 14: goaktpb.ActorRestarted.restarted_at:type_name -> google.protobuf.Timestamp
 	13, // 15: goaktpb.NodeJoined.timestamp:type_name -> google.protobuf.Timestamp
 	13, // 16: goaktpb.NodeLeft.timestamp:type_name -> google.protobuf.Timestamp
-	13, // 17: goaktpb.Initialized.timestamp:type_name -> google.protobuf.Timestamp
-	0,  // 18: goaktpb.Initialized.address:type_name -> goaktpb.Address
-	19, // [19:19] is the sub-list for method output_type
-	19, // [19:19] is the sub-list for method input_type
-	19, // [19:19] is the sub-list for extension type_name
-	19, // [19:19] is the sub-list for extension extendee
-	0,  // [0:19] is the sub-list for field type_name
+	17, // [17:17] is the sub-list for method output_type
+	17, // [17:17] is the sub-list for method input_type
+	17, // [17:17] is the sub-list for extension type_name
+	17, // [17:17] is the sub-list for extension extendee
+	0,  // [0:17] is the sub-list for field type_name
 }
 
 func init() { file_goakt_goakt_proto_init() }
@@ -1045,7 +1008,7 @@ func file_goakt_goakt_proto_init() {
 			}
 		}
 		file_goakt_goakt_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} {
-			switch v := v.(*Initialized); i {
+			switch v := v.(*PostStart); i {
 			case 0:
 				return &v.state
 			case 1:
diff --git a/protos/goakt/goakt.proto b/protos/goakt/goakt.proto
index d49eccd..0640d9c 100644
--- a/protos/goakt/goakt.proto
+++ b/protos/goakt/goakt.proto
@@ -101,12 +101,5 @@ message Terminated {}
 // It will be handled after messages that were already queued in the mailbox.
 message PoisonPill {}
 
-// Initialized is used when an actor has successfully initialized
-message Initialized {
-  // Specifies the actor id
-  string id = 1;
-  // Specifies the timestamp
-  google.protobuf.Timestamp timestamp = 2;
-  // Specifies the actor address
-  Address address = 3;
-}
+// PostStart is used when an actor has successfully started
+message PostStart {}


Test patch:
diff --git a/actors/actor_test.go b/actors/actor_test.go
index 2d48a0e..d522019 100644
--- a/actors/actor_test.go
+++ b/actors/actor_test.go
@@ -84,7 +84,7 @@ func (p *Tester) PostStop(context.Context) error {
 // Receive processes any message dropped into the actor mailbox without a reply
 func (p *Tester) Receive(ctx ReceiveContext) {
 	switch ctx.Message().(type) {
-	case *goaktpb.Initialized:
+	case *goaktpb.PostStart:
 	case *testspb.TestSend:
 		p.counter.Inc()
 	case *testspb.TestPanic:
@@ -124,7 +124,7 @@ func (p *Monitor) PreStart(context.Context) error {
 
 func (p *Monitor) Receive(ctx ReceiveContext) {
 	switch ctx.Message().(type) {
-	case *goaktpb.Initialized:
+	case *goaktpb.PostStart:
 	case *testspb.TestSend:
 	default:
 		panic(ErrUnhandled)
@@ -152,7 +152,7 @@ func (c *Monitored) PreStart(context.Context) error {
 
 func (c *Monitored) Receive(ctx ReceiveContext) {
 	switch ctx.Message().(type) {
-	case *goaktpb.Initialized:
+	case *goaktpb.PostStart:
 	case *testspb.TestSend:
 	case *testspb.TestPanic:
 		panic("panicked")
@@ -181,7 +181,7 @@ func (x *UserActor) PostStop(_ context.Context) error {
 
 func (x *UserActor) Receive(ctx ReceiveContext) {
 	switch ctx.Message().(type) {
-	case *goaktpb.Initialized:
+	case *goaktpb.PostStart:
 	case *testspb.TestLogin:
 		ctx.Response(new(testspb.TestLoginSuccess))
 		ctx.Become(x.Authenticated)
@@ -194,7 +194,7 @@ func (x *UserActor) Receive(ctx ReceiveContext) {
 // Authenticated behavior is executed when the actor receive the TestAuth message
 func (x *UserActor) Authenticated(ctx ReceiveContext) {
 	switch ctx.Message().(type) {
-	case *goaktpb.Initialized:
+	case *goaktpb.PostStart:
 	case *testspb.TestReadiness:
 		ctx.Response(new(testspb.TestReady))
 		ctx.UnBecome()
@@ -203,7 +203,7 @@ func (x *UserActor) Authenticated(ctx ReceiveContext) {
 
 func (x *UserActor) CreditAccount(ctx ReceiveContext) {
 	switch ctx.Message().(type) {
-	case *goaktpb.Initialized:
+	case *goaktpb.PostStart:
 	case *testspb.CreditAccount:
 		ctx.Response(new(testspb.AccountCredited))
 		ctx.BecomeStacked(x.DebitAccount)
@@ -214,7 +214,7 @@ func (x *UserActor) CreditAccount(ctx ReceiveContext) {
 
 func (x *UserActor) DebitAccount(ctx ReceiveContext) {
 	switch ctx.Message().(type) {
-	case *goaktpb.Initialized:
+	case *goaktpb.PostStart:
 	case *testspb.DebitAccount:
 		ctx.Response(new(testspb.AccountDebited))
 		ctx.UnBecomeStacked()
@@ -230,7 +230,7 @@ func (e *Exchanger) PreStart(context.Context) error {
 func (e *Exchanger) Receive(ctx ReceiveContext) {
 	message := ctx.Message()
 	switch message.(type) {
-	case *goaktpb.Initialized:
+	case *goaktpb.PostStart:
 	case *testspb.TestSend:
 		_ = ctx.Self().Tell(ctx.Context(), ctx.Sender(), new(testspb.TestSend))
 	case *testspb.TestReply:
@@ -256,7 +256,7 @@ func (x *Stasher) PreStart(context.Context) error {
 
 func (x *Stasher) Receive(ctx ReceiveContext) {
 	switch ctx.Message().(type) {
-	case *goaktpb.Initialized:
+	case *goaktpb.PostStart:
 	case *testspb.TestStash:
 		ctx.Become(x.Ready)
 		ctx.Stash()
@@ -268,7 +268,7 @@ func (x *Stasher) Receive(ctx ReceiveContext) {
 
 func (x *Stasher) Ready(ctx ReceiveContext) {
 	switch ctx.Message().(type) {
-	case *goaktpb.Initialized:
+	case *goaktpb.PostStart:
 	case *testspb.TestStash:
 	case *testspb.TestLogin:
 		ctx.Stash()
@@ -310,7 +310,7 @@ func (x *PostStopBreaker) PreStart(context.Context) error {
 
 func (x *PostStopBreaker) Receive(ctx ReceiveContext) {
 	switch ctx.Message().(type) {
-	case *goaktpb.Initialized:
+	case *goaktpb.PostStart:
 	case *testspb.TestSend:
 	case *testspb.TestPanic:
 		panic("panicked")
@@ -360,7 +360,7 @@ func (x *Forwarder) PreStart(context.Context) error {
 
 func (x *Forwarder) Receive(ctx ReceiveContext) {
 	switch ctx.Message().(type) {
-	case *goaktpb.Initialized:
+	case *goaktpb.PostStart:
 	case *testspb.TestBye:
 		ctx.Forward(x.actorRef)
 	}
@@ -382,7 +382,7 @@ func (d *Discarder) PreStart(context.Context) error {
 
 func (d *Discarder) Receive(ctx ReceiveContext) {
 	switch ctx.Message().(type) {
-	case *goaktpb.Initialized:
+	case *goaktpb.PostStart:
 		// pass
 	default:
 		ctx.Unhandled()
diff --git a/testkit/probe.go b/testkit/probe.go
index 9346bd4..6d84d05 100644
--- a/testkit/probe.go
+++ b/testkit/probe.go
@@ -69,7 +69,7 @@ func (x *probeActor) Receive(ctx actors.ReceiveContext) {
 	// skip system message
 	case *goaktpb.PoisonPill,
 		*goaktpb.Terminated,
-		*goaktpb.Initialized:
+		*goaktpb.PostStart:
 	// pass
 	default:
 		// any message received is pushed to the queue