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

fix: Big Number support for incrementors in redis #149

Open
wants to merge 1 commit into
base: main
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
20 changes: 14 additions & 6 deletions src/storage/redis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use gasket::{
runtime::{spawn_stage, WorkOutcome},
};

use redis::{Commands, ToRedisArgs};
use redis::{Commands, ConnectionLike, ToRedisArgs};
use serde::Deserialize;

use crate::{bootstrap, crosscut, model};
Expand Down Expand Up @@ -233,13 +233,16 @@ impl gasket::runtime::Worker for Worker {
.set(key, value)
.or_restart()?;
}
model::CRDTCommand::PNCounter(key, value) => {
log::debug!("increasing counter [{}], by [{}]", key, value);
model::CRDTCommand::PNCounter(key, delta) => {
log::debug!("increasing counter [{}], by [{}]", key, delta);

self.connection
.as_mut()
.unwrap()
.incr(key, value)
.req_command(&redis::Cmd::new()
.arg("INCRBYFLOAT")
.arg(key)
.arg(delta.to_string()))
.or_restart()?;
}
model::CRDTCommand::HashSetValue(key, member, value) => {
Expand All @@ -252,12 +255,17 @@ impl gasket::runtime::Worker for Worker {
.or_restart()?;
}
model::CRDTCommand::HashCounter(key, member, delta) => {
log::debug!("increasing hash key {} member {} by {}", key, member, delta);
log::debug!("increasing hash key {} member {} by {}", key.clone(), member.clone(), delta);

self.connection
.as_mut()
.unwrap()
.hincr(key, member, delta)
.req_command(&redis::Cmd::new()
.arg("HINCRBYFLOAT")
.arg(key.clone())
.arg(member.clone())
.arg(delta.to_string())
)
.or_restart()?;
}
model::CRDTCommand::HashUnsetKey(key, member) => {
Expand Down