github.com/asynkron/protoactor-go@v0.0.0-20240308120642-ef91a6abee75/cluster/grain_context.go (about) 1 package cluster 2 3 import ( 4 "github.com/asynkron/protoactor-go/actor" 5 ) 6 7 type GrainContext interface { 8 actor.Context 9 10 Identity() string 11 Kind() string 12 Cluster() *Cluster 13 } 14 15 var _ actor.Context = GrainContext(&grainContextImpl{}) 16 17 type grainContextImpl struct { 18 actor.Context 19 ci *ClusterIdentity 20 cluster *Cluster 21 } 22 23 func (g grainContextImpl) Identity() string { 24 return g.ci.Identity 25 } 26 27 func (g grainContextImpl) Kind() string { 28 return g.ci.Kind 29 } 30 31 func (g grainContextImpl) Cluster() *Cluster { 32 return g.cluster 33 } 34 35 func NewGrainContext(context actor.Context, identity *ClusterIdentity, cluster *Cluster) GrainContext { 36 return &grainContextImpl{ 37 Context: context, 38 ci: identity, 39 cluster: cluster, 40 } 41 }