pub struct ServerEvent { /* private fields */ }Expand description
An event sent from the server to GA4 (Measurement Protocol), as a queue
job so a slow or failing request never holds up the page. Needs
GA4_MEASUREMENT_ID and GA4_API_SECRET; outside production it’s only logged.
Implementations§
Source§impl ServerEvent
impl ServerEvent
Sourcepub fn new(client_id: Option<String>, name: &str) -> Self
pub fn new(client_id: Option<String>, name: &str) -> Self
client_id from GaClientId; without one a random id is used, so
the event still counts but isn’t linked to the visitor’s session.
Sourcepub fn param(self, key: &str, value: impl Serialize) -> Self
pub fn param(self, key: &str, value: impl Serialize) -> Self
Adds a parameter; a value that can’t be serialized becomes null.
Trait Implementations§
Source§impl Clone for ServerEvent
impl Clone for ServerEvent
Source§impl Debug for ServerEvent
impl Debug for ServerEvent
Source§impl<'de> Deserialize<'de> for ServerEvent
impl<'de> Deserialize<'de> for ServerEvent
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Job for ServerEvent
impl Job for ServerEvent
Source§const NAME: &'static str = "renox:analytics"
const NAME: &'static str = "renox:analytics"
A stable name; stored with each job, so don’t rename it while jobs are queued.
Source§async fn handle(self, ctx: JobContext) -> Result
async fn handle(self, ctx: JobContext) -> Result
Does the work; an error fails the attempt (retried unless
Error::permanent).Source§const QUEUE: &'static str = "default"
const QUEUE: &'static str = "default"
Its queue;
queue:work --queue high,default drains queues in order.Source§const MAX_ATTEMPTS: u32 = 3
const MAX_ATTEMPTS: u32 = 3
Runs before the job is moved to
failed_jobs.Source§const ENCRYPTED: bool = false
const ENCRYPTED: bool = false
Store the payload encrypted with
APP_KEY (it holds personal data or
secrets). The worker decrypts it; failed_jobs keeps it encrypted.Source§const UNIQUE_FOR: Option<Duration> = None
const UNIQUE_FOR: Option<Duration> = None
While a job with the same
Job::unique_id is queued or running,
dispatching another returns the queued one’s id instead, for up to
this long (the claim is dropped when the job finishes).Source§fn backoff(attempt: u32) -> Duration
fn backoff(attempt: u32) -> Duration
Wait before retrying after the given failed attempt (1-based).
Source§fn unique_id(&self) -> String
fn unique_id(&self) -> String
What makes two jobs “the same” for
Job::UNIQUE_FOR, e.g. the
order id. Empty (the default) makes every job of the type the same.Source§fn middleware(&self) -> Vec<Middleware>
fn middleware(&self) -> Vec<Middleware>
Conditions checked before each attempt; a job that can’t run yet is
put back without using up an attempt.
Auto Trait Implementations§
impl Freeze for ServerEvent
impl RefUnwindSafe for ServerEvent
impl Send for ServerEvent
impl Sync for ServerEvent
impl Unpin for ServerEvent
impl UnsafeUnpin for ServerEvent
impl UnwindSafe for ServerEvent
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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 more