asynkron / protoactor-go

Proto Actor - Ultra fast distributed actors for Go, C# and Java/Kotlin
http://proto.actor
Apache License 2.0
5.02k stars 521 forks source link

ensureTopicKindRegistered is not a good idea #1007

Open qazwsxedckll opened 8 months ago

qazwsxedckll commented 8 months ago

I wrote a custom topic actor kind with presistency.

    persistenceStore := NewPersistentKeyValueStore(s.logger, s.repo)
    topicActorKind := cluster.NewKind(cluster.TopicActorKind, actor.PropsFromProducer(func() actor.Actor {
        return cluster.NewTopicActor(persistenceStore, s.logger)
    }))

If I forget to configure it on some node, especially in heterogeneous cluster, some topic actor kind without persistency will be spawned and will cause some problem.

func (c *Cluster) ensureTopicKindRegistered() {
    hasTopicKind := false
    for name := range c.kinds {
        if name == TopicActorKind {
            hasTopicKind = true
            break
        }
    }
    if !hasTopicKind {
        store := &EmptyKeyValueStore[*Subscribers]{}

        c.kinds[TopicActorKind] = NewKind(TopicActorKind, actor.PropsFromProducer(func() actor.Actor {
            return NewTopicActor(store, c.Logger())
        })).Build(c)
    }
}

I think it should be added explicitly by user if pubsub functions is used rather than automatically.

AqlaSolutions commented 4 months ago

Same for dotnet