Skip to content

Commit

Permalink
Fix inconsistent annoucne addr config for HTTP publisher kind
Browse files Browse the repository at this point in the history
http publisher announce addrs are not passed to the publisher when its
kind is HTTP. See inline comment.
  • Loading branch information
masih committed Jul 10, 2023
1 parent b545127 commit 2047451
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion engine/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,19 @@ func (e *Engine) Publish(ctx context.Context, adv schema.Advertisement) (cid.Cid
log.Info("Announcing advertisement in pubsub channel and via http")
}

err = e.publisher.UpdateRoot(ctx, c)
// The publishers have their own senders of announcements. Further, there is a bespoke sender in the engine
// to allow explicit announcements via HTTP. The catch is that their behaviour is inconsistent:
// * engine takes pubHttpAnnounceAddrs option to allow configuring which addrs should be announced.
// But those addrs are only used by the bespoke sender, _not_ the HTTP sender inside publishers.
//
// To work around this issue, check if announce addrs are set, and publisher kind is HTTP, and
// if so announce with explicit addresses configured.
if len(e.pubHttpAnnounceAddrs) > 0 && e.pubKind == HttpPublisher {
err = e.publisher.UpdateRootWithAddrs(ctx, c, e.pubHttpAnnounceAddrs)
} else {
err = e.publisher.UpdateRoot(ctx, c)
}

if err != nil {
log.Errorw("Failed to announce advertisement", "err", err)
return cid.Undef, err
Expand Down

0 comments on commit 2047451

Please sign in to comment.