Skip to main content

IdempotencyParams

Struct IdempotencyParams 

Source
pub(crate) struct IdempotencyParams<'a> {
    pub acc_id: u64,
    pub market: &'a str,
    pub code: &'a str,
    pub side: &'a str,
    pub qty: f64,
    pub price: Option<f64>,
    pub order_type: &'a str,
}
Expand description

v1.4.41 (eli v1.4.40 报告 P3.6 修): opt-in auto key 改成参数 deterministic hash,让同参数重试真能 dedup。

v1.4.40 bug:用 rand::thread_rng 每次生成新 UUID → daemon 看到不同 packet_id → 每次都当新请求,dedup 失效。eli wire-level 实证跑 2 次同参数 的 ConnID 字节完全不同。

v1.4.41 修法:用 (acc_id, market, code, side, qty, price, order_type) 7 元组 hash 成 deterministic key。daemon 端 90s TTL cache 会合并同参数 retry,返回第一次的结果,避免重复下单。

footgun 提示保持

  • 跨 daemon 进程 retry 还是靠 daemon cache TTL(默认 90s),超时就重新下单
  • 同 user-intended 下两次不同单(比如 qty=100 + qty=200)因 hash 不同,不会 被合并(符合预期)
  • 同参数两次下单被合并(只生成一单),用户想再下必须手动改参 (price 调整 0.001 / qty 调整 1 / 或加 –remark 作区分)—— 这是 opt-in 幂等性的代价。默认关闭不影响不 opt-in 的用户。

不加 opt-in 默认关闭(None),保持 v1.4.39 行为不变。

Signature 变化:v1.4.40 (Option<String>) -> Option<String> → v1.4.41 (Option<String>, &IdempotencyParams) -> Option<String>

Fields§

§acc_id: u64§market: &'a str§code: &'a str§side: &'a str§qty: f64§price: Option<f64>§order_type: &'a str

Trait Implementations§

Source§

impl<'a> Clone for IdempotencyParams<'a>

Source§

fn clone(&self) -> IdempotencyParams<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for IdempotencyParams<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Copy for IdempotencyParams<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for IdempotencyParams<'a>

§

impl<'a> RefUnwindSafe for IdempotencyParams<'a>

§

impl<'a> Send for IdempotencyParams<'a>

§

impl<'a> Sync for IdempotencyParams<'a>

§

impl<'a> Unpin for IdempotencyParams<'a>

§

impl<'a> UnsafeUnpin for IdempotencyParams<'a>

§

impl<'a> UnwindSafe for IdempotencyParams<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more