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

     1  package cluster
     2  
     3  import (
     4  	"github.com/asynkron/protoactor-go/actor"
     5  	"github.com/asynkron/protoactor-go/ctxext"
     6  )
     7  
     8  func (ci *ClusterIdentity) AsKey() string {
     9  	return ci.Kind + "/" + ci.Identity
    10  }
    11  
    12  var ciExtensionId = ctxext.NextContextExtensionID()
    13  
    14  // remove
    15  func (ci *ClusterIdentity) ToShortString() string {
    16  	return ci.Kind + "/" + ci.Identity
    17  }
    18  
    19  func NewClusterIdentity(identity string, kind string) *ClusterIdentity {
    20  	return &ClusterIdentity{
    21  		Identity: identity,
    22  		Kind:     kind,
    23  	}
    24  }
    25  
    26  func (ci *ClusterIdentity) ExtensionID() ctxext.ContextExtensionID {
    27  	return ciExtensionId
    28  }
    29  
    30  func GetClusterIdentity(ctx actor.ExtensionContext) *ClusterIdentity {
    31  	return ctx.Get(ciExtensionId).(*ClusterIdentity)
    32  }
    33  
    34  func SetClusterIdentity(ctx actor.ExtensionContext, ci *ClusterIdentity) {
    35  	ctx.Set(ci)
    36  }