Closed rostikts closed 2 years ago
@dstpierre Hi, the task is still in progress, I'll update the logic according to the Redis cache, but the core of the dev SubPub is done, could you take a look at the Observer
implementation?
Also, I want to clarify a few things:
if msg.Type == internal.MsgTypeChanIn {
msg.Type = internal.MsgTypeChanOut
} else if msg.IsSystemEvent {
Should there be some business logic that I'm not aware of?
Yep, you're deep in SB event / messaging aspect.
This is to prevent an infinite loop for the following scenario:
This entire part of StaticBackend (event / messages) is still in its early design phase.
@rostikts this look good to me so far.
One small thing, I'd rename the dev_observer package either just observer
or devobserver
if we need to keep the "dev", but we could lose it IMO. Same for the dev_cache_observer.go
, i'd just name it observer.go
in the observer
package.
Underscore in package name is to be avoided as much as possible.
Am I understanding correctly that the remaining implementation is for the PublishDocument
function and this would be ready for more test?
Thanks for this PR by the way :wave:
@dstpierre Yep, it's still in progress. You're right, the PublishDocument
function and more tests are planned in the next iteration, it should be ready today, maybe Saturday.
Also, I should review the func (o *memObserver) Publish(channel string, msg interface{}) error
function, I guess I should add here timer with some timeout after which the existing message in the channel will be discarded to avoid the blocking
Add a local observer for the Pub/sub cache events #42
Observer
provides a possibility to subscribe to a specific event and publish a message for all subscribers of the channel. ThememObserver
struct contains a map with a slice of subscribers where the key of the map is a specific channel.The
subscriber
is basically a wrapper for the channel that is listening for the changes