Skip to content

Commit

Permalink
add relay domain setting, optimize docker build
Browse files Browse the repository at this point in the history
  • Loading branch information
korewaChino committed Dec 4, 2024
1 parent 7a427a9 commit c02374b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
FROM rust:latest

LABEL org.opencontainers.image.source = "https://github.com/FyraLabs/skystreamer"
WORKDIR /usr/src/app
COPY . .

RUN cargo install --path skystreamer-bin

WORKDIR /
RUN rm -rf /usr/src/app


CMD ["skystreamer"]
5 changes: 4 additions & 1 deletion skystreamer-bin/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ pub struct Config {
pub exporter: ExporterType,
#[clap(flatten)]
pub file_exporter: FileExporterOptions,

#[clap(short = 'R', long, default_value = "bsky.network", env = "ATPROTO_RELAY")]
pub atproto_relay: String,
}

impl Config {
Expand Down Expand Up @@ -212,6 +215,6 @@ impl Config {
}
};

Ok(Consumer::new(exporter))
Ok(Consumer::new(exporter, &self.atproto_relay))
}
}
6 changes: 4 additions & 2 deletions skystreamer-bin/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use update_rate::RateCounter;
pub struct Consumer {
rate_counter: update_rate::DiscreteRateCounter,
exporter: Box<dyn exporter::Exporter>,
pub atproto_relay: String,
}
// #[derive(Debug)]
// pub struct TaskQueue {
Expand Down Expand Up @@ -67,15 +68,16 @@ pub struct Consumer {
// const GLOBAL_THREAD_POOL: OnceCell<ThreadPool> = OnceCell::new();

impl Consumer {
pub fn new(exporter: Box<dyn exporter::Exporter>) -> Self {
pub fn new(exporter: Box<dyn exporter::Exporter>, relay: &str) -> Self {
Consumer {
rate_counter: update_rate::DiscreteRateCounter::new(50),
exporter,
atproto_relay: relay.to_string(),
}
}

pub async fn start(&mut self) -> Result<()> {
let subscription = RepoSubscription::new("bsky.network").await.unwrap();
let subscription = RepoSubscription::new(&self.atproto_relay).await.unwrap();
let post_stream = PostStream::new(subscription);

let mut post_stream = post_stream.await;
Expand Down

0 comments on commit c02374b

Please sign in to comment.