Skip to content

Commit

Permalink
Support ACL LOG: Added entry ID, timestamp created, and timestamp las…
Browse files Browse the repository at this point in the history
…t updated
  • Loading branch information
codrin-ch committed May 3, 2023
1 parent 3273c85 commit 8f3f6a2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
13 changes: 11 additions & 2 deletions packages/client/lib/commands/ACL_LOG.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,13 @@ describe('ACL LOG', () => {
'age-seconds',
'4.096',
'client-info',
'id=6 addr=127.0.0.1:63026 fd=8 name= age=9 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=48 qbuf-free=32720 obl=0 oll=0 omem=0 events=r cmd=auth user=default'
'id=6 addr=127.0.0.1:63026 fd=8 name= age=9 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=48 qbuf-free=32720 obl=0 oll=0 omem=0 events=r cmd=auth user=default',
'entry-id',
0,
'timestamp-created',
1675361492408,
'timestamp-last-updated',
1675361492408
]]),
[{
count: 1,
Expand All @@ -46,7 +52,10 @@ describe('ACL LOG', () => {
object: 'AUTH',
username: 'someuser',
ageSeconds: 4.096,
clientInfo: 'id=6 addr=127.0.0.1:63026 fd=8 name= age=9 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=48 qbuf-free=32720 obl=0 oll=0 omem=0 events=r cmd=auth user=default'
clientInfo: 'id=6 addr=127.0.0.1:63026 fd=8 name= age=9 idle=0 flags=N db=0 sub=0 psub=0 multi=-1 qbuf=48 qbuf-free=32720 obl=0 oll=0 omem=0 events=r cmd=auth user=default',
entryId: 0,
timestampCreated: 1675361492408,
timestampLastUpdated: 1675361492408
}]
);
});
Expand Down
16 changes: 14 additions & 2 deletions packages/client/lib/commands/ACL_LOG.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,13 @@ type AclLogRawReply = [
_: RedisCommandArgument,
ageSeconds: RedisCommandArgument,
_: RedisCommandArgument,
clientInfo: RedisCommandArgument
clientInfo: RedisCommandArgument,
_: RedisCommandArgument,
entryId: number,
_: RedisCommandArgument,
timestampCreated: number,
_: RedisCommandArgument,
timestampLastUpdated: number,
];

interface AclLog {
Expand All @@ -35,6 +41,9 @@ interface AclLog {
username: RedisCommandArgument;
ageSeconds: number;
clientInfo: RedisCommandArgument;
entryId: number;
timestampCreated: number;
timestampLastUpdated: number;
}

export function transformReply(reply: Array<AclLogRawReply>): Array<AclLog> {
Expand All @@ -45,6 +54,9 @@ export function transformReply(reply: Array<AclLogRawReply>): Array<AclLog> {
object: log[7],
username: log[9],
ageSeconds: Number(log[11]),
clientInfo: log[13]
clientInfo: log[13],
entryId: log[15],
timestampCreated: log[17],
timestampLastUpdated: log[19],
}));
}

0 comments on commit 8f3f6a2

Please sign in to comment.