<commit_before>package router

import "github.com/AsynkronIT/protoactor-go/actor"

// process serves as a proxy to the router implementation and forwards messages directly to the routee. This
// optimization avoids serializing router messages through an actor
type process struct {
	router *actor.PID
	state  Interface
}

func (ref *process) SendUserMessage(pid *actor.PID, message interface{}, sender *actor.PID) {
	if _, ok := message.(ManagementMessage); ok {
		r, _ := actor.ProcessRegistry.Get(ref.router)
		r.SendUserMessage(pid, message, sender)
	} else {
		ref.state.RouteMessage(message, sender)
	}
}

func (ref *process) SendSystemMessage(pid *actor.PID, message interface{}) {
	r, _ := actor.ProcessRegistry.Get(ref.router)
	r.SendSystemMessage(pid, message)
}

func (ref *process) Stop(pid *actor.PID) {
	ref.SendSystemMessage(pid, &actor.Stop{})
}
<commit_msg>remove proxy on Stop<commit_after>package router

import "github.com/AsynkronIT/protoactor-go/actor"

// process serves as a proxy to the router implementation and forwards messages directly to the routee. This
// optimization avoids serializing router messages through an actor
type process struct {
	router *actor.PID
	state  Interface
}

func (ref *process) SendUserMessage(pid *actor.PID, message interface{}, sender *actor.PID) {
	if _, ok := message.(ManagementMessage); ok {
		r, _ := actor.ProcessRegistry.Get(ref.router)
		r.SendUserMessage(pid, message, sender)
	} else {
		ref.state.RouteMessage(message, sender)
	}
}

func (ref *process) SendSystemMessage(pid *actor.PID, message interface{}) {
	r, _ := actor.ProcessRegistry.Get(ref.router)
	r.SendSystemMessage(pid, message)
}

func (ref *process) Stop(pid *actor.PID) {
	actor.ProcessRegistry.Remove(pid)
	ref.SendSystemMessage(pid, &actor.Stop{})
}

{'fraction_non_alphanumeric': 0.1185682326621924, 'fraction_numerical': 0.0, 'mean_word_length': 5.085034013605442, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6841267', 'n_tokens_mistral': 569, 'n_tokens_neox': 546, 'n_words': 154}