This repository has been archived by the owner on Nov 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e516e30
commit e1607ce
Showing
7 changed files
with
24 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,10 @@ | ||
use std::env; | ||
|
||
use entity::{ | ||
db_enums::{CrateType, RepoSyncStatus}, | ||
repo_sync_status, | ||
}; | ||
use rdkafka::producer::FutureProducer; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
pub mod producer; | ||
|
||
pub fn get_producer() -> FutureProducer { | ||
let brokers = env::var("KAFKA_BROKER").unwrap(); | ||
producer::new_producer(&brokers) | ||
} | ||
|
||
#[derive(Serialize, Deserialize)] | ||
pub struct RepoMessage { | ||
pub crate_name: String, | ||
pub github_url: Option<String>, | ||
pub mega_url: String, | ||
pub crate_type: CrateType, | ||
pub status: RepoSyncStatus, | ||
pub err_message: Option<String>, | ||
} | ||
|
||
impl From<repo_sync_status::ActiveModel> for RepoMessage { | ||
fn from(value: repo_sync_status::ActiveModel) -> Self { | ||
Self { | ||
crate_name: value.crate_name.unwrap(), | ||
github_url: value.github_url.unwrap(), | ||
mega_url: value.mega_url.unwrap(), | ||
crate_type: value.crate_type.unwrap(), | ||
status: value.status.unwrap(), | ||
err_message: value.err_message.unwrap(), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters