Skip to content
This repository has been archived by the owner on Jun 14, 2024. It is now read-only.

Add getPersistentTopic method #2

Open
nootanghimire opened this issue Nov 12, 2018 · 0 comments
Open

Add getPersistentTopic method #2

nootanghimire opened this issue Nov 12, 2018 · 0 comments

Comments

@nootanghimire
Copy link
Contributor

nootanghimire commented Nov 12, 2018

The getTopic(name, options) method does two things as of now:

  1. Create a topic (with the given options) when its called the first time (i.e., when the topic does not exist)
  2. Use the existing topic (and discard the options) when its called subsequently (i.e., when the topic exist)

This is fine when you know the flow of execution, but when you don't you don't know which call creates a topic and which one just gets, you kind of have to make sure that all your calls to getTopic should contain the same options (because you want to ensure that wherever the topic is created, it should have the same options)

Since persisted is the only option, I was thinking if we should add a getPersistentTopic(name) method that does the following:

  1. If there is no any topic with given name present, create a new one with persistence
  2. if the topic is persistent return it
  3. Throw an error saying the topic is not persistent

Or maybe something flexible like: getPersistentTopic(name, coerce=false)

  1. If there is no any topic with given name present, create a new one with persistence
  2. if the topic is persistent return it
  3. If coerce is true convert the existing topic to persistent and return it
  4. Throw an error saying the topic is not persistent and coerce was passed false.
@nootanghimire nootanghimire changed the title Add getPeristentTopic method Add getPersistentTopic method Nov 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

1 participant