req id
This commit is contained in:
parent
3b2e376ffa
commit
21d6ed1966
5 changed files with 12 additions and 3 deletions
|
|
@ -1343,6 +1343,7 @@ The nostr server will send back a message response, and inside the body there wi
|
|||
- __app_id__: _string_
|
||||
- __metrics_name__: _string_
|
||||
- __page__: _number_
|
||||
- __request_id__: _number_ *this field is optional
|
||||
|
||||
### UpdateChannelPolicyRequest
|
||||
- __policy__: _[ChannelPolicy](#ChannelPolicy)_
|
||||
|
|
|
|||
|
|
@ -559,6 +559,7 @@ type SingleUsageMetricReq struct {
|
|||
App_id string `json:"app_id"`
|
||||
Metrics_name string `json:"metrics_name"`
|
||||
Page int64 `json:"page"`
|
||||
Request_id int64 `json:"request_id"`
|
||||
}
|
||||
type UpdateChannelPolicyRequest struct {
|
||||
Policy *ChannelPolicy `json:"policy"`
|
||||
|
|
|
|||
|
|
@ -3191,13 +3191,16 @@ export type SingleUsageMetricReq = {
|
|||
app_id: string
|
||||
metrics_name: string
|
||||
page: number
|
||||
request_id?: number
|
||||
}
|
||||
export const SingleUsageMetricReqOptionalFields: [] = []
|
||||
export type SingleUsageMetricReqOptionalField = 'request_id'
|
||||
export const SingleUsageMetricReqOptionalFields: SingleUsageMetricReqOptionalField[] = ['request_id']
|
||||
export type SingleUsageMetricReqOptions = OptionsBaseMessage & {
|
||||
checkOptionalsAreSet?: []
|
||||
checkOptionalsAreSet?: SingleUsageMetricReqOptionalField[]
|
||||
app_id_CustomCheck?: (v: string) => boolean
|
||||
metrics_name_CustomCheck?: (v: string) => boolean
|
||||
page_CustomCheck?: (v: number) => boolean
|
||||
request_id_CustomCheck?: (v?: number) => boolean
|
||||
}
|
||||
export const SingleUsageMetricReqValidate = (o?: SingleUsageMetricReq, opts: SingleUsageMetricReqOptions = {}, path: string = 'SingleUsageMetricReq::root.'): Error | null => {
|
||||
if (opts.checkOptionalsAreSet && opts.allOptionalsAreSet) return new Error(path + ': only one of checkOptionalsAreSet or allOptionalNonDefault can be set for each message')
|
||||
|
|
@ -3212,6 +3215,9 @@ export const SingleUsageMetricReqValidate = (o?: SingleUsageMetricReq, opts: Sin
|
|||
if (typeof o.page !== 'number') return new Error(`${path}.page: is not a number`)
|
||||
if (opts.page_CustomCheck && !opts.page_CustomCheck(o.page)) return new Error(`${path}.page: custom check failed`)
|
||||
|
||||
if ((o.request_id || opts.allOptionalsAreSet || opts.checkOptionalsAreSet?.includes('request_id')) && typeof o.request_id !== 'number') return new Error(`${path}.request_id: is not a number`)
|
||||
if (opts.request_id_CustomCheck && !opts.request_id_CustomCheck(o.request_id)) return new Error(`${path}.request_id: custom check failed`)
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ message SingleUsageMetricReq {
|
|||
string app_id = 1;
|
||||
string metrics_name = 2;
|
||||
int64 page = 3;
|
||||
optional int64 request_id = 4;
|
||||
}
|
||||
|
||||
message UsageMetric {
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ export default class webRTC {
|
|||
return
|
||||
}
|
||||
const res = await this.storage.metricsEventStorage.LoadRawMetricsFile(j.app_id, j.metrics_name, j.page)
|
||||
const id = Math.floor(Math.random() * 2_000_000_000)
|
||||
const id = j.request_id || Math.floor(Math.random() * 2_000_000_000)
|
||||
let i = 0
|
||||
const packets: Buffer[] = []
|
||||
while (i < res.length) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue