| 1 |
import { TimeSeriesAggregationType, TimeSeriesDuplicatePolicies } from '.'; |
| 2 |
|
| 3 |
export const FIRST_KEY_INDEX = 1; |
| 4 |
|
| 5 |
export const IS_READ_ONLY = true; |
| 6 |
|
| 7 |
export function transformArguments(key: string): Array<string> { |
| 8 |
return ['TS.INFO', key]; |
| 9 |
} |
| 10 |
|
| 11 |
export type InfoRawReply = [ |
| 12 |
'totalSamples', |
| 13 |
number, |
| 14 |
'memoryUsage', |
| 15 |
number, |
| 16 |
'firstTimestamp', |
| 17 |
number, |
| 18 |
'lastTimestamp', |
| 19 |
number, |
| 20 |
'retentionTime', |
| 21 |
number, |
| 22 |
'chunkCount', |
| 23 |
number, |
| 24 |
'chunkSize', |
| 25 |
number, |
| 26 |
'chunkType', |
| 27 |
string, |
| 28 |
'duplicatePolicy', |
| 29 |
TimeSeriesDuplicatePolicies | null, |
| 30 |
'labels', |
| 31 |
Array<[name: string, value: string]>, |
| 32 |
'sourceKey', |
| 33 |
string | null, |
| 34 |
'rules', |
| 35 |
Array<[key: string, timeBucket: number, aggregationType: TimeSeriesAggregationType]> |
| 36 |
]; |
| 37 |
|
| 38 |
export interface InfoReply { |
| 39 |
totalSamples: number; |
| 40 |
memoryUsage: number; |
| 41 |
firstTimestamp: number; |
| 42 |
lastTimestamp: number; |
| 43 |
retentionTime: number; |
| 44 |
chunkCount: number; |
| 45 |
chunkSize: number; |
| 46 |
chunkType: string; |
| 47 |
duplicatePolicy: TimeSeriesDuplicatePolicies | null; |
| 48 |
labels: Array<{ |
| 49 |
name: string; |
| 50 |
value: string; |
| 51 |
}>; |
| 52 |
sourceKey: string | null; |
| 53 |
rules: Array<{ |
| 54 |
key: string; |
| 55 |
timeBucket: number; |
| 56 |
aggregationType: TimeSeriesAggregationType |
| 57 |
}>; |
| 58 |
} |
| 59 |
|
| 60 |
export function transformReply(reply: InfoRawReply): InfoReply { |
| 61 |
return { |
| 62 |
totalSamples: reply[1], |
| 63 |
memoryUsage: reply[3], |
| 64 |
firstTimestamp: reply[5], |
| 65 |
lastTimestamp: reply[7], |
| 66 |
retentionTime: reply[9], |
| 67 |
chunkCount: reply[11], |
| 68 |
chunkSize: reply[13], |
| 69 |
chunkType: reply[15], |
| 70 |
duplicatePolicy: reply[17], |
| 71 |
labels: reply[19].map(([name, value]) => ({ |
| 72 |
name, |
| 73 |
value |
| 74 |
})), |
| 75 |
sourceKey: reply[21], |
| 76 |
rules: reply[23].map(([key, timeBucket, aggregationType]) => ({ |
| 77 |
key, |
| 78 |
timeBucket, |
| 79 |
aggregationType |
| 80 |
})) |
| 81 |
}; |
| 82 |
} |