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 for moving Redis read commands to replica connections #360

Merged
merged 2 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ my %WriteMakefileArgs = (
"Net::Async::HTTP" => "0.49",
"Net::Async::HTTP::Server" => "0.14",
"Net::Async::OpenTracing" => "1.001",
"Net::Async::Redis" => "6.003",
"Net::Async::Redis" => "6.004",
"Object::Pad" => "0.809",
"Object::Pad::FieldAttr::Checked" => 0,
"OpenTelemetry" => "0.023",
Expand Down Expand Up @@ -158,7 +158,7 @@ my %FallbackPrereqs = (
"Net::Async::HTTP" => "0.49",
"Net::Async::HTTP::Server" => "0.14",
"Net::Async::OpenTracing" => "1.001",
"Net::Async::Redis" => "6.003",
"Net::Async::Redis" => "6.004",
"Object::Pad" => "0.809",
"Object::Pad::FieldAttr::Checked" => 0,
"OpenTelemetry" => "0.023",
Expand Down
2 changes: 1 addition & 1 deletion cpanfile
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ requires 'Net::Async::OpenTracing', '>= 1.001';
requires 'Log::Any::Adapter::OpenTracing', '>= 0.001';
requires 'Metrics::Any::Adapter::Statsd', '>= 0.03';
# Transport
requires 'Net::Async::Redis', '>= 6.003';
requires 'Net::Async::Redis', '>= 6.004';
recommends 'Net::Async::Redis::XS', '>= 1.001';
requires 'Net::Async::HTTP', '>= 0.49';
requires 'Net::Async::HTTP::Server', '>= 0.14';
Expand Down
3 changes: 2 additions & 1 deletion lib/Myriad.pm
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,8 @@ method redis_transport () {
client_side_cache_size => $config->transport_redis_cache->as_number,
max_pool_count => $config->transport_pool_count->as_number,
wait_time => $config->transport_wait_time->as_number,
use_trim_exact => $config->transport_use_trim_exact->as_number
use_trim_exact => $config->transport_use_trim_exact->as_number,
use_read_replica => ($config->transport_use_read_replica->as_string ? 1 : 0),
) : ()
)
);
Expand Down
1 change: 1 addition & 0 deletions lib/Myriad/Config.pm
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ our %DEFAULTS = (
transport_redis => 'redis://localhost:6379',
transport_redis_cache => 0,
transport_use_trim_exact => 0,
transport_use_read_replica => 0,
transport_cluster => 0,
transport_pool_count => 10,
transport_wait_time => 15_000,
Expand Down
3 changes: 3 additions & 0 deletions lib/Myriad/Transport/Redis.pm
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ field $wait_time;
field $batch_count = 500;
field $max_pool_count;
field $clientside_cache_size;
field $use_read_replica = 0;
field $prefix;
field $ryu;
field $starting;
Expand All @@ -98,6 +99,7 @@ method configure (%args) {
$max_pool_count = exists $args{max_pool_count} ? delete $args{max_pool_count} : 10;
$prefix //= exists $args{prefix} ? delete $args{prefix} : 'myriad';
$clientside_cache_size = delete $args{client_side_cache_size} if exists $args{client_side_cache_size};
$use_read_replica = delete $args{use_read_replica} if exists $args{use_read_replica};
$wait_time = exists $args{wait_time} ? delete $args{wait_time} : 15_000;
# limit minimum wait time to 100ms
$wait_time = 100 if $wait_time < 100;
Expand Down Expand Up @@ -640,6 +642,7 @@ async method redis () {
if($use_cluster) {
$instance = $cluster_class->new(
client_side_cache_size => $clientside_cache_size,
use_read_replica => $use_read_replica,
);
$self->add_child(
$instance
Expand Down
Loading