github.com/asynkron/protoactor-go@v0.0.0-20240308120642-ef91a6abee75/cluster/identitylookup/disthash/identity_lookup.go (about)

     1  package disthash
     2  
     3  import (
     4  	"github.com/asynkron/protoactor-go/actor"
     5  	"github.com/asynkron/protoactor-go/cluster"
     6  )
     7  
     8  type IdentityLookup struct {
     9  	partitionManager *Manager
    10  }
    11  
    12  func (p *IdentityLookup) Get(clusterIdentity *cluster.ClusterIdentity) *actor.PID {
    13  	return p.partitionManager.Get(clusterIdentity)
    14  }
    15  
    16  func (p *IdentityLookup) RemovePid(clusterIdentity *cluster.ClusterIdentity, pid *actor.PID) {
    17  	activationTerminated := &cluster.ActivationTerminated{
    18  		Pid:             pid,
    19  		ClusterIdentity: clusterIdentity,
    20  	}
    21  	p.partitionManager.cluster.MemberList.BroadcastEvent(activationTerminated, true)
    22  }
    23  
    24  func (p *IdentityLookup) Setup(cluster *cluster.Cluster, kinds []string, isClient bool) {
    25  	p.partitionManager = newPartitionManager(cluster)
    26  	p.partitionManager.Start()
    27  }
    28  
    29  func (p *IdentityLookup) Shutdown() {
    30  	p.partitionManager.Stop()
    31  }
    32  
    33  func New() cluster.IdentityLookup {
    34  	return &IdentityLookup{}
    35  }