Skip to content

[WIP] add initializer_nodes option to RedisDB::Cluster #41

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions lib/RedisDB/Cluster.pm
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,16 @@ This module allows you to access redis cluster.

=cut

=head2 $self->new(startup_nodes => \@nodes)
=head2 $self->new(startup_nodes => \@nodes[, initializer_nodes => \@initializer_nodes])

create a new connection to cluster. Startup nodes should contain array of
hashes that contains addresses of some nodes in the cluster. Each hash should
contain 'host' and 'port' elements. Constructor will try to connect to nodes
from the list and from the first node to which it will be able to connect it
will retrieve information about all cluster nodes and slots mappings.

If I<\@initializer_nodes> is specified, TODO!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Copy link
Author

Choose a reason for hiding this comment

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

TODO: doc about it if this solution is accepted.


=over 4

=item password
Expand All @@ -168,10 +170,11 @@ sub new {
my ( $class, %params ) = @_;

my $self = {
_slots => [],
_connections => {},
_nodes => $params{startup_nodes},
_password => $params{password},
_slots => [],
_connections => {},
_nodes => $params{startup_nodes},
_initializer_nodes => $params{initializer_nodes},
_password => $params{password},
};
$self->{no_slots_initialization} = 1 if $params{no_slots_initialization};

Expand All @@ -191,7 +194,7 @@ sub _initialize_slots {

my %new_nodes;
my $new_nodes;
for my $node ( @{ $self->{_nodes} } ) {
for my $node ( @{ $self->{_initializer_nodes} || $self->{_nodes} } ) {
my $redis = _connect_to_node( $self, $node );
next unless $redis;

Expand Down