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

Add getPersistentTopic method #2

@nootanghimire

Description

@nootanghimire

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions