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: remove decoder step #228

Merged
merged 3 commits into from
Nov 4, 2024
Merged
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
12 changes: 1 addition & 11 deletions examples/src/jobs/jobs.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use std::time::Duration;

use base64::prelude::*;
use dapr::client::JobBuilder;
use dapr::dapr::proto::runtime::v1::{
app_callback_alpha_server::AppCallbackAlphaServer, JobEventRequest, JobEventResponse,
Expand Down Expand Up @@ -42,17 +41,8 @@ async fn backup_job_handler(request: JobEventRequest) -> Result<JobEventResponse
// The logic for handling the backup job request

if request.data.is_some() {
// weird value - any type is actually put into the value
let any = request.data.unwrap().value;

// parse any value
let any_parsed: JsonAny = serde_json::from_slice(&any).unwrap();

// Decode the base64-encoded value field
let decoded_value = BASE64_STANDARD.decode(any_parsed.value).unwrap();

// Deserialize the decoded value into a Backup struct
let backup_val: Backup = serde_json::from_slice(&decoded_value).unwrap();
let backup_val: Backup = serde_json::from_slice(&request.data.unwrap().value).unwrap();

println!("job received: {:?}", backup_val);
}
Expand Down
Loading