pub struct SnipSyncService {
pub db: Arc<Database>,
pub rate_limiter: Arc<RateLimiter>,
pub config: Config,
pub metrics: Metrics,
pub premade_manager: PremadeManager,
}Fields§
§db: Arc<Database>§rate_limiter: Arc<RateLimiter>§config: Config§metrics: Metrics§premade_manager: PremadeManagerImplementations§
Source§impl SnipSyncService
impl SnipSyncService
pub fn record_request(&self, method: &str)
pub fn record_request_finished(&self, method: &str, success: bool)
Sourcepub fn update_request_ids(
&self,
method: &str,
user_id: Option<String>,
device_id: Option<String>,
library_id: Option<String>,
)
pub fn update_request_ids( &self, method: &str, user_id: Option<String>, device_id: Option<String>, library_id: Option<String>, )
Update the last started request’s authenticated IDs.
Called after authentication resolves the user and device IDs.
Only active with test-helpers feature.
pub fn record_request_duration(&self, method: &str, start: Instant)
pub fn record_rate_limit(&self)
pub fn record_auth_failure(&self)
Sourcepub fn record_db_error(&self)
pub fn record_db_error(&self)
Record a database failure (for example an upsert that failed inside a
write transaction). Database failures are infrastructure errors, not
content-level skips, so they are counted separately from the
skipped_count a client sees.
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, rate_limit_key: &str, ) -> Result<String, Status>
Sourcepub async fn authenticate_and_rate_limit_with_duration(
&self,
api_key: &str,
rate_limit_key: &str,
start: Option<Instant>,
) -> Result<String, Status>
pub async fn authenticate_and_rate_limit_with_duration( &self, api_key: &str, rate_limit_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.
rate_limit_key must come from Self::peer_rate_limit_key.
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 non-deleted snippets from the selected library. Results are filtered
to the records the server delivers at or after the cursor
since
(>=). The cursor is server-assigned and monotone: the server tracks it
per row, so a record pushed with an older updated_at (a device whose
clock is behind) is still delivered. The server uses >= deliberately:
the cursor has second granularity, so a strict > would skip rows
written in the same second as the previous cursor.
Re-delivering boundary rows is safe — merges are idempotent by snippet
identity.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 the selected library. Invalid snippets are
rejected individually and reported in the response.
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,
Merge local snippets into the selected library and return changed server
records, including deletion tombstones.
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. Library IDs are scoped to the authenticated account.
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-to-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 Forget for SnipSyncService
impl Freeze for SnipSyncService
impl Move 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