Skip to content

Commit 76fb692

Browse files
authored
Merge pull request #30 from aschmahmann/feat/subscribeOnPut
Subscribe to PubSub topic before Publishing
2 parents 362e82d + 05e81e9 commit 76fb692

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

pubsub.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,8 @@ func (p *PubsubValueStore) PutValue(ctx context.Context, key string, value []byt
8282
// Encode to "/record/base64url(key)"
8383
topic := KeyToTopic(key)
8484

85-
p.mx.Lock()
86-
_, bootstraped := p.subs[key]
87-
88-
if !bootstraped {
89-
p.subs[key] = nil
90-
p.mx.Unlock()
91-
92-
bootstrapPubsub(p.ctx, p.cr, p.host, topic)
93-
} else {
94-
p.mx.Unlock()
85+
if err := p.Subscribe(key); err != nil {
86+
return err
9587
}
9688

9789
log.Debugf("PubsubPublish: publish value for key", key)

0 commit comments

Comments
 (0)