pub struct SnipSyncService {
pub db: Arc<Database>,
pub rate_limiter: Arc<RateLimiter>,
pub config: Config,
pub metrics: Metrics,
pub premade_manager: PremadeManager,
pub captured_auth_header: Arc<Mutex<Option<String>>>,
}Fields§
§db: Arc<Database>§rate_limiter: Arc<RateLimiter>§config: Config§metrics: Metrics§premade_manager: PremadeManager§captured_auth_header: Arc<Mutex<Option<String>>>Test-only: most recent authorization header value observed by
the gRPC handlers. Used by integration tests to assert that the
sync client actually sends a non-empty bearer token in metadata
(catching the auth-header regression where request.api_key was
read instead of the caller’s API key).
Implementations§
Source§impl SnipSyncService
impl SnipSyncService
pub fn record_request(&self, method: &str)
pub fn record_request_duration(&self, method: &str, start: Instant)
pub fn record_rate_limit(&self)
pub fn record_auth_failure(&self)
pub fn record_sync(&self, direction: &str)
pub fn record_library_op(&self, operation: &str)
pub async fn authenticate_and_rate_limit( &self, api_key: &str, ) -> Result<String, Status>
Sourcepub async fn authenticate_and_rate_limit_with_duration(
&self,
api_key: &str,
start: Option<Instant>,
) -> Result<String, Status>
pub async fn authenticate_and_rate_limit_with_duration( &self, api_key: &str, start: Option<Instant>, ) -> Result<String, Status>
Like authenticate_and_rate_limit, but records request duration on
failure so the histogram captures latency for error responses.
pub fn validate_snippet(&self, snippet: &ProtoSnippet) -> Result<(), Status>
Trait Implementations§
Source§impl SnippetSync for SnipSyncService
impl SnippetSync for SnipSyncService
Source§fn health<'life0, 'async_trait>(
&'life0 self,
_request: Request<HealthRequest>,
) -> Pin<Box<dyn Future<Output = Result<Response<HealthResponse>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn health<'life0, 'async_trait>(
&'life0 self,
_request: Request<HealthRequest>,
) -> Pin<Box<dyn Future<Output = Result<Response<HealthResponse>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Health check
Source§fn register<'life0, 'async_trait>(
&'life0 self,
request: Request<RegisterRequest>,
) -> Pin<Box<dyn Future<Output = Result<Response<RegisterResponse>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn register<'life0, 'async_trait>(
&'life0 self,
request: Request<RegisterRequest>,
) -> Pin<Box<dyn Future<Output = Result<Response<RegisterResponse>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Register a new device/user
Source§fn get_snippets<'life0, 'async_trait>(
&'life0 self,
request: Request<GetSnippetsRequest>,
) -> Pin<Box<dyn Future<Output = Result<Response<SnippetList>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn get_snippets<'life0, 'async_trait>(
&'life0 self,
request: Request<GetSnippetsRequest>,
) -> Pin<Box<dyn Future<Output = Result<Response<SnippetList>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Get snippets from server (optionally since a timestamp)
Source§fn push_snippets<'life0, 'async_trait>(
&'life0 self,
request: Request<PushSnippetsRequest>,
) -> Pin<Box<dyn Future<Output = Result<Response<PushSnippetsResponse>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn push_snippets<'life0, 'async_trait>(
&'life0 self,
request: Request<PushSnippetsRequest>,
) -> Pin<Box<dyn Future<Output = Result<Response<PushSnippetsResponse>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Push local snippets to server
Source§fn sync<'life0, 'async_trait>(
&'life0 self,
request: Request<SyncRequest>,
) -> Pin<Box<dyn Future<Output = Result<Response<SyncResponse>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn sync<'life0, 'async_trait>(
&'life0 self,
request: Request<SyncRequest>,
) -> Pin<Box<dyn Future<Output = Result<Response<SyncResponse>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Two-way sync - merge local and server snippets
Source§fn create_library<'life0, 'async_trait>(
&'life0 self,
request: Request<CreateLibraryRequest>,
) -> Pin<Box<dyn Future<Output = Result<Response<CreateLibraryResponse>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn create_library<'life0, 'async_trait>(
&'life0 self,
request: Request<CreateLibraryRequest>,
) -> Pin<Box<dyn Future<Output = Result<Response<CreateLibraryResponse>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Library management
fn list_libraries<'life0, 'async_trait>(
&'life0 self,
request: Request<ListLibrariesRequest>,
) -> Pin<Box<dyn Future<Output = Result<Response<ListLibrariesResponse>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn delete_library<'life0, 'async_trait>(
&'life0 self,
request: Request<DeleteLibraryRequest>,
) -> Pin<Box<dyn Future<Output = Result<Response<DeleteLibraryResponse>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Source§fn list_premade_libraries<'life0, 'async_trait>(
&'life0 self,
request: Request<ListPremadeLibrariesRequest>,
) -> Pin<Box<dyn Future<Output = Result<Response<ListPremadeLibrariesResponse>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn list_premade_libraries<'life0, 'async_trait>(
&'life0 self,
request: Request<ListPremadeLibrariesRequest>,
) -> Pin<Box<dyn Future<Output = Result<Response<ListPremadeLibrariesResponse>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Premade libraries (server->client only)
fn get_premade_library<'life0, 'async_trait>(
&'life0 self,
request: Request<GetPremadeLibraryRequest>,
) -> Pin<Box<dyn Future<Output = Result<Response<GetPremadeLibraryResponse>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn search_premade_libraries<'life0, 'async_trait>(
&'life0 self,
request: Request<SearchPremadeLibrariesRequest>,
) -> Pin<Box<dyn Future<Output = Result<Response<SearchPremadeLibrariesResponse>, Status>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Auto Trait Implementations§
impl !RefUnwindSafe for SnipSyncService
impl !UnwindSafe for SnipSyncService
impl Freeze for SnipSyncService
impl Send for SnipSyncService
impl Sync for SnipSyncService
impl Unpin for SnipSyncService
impl UnsafeUnpin for SnipSyncService
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request