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

Support readPreferenceTags as options array #299

Open
wants to merge 4 commits into
base: 1.x
Choose a base branch
from

Conversation

MarioCuljak
Copy link

This pull requests propose changes to configuration options for MongoClient regarding readPreferenceTags.

Currently, read preference tags can be configured using string of comma-delimited sequence of colon-delimited key/value pairs.
Example:

<?php
$options = [
    'readPreference' => 'secondary',
    'readPreferenceTags' => 'dc:east,use:reporting'
];

$m = new MongoClient("mongodb://localhost/", $options);
?>

There are limitation when using string syntax:

  • unable to define multiple tag sets
  • unable to define empty tag set

Proposed solution allow readPreferenceTags to be set using array syntax.
Same syntax is used when configuring tags using setter methods.
Example:

<?php

$options = [
    'readPreference' => 'secondary',
    'readPreferenceTags' => [
    	['dc' => 'east', 'use' => 'reporting'],
    	['dc' => 'west'],
    	[]
    ]
];

$m = new MongoClient("mongodb://localhost/", $options);
?>

Configuration is backwards compatible, so users can continue to use old string syntax.
If not necessary, it can be removed.

@alcaeus alcaeus closed this Jun 6, 2023
@alcaeus alcaeus reopened this Jun 6, 2023
@alcaeus
Copy link
Owner

alcaeus commented Jun 12, 2023

@MarioCuljak note that the CI pipeline doesn't work anymore, as GitHub Actions no longer supports Ubuntu 18.04. If you want to try and update the workflows to use Ubuntu 20.04, feel free to give this a shot in a separate PR. I'm not sure when I'll have the time to look into this.

@MarioCuljak
Copy link
Author

@MarioCuljak note that the CI pipeline doesn't work anymore, as GitHub Actions no longer supports Ubuntu 18.04. If you want to try and update the workflows to use Ubuntu 20.04, feel free to give this a shot in a separate PR. I'm not sure when I'll have the time to look into this.

No problem, I'll take a look.

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.

None yet

2 participants