1 Star 0 Fork 0

jack/protoactor-go

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
identity_storage_lookup.go 1.62 KB
一键复制 编辑 原始数据 按行查看 历史
490689386@qq.com 提交于 2025-05-19 14:50 +08:00 . 初始化
package cluster
import (
"time"
"gitee.com/wujianhai/protoactor-go/actor"
)
const (
placementActorName = "placement-activator"
pidClusterIdentityStartIndex = len(placementActorName) + 1
)
// IdentityStorageLookup contains
type IdentityStorageLookup struct {
Storage StorageLookup
cluster *Cluster
isClient bool
placementActor *actor.PID
system *actor.ActorSystem
router *actor.PID
memberID string
}
func newIdentityStorageLookup(storage StorageLookup) *IdentityStorageLookup {
this := &IdentityStorageLookup{
Storage: storage,
}
return this
}
// RemoveMember from identity storage
func (i *IdentityStorageLookup) RemoveMember(memberID string) {
i.Storage.RemoveMemberId(memberID)
}
// RemotePlacementActor returns the PID of the remote placement actor
func RemotePlacementActor(address string) *actor.PID {
return actor.NewPID(address, placementActorName)
}
//
// Interface: IdentityLookup
//
// Get returns a PID for a given ClusterIdentity
func (id *IdentityStorageLookup) Get(clusterIdentity *ClusterIdentity) *actor.PID {
msg := newGetPid(clusterIdentity)
timeout := 5 * time.Second
res, _ := id.system.Root.RequestFuture(id.router, msg, timeout).Result()
response := res.(*actor.Future)
return response.PID()
}
func (id *IdentityStorageLookup) Setup(cluster *Cluster, kinds []string, isClient bool) {
id.cluster = cluster
id.system = cluster.ActorSystem
id.memberID = cluster.ActorSystem.ID
// workerProps := actor.PropsFromProducer(func() actor.Actor { return newIdentityStorageWorker(identity) })
// routerProps := identity.system.Root.(workerProps, 50);
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wujianhai/protoactor-go.git
git@gitee.com:wujianhai/protoactor-go.git
wujianhai
protoactor-go
protoactor-go
5633fe2499dd

搜索帮助