Skip to content

Commit

Permalink
Merge pull request #30 from aschmahmann/feat/subscribeOnPut
Browse files Browse the repository at this point in the history
Subscribe to PubSub topic before Publishing
  • Loading branch information
Stebalien authored May 3, 2019
2 parents 362e82d + 05e81e9 commit 76fb692
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,8 @@ func (p *PubsubValueStore) PutValue(ctx context.Context, key string, value []byt
// Encode to "/record/base64url(key)"
topic := KeyToTopic(key)

p.mx.Lock()
_, bootstraped := p.subs[key]

if !bootstraped {
p.subs[key] = nil
p.mx.Unlock()

bootstrapPubsub(p.ctx, p.cr, p.host, topic)
} else {
p.mx.Unlock()
if err := p.Subscribe(key); err != nil {
return err
}

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

0 comments on commit 76fb692

Please sign in to comment.