You've already forked node-redis
mirror of
https://github.com/redis/node-redis.git
synced 2025-08-06 02:15:48 +03:00
init time series
This commit is contained in:
82
packages/time-series/lib/commands/INFO.ts
Normal file
82
packages/time-series/lib/commands/INFO.ts
Normal file
@@ -0,0 +1,82 @@
|
||||
import { TimeSeriesAggregationType, TimeSeriesDuplicatePolicies } from '.';
|
||||
|
||||
export const FIRST_KEY_INDEX = 1;
|
||||
|
||||
export const IS_READ_ONLY = true;
|
||||
|
||||
export function transformArguments(key: string): Array<string> {
|
||||
return ['TS.INFO', key];
|
||||
}
|
||||
|
||||
export type InfoRawReply = [
|
||||
_: string,
|
||||
totalSamples: number,
|
||||
_: string,
|
||||
memoryUsage: number,
|
||||
_: string,
|
||||
firstTimestamp: number,
|
||||
_: string,
|
||||
lastTimestamp: number,
|
||||
_: string,
|
||||
retentionTime: number,
|
||||
_: string,
|
||||
chunkCount: number,
|
||||
_: string,
|
||||
chunkSize: number,
|
||||
_: string,
|
||||
chunkType: string,
|
||||
_: string,
|
||||
duplicatePolicy: TimeSeriesDuplicatePolicies | null,
|
||||
_: string,
|
||||
labels: Array<[name: string, value: string]>,
|
||||
_: string,
|
||||
sourceKey: string | null,
|
||||
_: string,
|
||||
rules: Array<[key: string, timeBucket: number, aggregationType: TimeSeriesAggregationType]>
|
||||
];
|
||||
|
||||
export interface InfoReply {
|
||||
totalSamples: number;
|
||||
memoryUsage: number;
|
||||
firstTimestamp: number;
|
||||
lastTimestamp: number;
|
||||
retentionTime: number;
|
||||
chunkCount: number;
|
||||
chunkSize: number;
|
||||
chunkType: string;
|
||||
duplicatePolicy: TimeSeriesDuplicatePolicies | null;
|
||||
labels: Array<{
|
||||
name: string;
|
||||
value: string;
|
||||
}>;
|
||||
sourceKey: string | null;
|
||||
rules: Array<{
|
||||
key: string;
|
||||
timeBucket: number;
|
||||
aggregationType: TimeSeriesAggregationType
|
||||
}>;
|
||||
}
|
||||
|
||||
export function transformReply(reply: InfoRawReply): InfoReply {
|
||||
return {
|
||||
totalSamples: reply[1],
|
||||
memoryUsage: reply[3],
|
||||
firstTimestamp: reply[5],
|
||||
lastTimestamp: reply[7],
|
||||
retentionTime: reply[9],
|
||||
chunkCount: reply[11],
|
||||
chunkSize: reply[13],
|
||||
chunkType: reply[15],
|
||||
duplicatePolicy: reply[17],
|
||||
labels: reply[19].map(([name, value]) => ({
|
||||
name,
|
||||
value
|
||||
})),
|
||||
sourceKey: reply[21],
|
||||
rules: reply[23].map(([key, timeBucket, aggregationType]) => ({
|
||||
key,
|
||||
timeBucket,
|
||||
aggregationType
|
||||
}))
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user