Skip to content

Commit

Permalink
add oss
Browse files Browse the repository at this point in the history
  • Loading branch information
afsalthaj committed Dec 14, 2024
1 parent edd8807 commit e2bd089
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
18 changes: 8 additions & 10 deletions golem-worker-executor-base/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,7 @@ pub trait Bootstrap<Ctx: WorkerCtx> {
/// Allows customizing the `ActiveWorkers` service.
fn create_active_workers(&self, golem_config: &GolemConfig) -> Arc<ActiveWorkers<Ctx>>;

fn run_grpc_server(&self) -> bool {
true
}
fn run_grpc_server(&self) -> bool;

#[allow(clippy::type_complexity)]
fn create_plugins(
Expand Down Expand Up @@ -197,6 +195,8 @@ pub trait Bootstrap<Ctx: WorkerCtx> {
ISizeFormatter::new(worker_memory, BINARY)
);

let addr = golem_config.grpc_addr()?;

if self.run_grpc_server() {
let (mut health_reporter, health_service) = tonic_health::server::health_reporter();
health_reporter
Expand All @@ -207,19 +207,17 @@ pub trait Bootstrap<Ctx: WorkerCtx> {
.register_encoded_file_descriptor_set(proto::FILE_DESCRIPTOR_SET)
.build_v1()?;

let addr = golem_config.grpc_addr()?;

let listener = TcpListener::bind(addr).await?;
let grpc_port = listener.local_addr()?.port();

let worker_executor =
create_worker_executor_grpc_api::<Ctx>(
create_worker_executor_grpc_api::<Ctx, Self>(
golem_config.clone(),
self,
runtime.clone(),
join_set,
grpc_port,
).await;
).await?;

let service = WorkerExecutorServer::new(worker_executor)
.accept_compressed(CompressionEncoding::Gzip)
Expand Down Expand Up @@ -255,14 +253,14 @@ pub trait Bootstrap<Ctx: WorkerCtx> {

Ok(RunDetails {
http_port,
grpc_port,
grpc_port: addr.port(),
})
}
}

async fn create_worker_executor_grpc_api<Ctx: WorkerCtx>(
async fn create_worker_executor_grpc_api<Ctx: WorkerCtx, A: Bootstrap<Ctx> + ?Sized>(
golem_config: GolemConfig,
bootstrap: impl Bootstrap<Ctx>,
bootstrap: &A,
runtime: Handle,
join_set: &mut JoinSet<Result<(), anyhow::Error>>,
grpc_port: u16,
Expand Down
4 changes: 4 additions & 0 deletions golem-worker-executor-base/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,10 @@ impl Bootstrap<TestWorkerCtx> for ServerBootstrap {
Arc::new(ActiveWorkers::<TestWorkerCtx>::new(&golem_config.memory))
}

fn run_grpc_server(&self) -> bool {
true
}

fn create_plugins(
&self,
golem_config: &GolemConfig,
Expand Down
4 changes: 4 additions & 0 deletions golem-worker-executor/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ impl Bootstrap<Context> for ServerBootstrap {
Arc::new(ActiveWorkers::<Context>::new(&golem_config.memory))
}

fn run_grpc_server(&self) -> bool {
true
}

fn create_plugins(
&self,
golem_config: &GolemConfig,
Expand Down

0 comments on commit e2bd089

Please sign in to comment.