Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Immutable locking config #189

Merged
merged 5 commits into from
Aug 8, 2024
Merged

Immutable locking config #189

merged 5 commits into from
Aug 8, 2024

Conversation

seba-aln
Copy link
Contributor

@seba-aln seba-aln commented Jul 30, 2024

feat: Optionally immutable config.

Option to lock PNConfiguration mutability. Note that mutable config will be deprecated in future major releases

@seba-aln seba-aln marked this pull request as ready for review August 1, 2024 08:11
self.config = config
def __init__(self, config: PNConfiguration):
if not config.disable_config_locking:
config.lock()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if, as a user, I wanted to reuse most of the settings of the config to create a new (second) PN instance, is there a way I can do it now? probably not, since the original config will be locked (both outside and the inner copy in PN)?

Can you add a method to config that, even with a locked config, lets me clone+modify an existing config? or is it already possible with some Python magic, or similar to the deepcopy function that you're using here

I'd like to do something like (pseudocode):

val config = PNConfiguration(blah, blah, blah)
val pubnub1 = PubNub(config)

val config2 = config.copy(uuid = blah2)
val pubnub2 = PubNub(config2)

@seba-aln seba-aln force-pushed the feat/immutable-pnconfiguration branch from 2a20d99 to e97e0f6 Compare August 6, 2024 12:48
@seba-aln seba-aln merged commit b56d703 into master Aug 8, 2024
9 checks passed
@seba-aln seba-aln deleted the feat/immutable-pnconfiguration branch August 8, 2024 11:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants