Skip to content

Commit

Permalink
feat: new WithMsgIdFunction topic option to enable topics to have own…
Browse files Browse the repository at this point in the history
… msg id generation rules
  • Loading branch information
Wondertan authored and vyzo committed Jan 23, 2022
1 parent 0e687f2 commit 6035642
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions pubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,14 @@ type TopicOptions struct{}

type TopicOpt func(t *Topic) error

// WithMsgIdFunction sets custom MsgIdFunction for a Topic, enabling topics to have own msg id generation rules.
func (p *PubSub) WithMsgIdFunction(msgId MsgIdFunction) TopicOpt {
return func(t *Topic) error {
t.p.idGen.Set(t.topic, msgId)
return nil
}
}

// Join joins the topic and returns a Topic handle. Only one Topic handle should exist per topic, and Join will error if
// the Topic handle already exists.
func (p *PubSub) Join(topic string, opts ...TopicOpt) (*Topic, error) {
Expand Down

0 comments on commit 6035642

Please sign in to comment.