use std::time::Instant;
use tonic::Status;
use crate::config::Config;
use crate::http::AppState;
use crate::storage::{
StorageClient, StorageOperationContextOps, StorageSchemaContextOps, StorageSyncContextOps,
};
use super::proto::{MigrationProgressEvent, StreamResponse};
pub(crate) type ExecuteQueryStreamStream = std::pin::Pin<
Box<dyn tokio_stream::Stream<Item = Result<StreamResponse, Status>> + Send + 'static>,
>;
pub(crate) type StreamMigrationProgressStream = std::pin::Pin<
Box<dyn tokio_stream::Stream<Item = Result<MigrationProgressEvent, Status>> + Send + 'static>,
>;
pub struct LinkrsService<
S: StorageClient
+ StorageSchemaContextOps
+ StorageSyncContextOps
+ StorageOperationContextOps
+ Clone
+ 'static,
> {
pub(crate) app_state: AppState<S>,
pub(crate) config: Config,
pub(crate) start_time: Instant,
}
impl<
S: StorageClient
+ StorageSchemaContextOps
+ StorageSyncContextOps
+ StorageOperationContextOps
+ Clone
+ 'static,
> LinkrsService<S>
{
pub fn new(app_state: AppState<S>, config: Config) -> Self {
Self {
app_state,
config,
start_time: Instant::now(),
}
}
pub fn config(&self) -> &Config {
&self.config
}
pub fn app_state(&self) -> &AppState<S> {
&self.app_state
}
pub fn start_time(&self) -> Instant {
self.start_time
}
}