Skip to main content

lumen_server/service/
traits.rs

1use std::time::Duration;
2
3use super::{
4    ArtifactRef, ArtifactWrite, BoxFuture, ProgressEvent, RenderJob, RenderJobId, RenderLease,
5    RenderLeaseId, RenderOutput, ServiceError, ServiceResult, WorkerId,
6};
7
8pub trait RenderQueue: Send + Sync {
9    fn enqueue<'a>(&'a self, job: RenderJob) -> BoxFuture<'a, ServiceResult<RenderJobId>>;
10    fn lease<'a>(
11        &'a self,
12        worker_id: &'a WorkerId,
13        ttl: Duration,
14    ) -> BoxFuture<'a, ServiceResult<Option<RenderLease>>>;
15    fn ack<'a>(&'a self, lease_id: RenderLeaseId) -> BoxFuture<'a, ServiceResult<()>>;
16    fn nack<'a>(
17        &'a self,
18        lease_id: RenderLeaseId,
19        reason: ServiceError,
20    ) -> BoxFuture<'a, ServiceResult<()>>;
21    fn heartbeat<'a>(
22        &'a self,
23        lease_id: &'a RenderLeaseId,
24        ttl: Duration,
25    ) -> BoxFuture<'a, ServiceResult<()>>;
26}
27
28pub trait RenderExecutor: Send + Sync {
29    fn execute<'a>(
30        &'a self,
31        job: RenderJob,
32        progress: &'a dyn ProgressSink,
33    ) -> BoxFuture<'a, ServiceResult<RenderOutput>>;
34}
35
36pub trait ArtifactStore: Send + Sync {
37    fn put<'a>(&'a self, artifact: ArtifactWrite) -> BoxFuture<'a, ServiceResult<ArtifactRef>>;
38}
39
40pub trait ProgressSink: Send + Sync {
41    fn publish<'a>(&'a self, event: ProgressEvent) -> BoxFuture<'a, ServiceResult<()>>;
42}