From bc188cfea4287a3661a3cadb2278f837b0299a8c Mon Sep 17 00:00:00 2001 From: Kelvin Mwinuka Date: Tue, 26 Mar 2024 20:26:48 +0800 Subject: [PATCH] Moved some types into internal folder as they will do not need to be exported. Changed GetState method to getState to make it private to the echovault package --- cmd/main.go | 3 +- coverage/coverage.out | 654 +++++++++++++-------------- internal/aof/engine.go | 14 +- internal/aof/preamble/store.go | 18 +- internal/memberlist/delegate.go | 9 +- internal/memberlist/memberlist.go | 5 +- internal/raft/fms_snapshot.go | 5 +- internal/raft/fsm.go | 27 +- internal/raft/raft.go | 3 + internal/snapshot/snapshot.go | 19 +- internal/types.go | 43 ++ internal/utils.go | 2 +- pkg/echovault/cluster.go | 16 +- pkg/echovault/echovault.go | 47 +- pkg/echovault/keyspace.go | 12 +- pkg/modules/generic/commands_test.go | 153 ++++--- pkg/utils/types.go | 28 -- 17 files changed, 551 insertions(+), 507 deletions(-) create mode 100644 internal/types.go diff --git a/cmd/main.go b/cmd/main.go index 37da265..2a0fb72 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -20,7 +20,6 @@ import ( "github.com/echovault/echovault/internal/config" "github.com/echovault/echovault/pkg/commands" "github.com/echovault/echovault/pkg/echovault" - "github.com/echovault/echovault/pkg/utils" "log" "os" "os/signal" @@ -33,7 +32,7 @@ func main() { log.Fatal(err) } - ctx := context.WithValue(context.Background(), utils.ContextServerID("ServerID"), conf.ServerID) + ctx := context.WithValue(context.Background(), internal.ContextServerID("ServerID"), conf.ServerID) // Default BindAddr if it's not specified if conf.BindAddr == "" { diff --git a/coverage/coverage.out b/coverage/coverage.out index cb81316..8156ecc 100644 --- a/coverage/coverage.out +++ b/coverage/coverage.out @@ -1,77 +1,4 @@ mode: set -github.com/echovault/echovault/pkg/modules/admin/commands.go:28.115,34.29 4 1 -github.com/echovault/echovault/pkg/modules/admin/commands.go:34.29,35.54 1 1 -github.com/echovault/echovault/pkg/modules/admin/commands.go:35.54,41.42 4 1 -github.com/echovault/echovault/pkg/modules/admin/commands.go:41.42,43.5 1 1 -github.com/echovault/echovault/pkg/modules/admin/commands.go:45.4,48.12 3 1 -github.com/echovault/echovault/pkg/modules/admin/commands.go:51.3,51.36 1 1 -github.com/echovault/echovault/pkg/modules/admin/commands.go:51.36,58.43 5 1 -github.com/echovault/echovault/pkg/modules/admin/commands.go:58.43,60.5 1 1 -github.com/echovault/echovault/pkg/modules/admin/commands.go:62.4,64.21 2 1 -github.com/echovault/echovault/pkg/modules/admin/commands.go:68.2,70.25 2 1 -github.com/echovault/echovault/pkg/modules/admin/commands.go:73.109,77.35 3 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:77.35,78.65 1 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:78.65,79.41 1 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:79.41,81.5 1 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:82.4,82.12 1 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:84.3,84.13 1 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:87.2,87.51 1 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:90.112,91.18 1 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:92.9,97.36 4 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:97.36,98.66 1 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:98.66,99.52 1 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:99.52,103.6 3 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:104.5,104.13 1 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:106.4,107.14 2 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:109.3,110.26 2 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:112.9,116.45 3 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:116.45,118.4 1 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:119.3,119.42 1 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:119.42,123.37 3 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:123.37,124.67 1 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:124.67,125.53 1 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:125.53,126.59 1 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:126.59,130.8 3 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:132.6,132.14 1 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:134.5,134.54 1 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:134.54,137.6 2 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:139.9,139.50 1 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:139.50,143.37 3 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:143.37,144.67 1 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:144.67,145.53 1 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:145.53,147.24 2 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:147.24,150.8 2 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:152.6,152.14 1 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:154.5,154.33 1 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:154.33,157.6 2 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:159.9,161.4 1 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:162.3,163.26 2 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:164.10,165.50 1 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:169.112,171.2 1 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:173.33,180.60 1 1 -github.com/echovault/echovault/pkg/modules/admin/commands.go:180.60,180.86 1 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:188.60,190.5 1 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:197.62,197.88 1 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:205.62,205.88 1 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:214.62,214.88 1 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:224.60,226.5 1 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:227.113,228.49 1 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:228.49,230.6 1 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:231.5,231.41 1 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:239.60,241.5 1 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:242.113,244.18 2 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:244.18,246.6 1 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:247.5,247.53 1 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:255.60,257.5 1 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:258.113,259.47 1 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:259.47,261.6 1 0 -github.com/echovault/echovault/pkg/modules/admin/commands.go:262.5,262.41 1 0 -github.com/echovault/echovault/pkg/modules/connection/commands.go:25.108,26.18 1 1 -github.com/echovault/echovault/pkg/modules/connection/commands.go:27.10,28.50 1 1 -github.com/echovault/echovault/pkg/modules/connection/commands.go:29.9,30.34 1 1 -github.com/echovault/echovault/pkg/modules/connection/commands.go:31.9,32.72 1 1 -github.com/echovault/echovault/pkg/modules/connection/commands.go:36.33,43.60 1 0 -github.com/echovault/echovault/pkg/modules/connection/commands.go:43.60,45.5 1 0 github.com/echovault/echovault/pkg/modules/acl/commands.go:33.108,34.34 1 1 github.com/echovault/echovault/pkg/modules/acl/commands.go:34.34,36.3 1 1 github.com/echovault/echovault/pkg/modules/acl/commands.go:37.2,38.9 2 1 @@ -276,260 +203,6 @@ github.com/echovault/echovault/pkg/modules/acl/commands.go:569.62,571.7 1 1 github.com/echovault/echovault/pkg/modules/acl/commands.go:579.62,581.7 1 1 github.com/echovault/echovault/pkg/modules/acl/commands.go:592.62,594.7 1 0 github.com/echovault/echovault/pkg/modules/acl/commands.go:602.62,604.7 1 0 -github.com/echovault/echovault/pkg/modules/generic/commands.go:33.13,34.34 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:34.34,38.3 2 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:40.2,41.29 2 0 -github.com/echovault/echovault/pkg/modules/generic/commands.go:41.29,43.3 1 0 -github.com/echovault/echovault/pkg/modules/generic/commands.go:51.104,53.16 2 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:53.16,55.3 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:57.2,62.16 5 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:62.16,64.3 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:68.2,68.16 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:68.16,69.34 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:69.34,71.4 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:71.9,73.4 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:76.2,76.44 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:76.44,78.34 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:78.34,80.4 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:81.3,81.36 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:82.8,82.51 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:82.51,84.33 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:84.33,86.4 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:87.3,87.45 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:88.8,90.34 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:90.34,93.4 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:93.9,96.4 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:98.2,98.16 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:98.16,100.3 1 0 -github.com/echovault/echovault/pkg/modules/generic/commands.go:101.2,103.76 2 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:103.76,105.3 1 0 -github.com/echovault/echovault/pkg/modules/generic/commands.go:108.2,108.28 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:108.28,110.3 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:112.2,112.17 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:115.105,116.44 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:116.44,118.3 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:120.2,123.15 2 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:123.15,124.29 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:124.29,125.16 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:125.16,131.5 2 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:136.2,136.30 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:136.30,137.15 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:137.15,142.4 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:147.2,147.28 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:147.28,148.31 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:148.31,149.52 1 0 -github.com/echovault/echovault/pkg/modules/generic/commands.go:149.52,151.5 1 0 -github.com/echovault/echovault/pkg/modules/generic/commands.go:152.4,153.12 2 0 -github.com/echovault/echovault/pkg/modules/generic/commands.go:155.3,155.60 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:155.60,157.4 1 0 -github.com/echovault/echovault/pkg/modules/generic/commands.go:158.3,158.55 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:162.2,162.28 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:162.28,163.58 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:163.58,165.4 1 0 -github.com/echovault/echovault/pkg/modules/generic/commands.go:168.2,168.38 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:171.104,173.16 2 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:173.16,175.3 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:176.2,178.33 2 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:178.33,180.3 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:182.2,183.16 2 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:183.16,185.3 1 0 -github.com/echovault/echovault/pkg/modules/generic/commands.go:186.2,190.51 3 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:193.105,195.16 2 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:195.16,197.3 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:199.2,202.27 3 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:202.27,203.31 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:203.31,205.12 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:207.3,207.33 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:207.33,209.18 2 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:209.18,211.5 1 0 -github.com/echovault/echovault/pkg/modules/generic/commands.go:212.4,213.12 2 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:215.3,215.19 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:217.2,217.15 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:217.15,218.34 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:218.34,219.14 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:219.14,222.5 2 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:226.2,226.28 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:226.28,228.3 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:230.2,232.30 2 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:232.30,233.24 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:233.24,235.12 2 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:237.3,237.96 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:240.2,240.19 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:243.104,245.16 2 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:245.16,247.3 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:248.2,249.27 2 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:249.27,251.17 2 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:251.17,253.12 2 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:255.3,255.13 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:257.2,257.51 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:260.108,262.16 2 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:262.16,264.3 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:266.2,268.33 2 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:268.33,270.3 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:272.2,272.51 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:272.51,274.3 1 0 -github.com/echovault/echovault/pkg/modules/generic/commands.go:275.2,278.31 3 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:278.31,280.3 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:282.2,284.30 2 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:287.111,289.16 2 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:289.16,291.3 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:293.2,295.33 2 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:295.33,297.3 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:299.2,299.52 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:299.52,301.3 1 0 -github.com/echovault/echovault/pkg/modules/generic/commands.go:302.2,306.31 3 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:306.31,308.3 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:310.2,311.46 2 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:311.46,313.3 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:315.2,315.47 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:318.104,320.16 2 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:320.16,322.3 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:324.2,326.33 2 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:326.33,328.3 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:330.2,330.52 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:330.52,332.3 1 0 -github.com/echovault/echovault/pkg/modules/generic/commands.go:333.2,337.31 3 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:337.31,339.3 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:341.2,342.39 2 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:342.39,344.3 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:346.2,346.12 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:346.12,348.3 1 0 -github.com/echovault/echovault/pkg/modules/generic/commands.go:350.2,350.47 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:353.107,355.16 2 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:355.16,357.3 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:359.2,363.16 3 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:363.16,365.3 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:366.2,367.42 2 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:367.42,369.3 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:371.2,371.33 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:371.33,373.3 1 0 -github.com/echovault/echovault/pkg/modules/generic/commands.go:375.2,375.51 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:375.51,377.3 1 0 -github.com/echovault/echovault/pkg/modules/generic/commands.go:378.2,380.19 2 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:380.19,383.3 2 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:385.2,387.33 2 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:388.12,389.39 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:389.39,391.4 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:392.3,392.46 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:393.12,394.39 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:394.39,396.4 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:397.3,397.46 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:398.12,399.39 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:399.39,401.4 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:402.3,402.39 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:402.39,404.4 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:405.3,405.46 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:406.12,407.39 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:407.39,408.40 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:408.40,410.5 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:411.4,411.47 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:413.3,413.46 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:414.10,415.71 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:418.2,418.30 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:421.109,423.16 2 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:423.16,425.3 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:427.2,431.16 3 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:431.16,433.3 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:434.2,435.44 2 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:435.44,437.3 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:439.2,439.33 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:439.33,441.3 1 0 -github.com/echovault/echovault/pkg/modules/generic/commands.go:443.2,443.51 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:443.51,445.3 1 0 -github.com/echovault/echovault/pkg/modules/generic/commands.go:446.2,448.19 2 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:448.19,451.3 2 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:453.2,455.33 2 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:456.12,457.39 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:457.39,459.4 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:460.3,460.46 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:461.12,462.39 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:462.39,464.4 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:465.3,465.46 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:466.12,467.39 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:467.39,469.4 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:470.3,470.39 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:470.39,472.4 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:473.3,473.46 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:474.12,475.39 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:475.39,476.40 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:476.40,478.5 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:479.4,479.47 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:481.3,481.46 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:482.10,483.71 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:486.2,486.30 1 1 -github.com/echovault/echovault/pkg/modules/generic/commands.go:489.33,644.2 1 0 -github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:22.49,23.34 1 1 -github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:23.34,25.3 1 1 -github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:26.2,26.30 1 1 -github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:29.50,30.25 1 1 -github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:30.25,32.3 1 1 -github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:33.2,34.30 2 1 -github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:34.30,35.15 1 1 -github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:35.15,37.4 1 1 -github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:39.2,39.18 1 1 -github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:42.49,43.19 1 1 -github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:43.19,45.3 1 1 -github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:46.2,46.30 1 1 -github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:49.50,50.18 1 1 -github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:50.18,52.3 1 1 -github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:53.2,53.21 1 1 -github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:56.49,57.18 1 1 -github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:57.18,59.3 1 1 -github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:60.2,60.21 1 1 -github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:63.53,64.19 1 1 -github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:64.19,66.3 1 1 -github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:67.2,67.21 1 1 -github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:70.56,71.19 1 1 -github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:71.19,73.3 1 1 -github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:74.2,74.21 1 1 -github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:77.49,78.19 1 1 -github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:78.19,80.3 1 1 -github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:81.2,81.21 1 1 -github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:84.52,85.34 1 1 -github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:85.34,87.3 1 1 -github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:88.2,88.30 1 1 -github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:91.54,92.34 1 0 -github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:92.34,94.3 1 0 -github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:95.2,95.30 1 0 -github.com/echovault/echovault/pkg/modules/generic/utils.go:31.77,32.19 1 1 -github.com/echovault/echovault/pkg/modules/generic/utils.go:32.19,34.3 1 1 -github.com/echovault/echovault/pkg/modules/generic/utils.go:35.2,35.33 1 1 -github.com/echovault/echovault/pkg/modules/generic/utils.go:36.13,38.46 2 1 -github.com/echovault/echovault/pkg/modules/generic/utils.go:40.12,41.26 1 1 -github.com/echovault/echovault/pkg/modules/generic/utils.go:41.26,43.4 1 1 -github.com/echovault/echovault/pkg/modules/generic/utils.go:44.3,45.46 2 1 -github.com/echovault/echovault/pkg/modules/generic/utils.go:47.12,48.26 1 1 -github.com/echovault/echovault/pkg/modules/generic/utils.go:48.26,50.4 1 1 -github.com/echovault/echovault/pkg/modules/generic/utils.go:51.3,52.46 2 1 -github.com/echovault/echovault/pkg/modules/generic/utils.go:54.12,55.19 1 1 -github.com/echovault/echovault/pkg/modules/generic/utils.go:55.19,57.4 1 1 -github.com/echovault/echovault/pkg/modules/generic/utils.go:58.3,58.29 1 1 -github.com/echovault/echovault/pkg/modules/generic/utils.go:58.29,60.4 1 1 -github.com/echovault/echovault/pkg/modules/generic/utils.go:61.3,63.17 3 1 -github.com/echovault/echovault/pkg/modules/generic/utils.go:63.17,65.4 1 1 -github.com/echovault/echovault/pkg/modules/generic/utils.go:66.3,67.46 2 1 -github.com/echovault/echovault/pkg/modules/generic/utils.go:69.12,70.19 1 1 -github.com/echovault/echovault/pkg/modules/generic/utils.go:70.19,72.4 1 1 -github.com/echovault/echovault/pkg/modules/generic/utils.go:73.3,73.29 1 1 -github.com/echovault/echovault/pkg/modules/generic/utils.go:73.29,75.4 1 1 -github.com/echovault/echovault/pkg/modules/generic/utils.go:76.3,78.17 3 1 -github.com/echovault/echovault/pkg/modules/generic/utils.go:78.17,80.4 1 1 -github.com/echovault/echovault/pkg/modules/generic/utils.go:81.3,82.46 2 1 -github.com/echovault/echovault/pkg/modules/generic/utils.go:84.14,85.19 1 1 -github.com/echovault/echovault/pkg/modules/generic/utils.go:85.19,87.4 1 1 -github.com/echovault/echovault/pkg/modules/generic/utils.go:88.3,88.29 1 1 -github.com/echovault/echovault/pkg/modules/generic/utils.go:88.29,90.4 1 1 -github.com/echovault/echovault/pkg/modules/generic/utils.go:91.3,93.17 3 1 -github.com/echovault/echovault/pkg/modules/generic/utils.go:93.17,95.4 1 1 -github.com/echovault/echovault/pkg/modules/generic/utils.go:96.3,97.46 2 1 -github.com/echovault/echovault/pkg/modules/generic/utils.go:99.14,100.19 1 1 -github.com/echovault/echovault/pkg/modules/generic/utils.go:100.19,102.4 1 1 -github.com/echovault/echovault/pkg/modules/generic/utils.go:103.3,103.29 1 1 -github.com/echovault/echovault/pkg/modules/generic/utils.go:103.29,105.4 1 1 -github.com/echovault/echovault/pkg/modules/generic/utils.go:106.3,108.17 3 1 -github.com/echovault/echovault/pkg/modules/generic/utils.go:108.17,110.4 1 1 -github.com/echovault/echovault/pkg/modules/generic/utils.go:111.3,112.46 2 1 -github.com/echovault/echovault/pkg/modules/generic/utils.go:114.10,115.95 1 1 github.com/echovault/echovault/pkg/modules/hash/commands.go:30.105,32.16 2 1 github.com/echovault/echovault/pkg/modules/hash/commands.go:32.16,34.3 1 1 github.com/echovault/echovault/pkg/modules/hash/commands.go:36.2,39.25 3 1 @@ -794,6 +467,260 @@ github.com/echovault/echovault/pkg/modules/hash/key_funcs.go:99.2,99.22 1 1 github.com/echovault/echovault/pkg/modules/hash/key_funcs.go:102.50,103.18 1 1 github.com/echovault/echovault/pkg/modules/hash/key_funcs.go:103.18,105.3 1 1 github.com/echovault/echovault/pkg/modules/hash/key_funcs.go:106.2,106.22 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:33.13,34.34 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:34.34,38.3 2 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:40.2,41.29 2 0 +github.com/echovault/echovault/pkg/modules/generic/commands.go:41.29,43.3 1 0 +github.com/echovault/echovault/pkg/modules/generic/commands.go:51.104,53.16 2 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:53.16,55.3 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:57.2,62.16 5 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:62.16,64.3 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:68.2,68.16 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:68.16,69.34 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:69.34,71.4 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:71.9,73.4 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:76.2,76.44 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:76.44,78.34 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:78.34,80.4 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:81.3,81.36 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:82.8,82.51 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:82.51,84.33 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:84.33,86.4 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:87.3,87.45 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:88.8,90.34 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:90.34,93.4 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:93.9,96.4 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:98.2,98.16 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:98.16,100.3 1 0 +github.com/echovault/echovault/pkg/modules/generic/commands.go:101.2,103.76 2 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:103.76,105.3 1 0 +github.com/echovault/echovault/pkg/modules/generic/commands.go:108.2,108.28 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:108.28,110.3 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:112.2,112.17 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:115.105,116.44 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:116.44,118.3 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:120.2,123.15 2 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:123.15,124.29 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:124.29,125.16 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:125.16,131.5 2 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:136.2,136.30 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:136.30,137.15 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:137.15,142.4 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:147.2,147.28 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:147.28,148.31 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:148.31,149.52 1 0 +github.com/echovault/echovault/pkg/modules/generic/commands.go:149.52,151.5 1 0 +github.com/echovault/echovault/pkg/modules/generic/commands.go:152.4,153.12 2 0 +github.com/echovault/echovault/pkg/modules/generic/commands.go:155.3,155.60 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:155.60,157.4 1 0 +github.com/echovault/echovault/pkg/modules/generic/commands.go:158.3,158.55 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:162.2,162.28 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:162.28,163.58 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:163.58,165.4 1 0 +github.com/echovault/echovault/pkg/modules/generic/commands.go:168.2,168.38 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:171.104,173.16 2 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:173.16,175.3 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:176.2,178.33 2 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:178.33,180.3 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:182.2,183.16 2 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:183.16,185.3 1 0 +github.com/echovault/echovault/pkg/modules/generic/commands.go:186.2,190.51 3 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:193.105,195.16 2 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:195.16,197.3 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:199.2,202.27 3 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:202.27,203.31 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:203.31,205.12 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:207.3,207.33 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:207.33,209.18 2 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:209.18,211.5 1 0 +github.com/echovault/echovault/pkg/modules/generic/commands.go:212.4,213.12 2 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:215.3,215.19 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:217.2,217.15 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:217.15,218.34 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:218.34,219.14 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:219.14,222.5 2 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:226.2,226.28 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:226.28,228.3 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:230.2,232.30 2 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:232.30,233.24 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:233.24,235.12 2 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:237.3,237.96 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:240.2,240.19 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:243.104,245.16 2 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:245.16,247.3 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:248.2,249.27 2 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:249.27,251.17 2 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:251.17,253.12 2 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:255.3,255.13 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:257.2,257.51 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:260.108,262.16 2 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:262.16,264.3 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:266.2,268.33 2 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:268.33,270.3 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:272.2,272.51 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:272.51,274.3 1 0 +github.com/echovault/echovault/pkg/modules/generic/commands.go:275.2,278.31 3 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:278.31,280.3 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:282.2,284.30 2 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:287.111,289.16 2 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:289.16,291.3 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:293.2,295.33 2 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:295.33,297.3 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:299.2,299.52 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:299.52,301.3 1 0 +github.com/echovault/echovault/pkg/modules/generic/commands.go:302.2,306.31 3 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:306.31,308.3 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:310.2,311.46 2 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:311.46,313.3 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:315.2,315.47 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:318.104,320.16 2 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:320.16,322.3 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:324.2,326.33 2 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:326.33,328.3 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:330.2,330.52 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:330.52,332.3 1 0 +github.com/echovault/echovault/pkg/modules/generic/commands.go:333.2,337.31 3 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:337.31,339.3 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:341.2,342.39 2 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:342.39,344.3 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:346.2,346.12 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:346.12,348.3 1 0 +github.com/echovault/echovault/pkg/modules/generic/commands.go:350.2,350.47 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:353.107,355.16 2 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:355.16,357.3 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:359.2,363.16 3 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:363.16,365.3 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:366.2,367.42 2 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:367.42,369.3 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:371.2,371.33 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:371.33,373.3 1 0 +github.com/echovault/echovault/pkg/modules/generic/commands.go:375.2,375.51 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:375.51,377.3 1 0 +github.com/echovault/echovault/pkg/modules/generic/commands.go:378.2,380.19 2 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:380.19,383.3 2 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:385.2,387.33 2 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:388.12,389.39 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:389.39,391.4 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:392.3,392.46 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:393.12,394.39 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:394.39,396.4 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:397.3,397.46 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:398.12,399.39 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:399.39,401.4 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:402.3,402.39 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:402.39,404.4 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:405.3,405.46 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:406.12,407.39 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:407.39,408.40 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:408.40,410.5 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:411.4,411.47 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:413.3,413.46 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:414.10,415.71 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:418.2,418.30 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:421.109,423.16 2 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:423.16,425.3 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:427.2,431.16 3 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:431.16,433.3 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:434.2,435.44 2 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:435.44,437.3 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:439.2,439.33 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:439.33,441.3 1 0 +github.com/echovault/echovault/pkg/modules/generic/commands.go:443.2,443.51 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:443.51,445.3 1 0 +github.com/echovault/echovault/pkg/modules/generic/commands.go:446.2,448.19 2 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:448.19,451.3 2 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:453.2,455.33 2 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:456.12,457.39 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:457.39,459.4 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:460.3,460.46 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:461.12,462.39 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:462.39,464.4 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:465.3,465.46 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:466.12,467.39 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:467.39,469.4 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:470.3,470.39 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:470.39,472.4 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:473.3,473.46 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:474.12,475.39 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:475.39,476.40 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:476.40,478.5 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:479.4,479.47 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:481.3,481.46 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:482.10,483.71 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:486.2,486.30 1 1 +github.com/echovault/echovault/pkg/modules/generic/commands.go:489.33,644.2 1 0 +github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:22.49,23.34 1 1 +github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:23.34,25.3 1 1 +github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:26.2,26.30 1 1 +github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:29.50,30.25 1 1 +github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:30.25,32.3 1 1 +github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:33.2,34.30 2 1 +github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:34.30,35.15 1 1 +github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:35.15,37.4 1 1 +github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:39.2,39.18 1 1 +github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:42.49,43.19 1 1 +github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:43.19,45.3 1 1 +github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:46.2,46.30 1 1 +github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:49.50,50.18 1 1 +github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:50.18,52.3 1 1 +github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:53.2,53.21 1 1 +github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:56.49,57.18 1 1 +github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:57.18,59.3 1 1 +github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:60.2,60.21 1 1 +github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:63.53,64.19 1 1 +github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:64.19,66.3 1 1 +github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:67.2,67.21 1 1 +github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:70.56,71.19 1 1 +github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:71.19,73.3 1 1 +github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:74.2,74.21 1 1 +github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:77.49,78.19 1 1 +github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:78.19,80.3 1 1 +github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:81.2,81.21 1 1 +github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:84.52,85.34 1 1 +github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:85.34,87.3 1 1 +github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:88.2,88.30 1 1 +github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:91.54,92.34 1 0 +github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:92.34,94.3 1 0 +github.com/echovault/echovault/pkg/modules/generic/key_funcs.go:95.2,95.30 1 0 +github.com/echovault/echovault/pkg/modules/generic/utils.go:31.77,32.19 1 1 +github.com/echovault/echovault/pkg/modules/generic/utils.go:32.19,34.3 1 1 +github.com/echovault/echovault/pkg/modules/generic/utils.go:35.2,35.33 1 1 +github.com/echovault/echovault/pkg/modules/generic/utils.go:36.13,38.46 2 1 +github.com/echovault/echovault/pkg/modules/generic/utils.go:40.12,41.26 1 1 +github.com/echovault/echovault/pkg/modules/generic/utils.go:41.26,43.4 1 1 +github.com/echovault/echovault/pkg/modules/generic/utils.go:44.3,45.46 2 1 +github.com/echovault/echovault/pkg/modules/generic/utils.go:47.12,48.26 1 1 +github.com/echovault/echovault/pkg/modules/generic/utils.go:48.26,50.4 1 1 +github.com/echovault/echovault/pkg/modules/generic/utils.go:51.3,52.46 2 1 +github.com/echovault/echovault/pkg/modules/generic/utils.go:54.12,55.19 1 1 +github.com/echovault/echovault/pkg/modules/generic/utils.go:55.19,57.4 1 1 +github.com/echovault/echovault/pkg/modules/generic/utils.go:58.3,58.29 1 1 +github.com/echovault/echovault/pkg/modules/generic/utils.go:58.29,60.4 1 1 +github.com/echovault/echovault/pkg/modules/generic/utils.go:61.3,63.17 3 1 +github.com/echovault/echovault/pkg/modules/generic/utils.go:63.17,65.4 1 1 +github.com/echovault/echovault/pkg/modules/generic/utils.go:66.3,67.46 2 1 +github.com/echovault/echovault/pkg/modules/generic/utils.go:69.12,70.19 1 1 +github.com/echovault/echovault/pkg/modules/generic/utils.go:70.19,72.4 1 1 +github.com/echovault/echovault/pkg/modules/generic/utils.go:73.3,73.29 1 1 +github.com/echovault/echovault/pkg/modules/generic/utils.go:73.29,75.4 1 1 +github.com/echovault/echovault/pkg/modules/generic/utils.go:76.3,78.17 3 1 +github.com/echovault/echovault/pkg/modules/generic/utils.go:78.17,80.4 1 1 +github.com/echovault/echovault/pkg/modules/generic/utils.go:81.3,82.46 2 1 +github.com/echovault/echovault/pkg/modules/generic/utils.go:84.14,85.19 1 1 +github.com/echovault/echovault/pkg/modules/generic/utils.go:85.19,87.4 1 1 +github.com/echovault/echovault/pkg/modules/generic/utils.go:88.3,88.29 1 1 +github.com/echovault/echovault/pkg/modules/generic/utils.go:88.29,90.4 1 1 +github.com/echovault/echovault/pkg/modules/generic/utils.go:91.3,93.17 3 1 +github.com/echovault/echovault/pkg/modules/generic/utils.go:93.17,95.4 1 1 +github.com/echovault/echovault/pkg/modules/generic/utils.go:96.3,97.46 2 1 +github.com/echovault/echovault/pkg/modules/generic/utils.go:99.14,100.19 1 1 +github.com/echovault/echovault/pkg/modules/generic/utils.go:100.19,102.4 1 1 +github.com/echovault/echovault/pkg/modules/generic/utils.go:103.3,103.29 1 1 +github.com/echovault/echovault/pkg/modules/generic/utils.go:103.29,105.4 1 1 +github.com/echovault/echovault/pkg/modules/generic/utils.go:106.3,108.17 3 1 +github.com/echovault/echovault/pkg/modules/generic/utils.go:108.17,110.4 1 1 +github.com/echovault/echovault/pkg/modules/generic/utils.go:111.3,112.46 2 1 +github.com/echovault/echovault/pkg/modules/generic/utils.go:114.10,115.95 1 1 github.com/echovault/echovault/pkg/modules/list/commands.go:29.105,31.16 2 1 github.com/echovault/echovault/pkg/modules/list/commands.go:31.16,33.3 1 1 github.com/echovault/echovault/pkg/modules/list/commands.go:35.2,37.33 2 1 @@ -1013,6 +940,79 @@ github.com/echovault/echovault/pkg/modules/list/key_funcs.go:82.2,82.30 1 1 github.com/echovault/echovault/pkg/modules/list/key_funcs.go:85.51,86.19 1 1 github.com/echovault/echovault/pkg/modules/list/key_funcs.go:86.19,88.3 1 1 github.com/echovault/echovault/pkg/modules/list/key_funcs.go:89.2,89.38 1 1 +github.com/echovault/echovault/pkg/modules/admin/commands.go:28.115,34.29 4 1 +github.com/echovault/echovault/pkg/modules/admin/commands.go:34.29,35.54 1 1 +github.com/echovault/echovault/pkg/modules/admin/commands.go:35.54,41.42 4 1 +github.com/echovault/echovault/pkg/modules/admin/commands.go:41.42,43.5 1 1 +github.com/echovault/echovault/pkg/modules/admin/commands.go:45.4,48.12 3 1 +github.com/echovault/echovault/pkg/modules/admin/commands.go:51.3,51.36 1 1 +github.com/echovault/echovault/pkg/modules/admin/commands.go:51.36,58.43 5 1 +github.com/echovault/echovault/pkg/modules/admin/commands.go:58.43,60.5 1 1 +github.com/echovault/echovault/pkg/modules/admin/commands.go:62.4,64.21 2 1 +github.com/echovault/echovault/pkg/modules/admin/commands.go:68.2,70.25 2 1 +github.com/echovault/echovault/pkg/modules/admin/commands.go:73.109,77.35 3 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:77.35,78.65 1 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:78.65,79.41 1 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:79.41,81.5 1 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:82.4,82.12 1 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:84.3,84.13 1 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:87.2,87.51 1 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:90.112,91.18 1 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:92.9,97.36 4 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:97.36,98.66 1 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:98.66,99.52 1 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:99.52,103.6 3 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:104.5,104.13 1 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:106.4,107.14 2 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:109.3,110.26 2 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:112.9,116.45 3 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:116.45,118.4 1 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:119.3,119.42 1 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:119.42,123.37 3 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:123.37,124.67 1 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:124.67,125.53 1 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:125.53,126.59 1 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:126.59,130.8 3 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:132.6,132.14 1 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:134.5,134.54 1 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:134.54,137.6 2 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:139.9,139.50 1 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:139.50,143.37 3 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:143.37,144.67 1 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:144.67,145.53 1 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:145.53,147.24 2 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:147.24,150.8 2 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:152.6,152.14 1 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:154.5,154.33 1 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:154.33,157.6 2 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:159.9,161.4 1 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:162.3,163.26 2 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:164.10,165.50 1 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:169.112,171.2 1 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:173.33,180.60 1 1 +github.com/echovault/echovault/pkg/modules/admin/commands.go:180.60,180.86 1 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:188.60,190.5 1 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:197.62,197.88 1 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:205.62,205.88 1 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:214.62,214.88 1 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:224.60,226.5 1 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:227.113,228.49 1 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:228.49,230.6 1 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:231.5,231.41 1 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:239.60,241.5 1 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:242.113,244.18 2 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:244.18,246.6 1 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:247.5,247.53 1 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:255.60,257.5 1 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:258.113,259.47 1 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:259.47,261.6 1 0 +github.com/echovault/echovault/pkg/modules/admin/commands.go:262.5,262.41 1 0 +github.com/echovault/echovault/pkg/modules/connection/commands.go:25.108,26.18 1 1 +github.com/echovault/echovault/pkg/modules/connection/commands.go:27.10,28.50 1 1 +github.com/echovault/echovault/pkg/modules/connection/commands.go:29.9,30.34 1 1 +github.com/echovault/echovault/pkg/modules/connection/commands.go:31.9,32.72 1 1 +github.com/echovault/echovault/pkg/modules/connection/commands.go:36.33,43.60 1 0 +github.com/echovault/echovault/pkg/modules/connection/commands.go:43.60,45.5 1 0 github.com/echovault/echovault/pkg/modules/set/commands.go:28.108,30.16 2 1 github.com/echovault/echovault/pkg/modules/set/commands.go:30.16,32.3 1 1 github.com/echovault/echovault/pkg/modules/set/commands.go:34.2,38.33 3 1 diff --git a/internal/aof/engine.go b/internal/aof/engine.go index 0ce76fc..7922c80 100644 --- a/internal/aof/engine.go +++ b/internal/aof/engine.go @@ -16,9 +16,9 @@ package aof import ( "fmt" + "github.com/echovault/echovault/internal" logstore "github.com/echovault/echovault/internal/aof/log" "github.com/echovault/echovault/internal/aof/preamble" - "github.com/echovault/echovault/pkg/utils" "log" "sync" ) @@ -40,8 +40,8 @@ type Engine struct { startRewriteFunc func() finishRewriteFunc func() - getStateFunc func() map[string]utils.KeyData - setKeyDataFunc func(key string, data utils.KeyData) + getStateFunc func() map[string]internal.KeyData + setKeyDataFunc func(key string, data internal.KeyData) handleCommand func(command []byte) } @@ -69,13 +69,13 @@ func WithFinishRewriteFunc(f func()) func(engine *Engine) { } } -func WithGetStateFunc(f func() map[string]utils.KeyData) func(engine *Engine) { +func WithGetStateFunc(f func() map[string]internal.KeyData) func(engine *Engine) { return func(engine *Engine) { engine.getStateFunc = f } } -func WithSetKeyDataFunc(f func(key string, data utils.KeyData)) func(engine *Engine) { +func WithSetKeyDataFunc(f func(key string, data internal.KeyData)) func(engine *Engine) { return func(engine *Engine) { engine.setKeyDataFunc = f } @@ -108,8 +108,8 @@ func NewAOFEngine(options ...func(engine *Engine)) *Engine { logCount: 0, startRewriteFunc: func() {}, finishRewriteFunc: func() {}, - getStateFunc: func() map[string]utils.KeyData { return nil }, - setKeyDataFunc: func(key string, data utils.KeyData) {}, + getStateFunc: func() map[string]internal.KeyData { return nil }, + setKeyDataFunc: func(key string, data internal.KeyData) {}, handleCommand: func(command []byte) {}, } diff --git a/internal/aof/preamble/store.go b/internal/aof/preamble/store.go index a245c92..19aae77 100644 --- a/internal/aof/preamble/store.go +++ b/internal/aof/preamble/store.go @@ -17,7 +17,7 @@ package preamble import ( "encoding/json" "fmt" - "github.com/echovault/echovault/pkg/utils" + "github.com/echovault/echovault/internal" "io" "log" "os" @@ -37,8 +37,8 @@ type PreambleStore struct { rw PreambleReadWriter mut sync.Mutex directory string - getStateFunc func() map[string]utils.KeyData - setKeyDataFunc func(key string, data utils.KeyData) + getStateFunc func() map[string]internal.KeyData + setKeyDataFunc func(key string, data internal.KeyData) } func WithReadWriter(rw PreambleReadWriter) func(store *PreambleStore) { @@ -47,13 +47,13 @@ func WithReadWriter(rw PreambleReadWriter) func(store *PreambleStore) { } } -func WithGetStateFunc(f func() map[string]utils.KeyData) func(store *PreambleStore) { +func WithGetStateFunc(f func() map[string]internal.KeyData) func(store *PreambleStore) { return func(store *PreambleStore) { store.getStateFunc = f } } -func WithSetKeyDataFunc(f func(key string, data utils.KeyData)) func(store *PreambleStore) { +func WithSetKeyDataFunc(f func(key string, data internal.KeyData)) func(store *PreambleStore) { return func(store *PreambleStore) { store.setKeyDataFunc = f } @@ -70,11 +70,11 @@ func NewPreambleStore(options ...func(store *PreambleStore)) *PreambleStore { rw: nil, mut: sync.Mutex{}, directory: "", - getStateFunc: func() map[string]utils.KeyData { + getStateFunc: func() map[string]internal.KeyData { // No-Op by default return nil }, - setKeyDataFunc: func(key string, data utils.KeyData) {}, + setKeyDataFunc: func(key string, data internal.KeyData) {}, } for _, option := range options { @@ -143,7 +143,7 @@ func (store *PreambleStore) Restore() error { return nil } - state := make(map[string]utils.KeyData) + state := make(map[string]internal.KeyData) if err = json.Unmarshal(b, &state); err != nil { return err @@ -163,7 +163,7 @@ func (store *PreambleStore) Close() error { } // filterExpiredKeys filters out keys that are already expired, so they are not persisted. -func (store *PreambleStore) filterExpiredKeys(state map[string]utils.KeyData) map[string]utils.KeyData { +func (store *PreambleStore) filterExpiredKeys(state map[string]internal.KeyData) map[string]internal.KeyData { var keysToDelete []string for k, v := range state { if v.ExpireAt.Before(time.Now()) { diff --git a/internal/memberlist/delegate.go b/internal/memberlist/delegate.go index 86ea7d3..18fb3d1 100644 --- a/internal/memberlist/delegate.go +++ b/internal/memberlist/delegate.go @@ -20,7 +20,6 @@ import ( "fmt" "github.com/echovault/echovault/internal" "github.com/echovault/echovault/internal/config" - "github.com/echovault/echovault/pkg/utils" "github.com/hashicorp/memberlist" "github.com/hashicorp/raft" "log" @@ -93,8 +92,8 @@ func (delegate *Delegate) NotifyMsg(msgBytes []byte) { } // Current node is the cluster leader, handle the key deletion ctx := context.WithValue( - context.WithValue(context.Background(), utils.ContextServerID("ServerID"), string(msg.ServerID)), - utils.ContextConnID("ConnectionID"), msg.ConnId) + context.WithValue(context.Background(), internal.ContextServerID("ServerID"), string(msg.ServerID)), + internal.ContextConnID("ConnectionID"), msg.ConnId) key := string(msg.Content) @@ -110,8 +109,8 @@ func (delegate *Delegate) NotifyMsg(msgBytes []byte) { } // Current node is the cluster leader, handle the mutation ctx := context.WithValue( - context.WithValue(context.Background(), utils.ContextServerID("ServerID"), string(msg.ServerID)), - utils.ContextConnID("ConnectionID"), msg.ConnId) + context.WithValue(context.Background(), internal.ContextServerID("ServerID"), string(msg.ServerID)), + internal.ContextConnID("ConnectionID"), msg.ConnId) cmd, err := internal.Decode(msg.Content) if err != nil { diff --git a/internal/memberlist/memberlist.go b/internal/memberlist/memberlist.go index b35eba0..5247085 100644 --- a/internal/memberlist/memberlist.go +++ b/internal/memberlist/memberlist.go @@ -23,7 +23,6 @@ import ( "log" "time" - "github.com/echovault/echovault/pkg/utils" "github.com/hashicorp/memberlist" "github.com/hashicorp/raft" "github.com/sethvargo/go-retry" @@ -124,7 +123,7 @@ func (m *MemberList) broadcastRaftAddress() { // The ForwardDeleteKey function is only called by non-leaders. // It uses the broadcast queue to forward a key eviction command within the cluster. func (m *MemberList) ForwardDeleteKey(ctx context.Context, key string) { - connId, _ := ctx.Value(utils.ContextConnID("ConnectionID")).(string) + connId, _ := ctx.Value(internal.ContextConnID("ConnectionID")).(string) m.broadcastQueue.QueueBroadcast(&BroadcastMessage{ Action: "DeleteKey", Content: []byte(key), @@ -141,7 +140,7 @@ func (m *MemberList) ForwardDeleteKey(ctx context.Context, key string) { // The ForwardDataMutation function is only called by non-leaders. // It uses the broadcast queue to forward a data mutation within the cluster. func (m *MemberList) ForwardDataMutation(ctx context.Context, cmd []byte) { - connId, _ := ctx.Value(utils.ContextConnID("ConnectionID")).(string) + connId, _ := ctx.Value(internal.ContextConnID("ConnectionID")).(string) m.broadcastQueue.QueueBroadcast(&BroadcastMessage{ Action: "MutateData", Content: cmd, diff --git a/internal/raft/fms_snapshot.go b/internal/raft/fms_snapshot.go index c6a938f..249f97e 100644 --- a/internal/raft/fms_snapshot.go +++ b/internal/raft/fms_snapshot.go @@ -18,7 +18,6 @@ import ( "encoding/json" "github.com/echovault/echovault/internal" "github.com/echovault/echovault/internal/config" - "github.com/echovault/echovault/pkg/utils" "github.com/hashicorp/raft" "strconv" "strings" @@ -26,7 +25,7 @@ import ( type SnapshotOpts struct { config config.Config - data map[string]utils.KeyData + data map[string]internal.KeyData startSnapshot func() finishSnapshot func() setLatestSnapshot func(msec int64) @@ -52,7 +51,7 @@ func (s *Snapshot) Persist(sink raft.SnapshotSink) error { return err } - snapshotObject := utils.SnapshotObject{ + snapshotObject := internal.SnapshotObject{ State: internal.FilterExpiredKeys(s.options.data), LatestSnapshotMilliseconds: int64(msec), } diff --git a/internal/raft/fsm.go b/internal/raft/fsm.go index b412aaf..7a2eb3d 100644 --- a/internal/raft/fsm.go +++ b/internal/raft/fsm.go @@ -30,6 +30,7 @@ import ( type FSMOpts struct { Config config.Config EchoVault utils.EchoVault + GetState func() map[string]internal.KeyData GetCommand func(command string) (utils.Command, error) DeleteKey func(ctx context.Context, key string) error } @@ -50,33 +51,33 @@ func (fsm *FSM) Apply(log *raft.Log) interface{} { default: // No-Op case raft.LogCommand: - var request utils.ApplyRequest + var request internal.ApplyRequest if err := json.Unmarshal(log.Data, &request); err != nil { - return utils.ApplyResponse{ + return internal.ApplyResponse{ Error: err, Response: nil, } } - ctx := context.WithValue(context.Background(), utils.ContextServerID("ServerID"), request.ServerID) - ctx = context.WithValue(ctx, utils.ContextConnID("ConnectionID"), request.ConnectionID) + ctx := context.WithValue(context.Background(), internal.ContextServerID("ServerID"), request.ServerID) + ctx = context.WithValue(ctx, internal.ContextConnID("ConnectionID"), request.ConnectionID) switch strings.ToLower(request.Type) { default: - return utils.ApplyResponse{ + return internal.ApplyResponse{ Error: fmt.Errorf("unsupported raft command type %s", request.Type), Response: nil, } case "delete-key": if err := fsm.options.DeleteKey(ctx, request.Key); err != nil { - return utils.ApplyResponse{ + return internal.ApplyResponse{ Error: err, Response: nil, } } - return utils.ApplyResponse{ + return internal.ApplyResponse{ Error: nil, Response: []byte("OK"), } @@ -85,7 +86,7 @@ func (fsm *FSM) Apply(log *raft.Log) interface{} { // Handle command command, err := fsm.options.GetCommand(request.CMD[0]) if err != nil { - return utils.ApplyResponse{ + return internal.ApplyResponse{ Error: err, Response: nil, } @@ -99,12 +100,12 @@ func (fsm *FSM) Apply(log *raft.Log) interface{} { } if res, err := handler(ctx, request.CMD, fsm.options.EchoVault, nil); err != nil { - return utils.ApplyResponse{ + return internal.ApplyResponse{ Error: err, Response: nil, } } else { - return utils.ApplyResponse{ + return internal.ApplyResponse{ Error: nil, Response: res, } @@ -119,10 +120,10 @@ func (fsm *FSM) Apply(log *raft.Log) interface{} { func (fsm *FSM) Snapshot() (raft.FSMSnapshot, error) { return NewFSMSnapshot(SnapshotOpts{ config: fsm.options.Config, - data: fsm.options.EchoVault.GetState(), startSnapshot: fsm.options.EchoVault.StartSnapshot, finishSnapshot: fsm.options.EchoVault.FinishSnapshot, setLatestSnapshot: fsm.options.EchoVault.SetLatestSnapshot, + data: fsm.options.GetState(), }), nil } @@ -135,8 +136,8 @@ func (fsm *FSM) Restore(snapshot io.ReadCloser) error { return err } - data := utils.SnapshotObject{ - State: make(map[string]utils.KeyData), + data := internal.SnapshotObject{ + State: make(map[string]internal.KeyData), LatestSnapshotMilliseconds: 0, } diff --git a/internal/raft/raft.go b/internal/raft/raft.go index 1f4d599..284e5f9 100644 --- a/internal/raft/raft.go +++ b/internal/raft/raft.go @@ -18,6 +18,7 @@ import ( "context" "errors" "fmt" + "github.com/echovault/echovault/internal" "github.com/echovault/echovault/internal/config" "github.com/echovault/echovault/internal/memberlist" "log" @@ -34,6 +35,7 @@ import ( type Opts struct { Config config.Config EchoVault utils.EchoVault + GetState func() map[string]internal.KeyData GetCommand func(command string) (utils.Command, error) DeleteKey func(ctx context.Context, key string) error } @@ -109,6 +111,7 @@ func (r *Raft) RaftInit(ctx context.Context) { NewFSM(FSMOpts{ Config: r.options.Config, EchoVault: r.options.EchoVault, + GetState: r.options.GetState, GetCommand: r.options.GetCommand, DeleteKey: r.options.DeleteKey, }), diff --git a/internal/snapshot/snapshot.go b/internal/snapshot/snapshot.go index 75c9214..4ce4a7b 100644 --- a/internal/snapshot/snapshot.go +++ b/internal/snapshot/snapshot.go @@ -20,7 +20,6 @@ import ( "errors" "fmt" "github.com/echovault/echovault/internal" - "github.com/echovault/echovault/pkg/utils" "io" "io/fs" "log" @@ -44,10 +43,10 @@ type Engine struct { snapshotThreshold uint64 startSnapshotFunc func() finishSnapshotFunc func() - getStateFunc func() map[string]utils.KeyData + getStateFunc func() map[string]internal.KeyData setLatestSnapshotTimeFunc func(msec int64) getLatestSnapshotTimeFunc func() int64 - setKeyDataFunc func(key string, data utils.KeyData) + setKeyDataFunc func(key string, data internal.KeyData) } func WithDirectory(directory string) func(engine *Engine) { @@ -80,7 +79,7 @@ func WithFinishSnapshotFunc(f func()) func(engine *Engine) { } } -func WithGetStateFunc(f func() map[string]utils.KeyData) func(engine *Engine) { +func WithGetStateFunc(f func() map[string]internal.KeyData) func(engine *Engine) { return func(engine *Engine) { engine.getStateFunc = f } @@ -98,7 +97,7 @@ func WithGetLatestSnapshotTimeFunc(f func() int64) func(engine *Engine) { } } -func WithSetKeyDataFunc(f func(key string, data utils.KeyData)) func(engine *Engine) { +func WithSetKeyDataFunc(f func(key string, data internal.KeyData)) func(engine *Engine) { return func(engine *Engine) { engine.setKeyDataFunc = f } @@ -112,14 +111,14 @@ func NewSnapshotEngine(options ...func(engine *Engine)) *Engine { snapshotThreshold: 1000, startSnapshotFunc: func() {}, finishSnapshotFunc: func() {}, - getStateFunc: func() map[string]utils.KeyData { - return map[string]utils.KeyData{} + getStateFunc: func() map[string]internal.KeyData { + return map[string]internal.KeyData{} }, setLatestSnapshotTimeFunc: func(msec int64) {}, getLatestSnapshotTimeFunc: func() int64 { return 0 }, - setKeyDataFunc: func(key string, data utils.KeyData) {}, + setKeyDataFunc: func(key string, data internal.KeyData) {}, } for _, option := range options { @@ -205,7 +204,7 @@ func (engine *Engine) TakeSnapshot() error { } // Get current state - snapshotObject := utils.SnapshotObject{ + snapshotObject := internal.SnapshotObject{ State: internal.FilterExpiredKeys(engine.getStateFunc()), LatestSnapshotMilliseconds: engine.getLatestSnapshotTimeFunc(), } @@ -334,7 +333,7 @@ func (engine *Engine) Restore() error { return nil } - snapshotObject := new(utils.SnapshotObject) + snapshotObject := new(internal.SnapshotObject) if err = json.Unmarshal(sd, snapshotObject); err != nil { return err diff --git a/internal/types.go b/internal/types.go new file mode 100644 index 0000000..277af0d --- /dev/null +++ b/internal/types.go @@ -0,0 +1,43 @@ +// Copyright 2024 Kelvin Clement Mwinuka +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package internal + +import "time" + +type KeyData struct { + Value interface{} + ExpireAt time.Time +} + +type ContextServerID string +type ContextConnID string + +type ApplyRequest struct { + Type string `json:"Type"` // command | delete-key + ServerID string `json:"ServerID"` + ConnectionID string `json:"ConnectionID"` + CMD []string `json:"CMD"` + Key string `json:"Key"` +} + +type ApplyResponse struct { + Error error + Response []byte +} + +type SnapshotObject struct { + State map[string]KeyData + LatestSnapshotMilliseconds int64 +} diff --git a/internal/utils.go b/internal/utils.go index 86a9017..2bb7234 100644 --- a/internal/utils.go +++ b/internal/utils.go @@ -202,7 +202,7 @@ func IsMaxMemoryExceeded(maxMemory uint64) bool { } // FilterExpiredKeys filters out keys that are already expired, so they are not persisted. -func FilterExpiredKeys(state map[string]utils.KeyData) map[string]utils.KeyData { +func FilterExpiredKeys(state map[string]KeyData) map[string]KeyData { var keysToDelete []string for k, v := range state { // Skip keys with no expiry time. diff --git a/pkg/echovault/cluster.go b/pkg/echovault/cluster.go index 6942b8a..3b80fb8 100644 --- a/pkg/echovault/cluster.go +++ b/pkg/echovault/cluster.go @@ -18,7 +18,7 @@ import ( "context" "encoding/json" "fmt" - "github.com/echovault/echovault/pkg/utils" + "github.com/echovault/echovault/internal" "time" ) @@ -27,9 +27,9 @@ func (server *EchoVault) isInCluster() bool { } func (server *EchoVault) raftApplyDeleteKey(ctx context.Context, key string) error { - serverId, _ := ctx.Value(utils.ContextServerID("ServerID")).(string) + serverId, _ := ctx.Value(internal.ContextServerID("ServerID")).(string) - deleteKeyRequest := utils.ApplyRequest{ + deleteKeyRequest := internal.ApplyRequest{ Type: "delete-key", ServerID: serverId, ConnectionID: "nil", @@ -47,7 +47,7 @@ func (server *EchoVault) raftApplyDeleteKey(ctx context.Context, key string) err return err } - r, ok := applyFuture.Response().(utils.ApplyResponse) + r, ok := applyFuture.Response().(internal.ApplyResponse) if !ok { return fmt.Errorf("unprocessable entity %v", r) @@ -61,10 +61,10 @@ func (server *EchoVault) raftApplyDeleteKey(ctx context.Context, key string) err } func (server *EchoVault) raftApplyCommand(ctx context.Context, cmd []string) ([]byte, error) { - serverId, _ := ctx.Value(utils.ContextServerID("ServerID")).(string) - connectionId, _ := ctx.Value(utils.ContextConnID("ConnectionID")).(string) + serverId, _ := ctx.Value(internal.ContextServerID("ServerID")).(string) + connectionId, _ := ctx.Value(internal.ContextConnID("ConnectionID")).(string) - applyRequest := utils.ApplyRequest{ + applyRequest := internal.ApplyRequest{ Type: "command", ServerID: serverId, ConnectionID: connectionId, @@ -82,7 +82,7 @@ func (server *EchoVault) raftApplyCommand(ctx context.Context, cmd []string) ([] return nil, err } - r, ok := applyFuture.Response().(utils.ApplyResponse) + r, ok := applyFuture.Response().(internal.ApplyResponse) if !ok { return nil, fmt.Errorf("unprocessable entity %v", r) diff --git a/pkg/echovault/echovault.go b/pkg/echovault/echovault.go index f84f328..660e788 100644 --- a/pkg/echovault/echovault.go +++ b/pkg/echovault/echovault.go @@ -48,9 +48,9 @@ type EchoVault struct { // the new number is the new connection's ID. connId atomic.Uint64 - store map[string]utils.KeyData // Data store to hold the keys and their associated data, expiry time, etc. - keyLocks map[string]*sync.RWMutex // Map to hold all the individual key locks. - keyCreationLock *sync.Mutex // The mutex for creating a new key. Only one goroutine should be able to create a key at a time. + store map[string]internal.KeyData // Data store to hold the keys and their associated data, expiry time, etc. + keyLocks map[string]*sync.RWMutex // Map to hold all the individual key locks. + keyCreationLock *sync.Mutex // The mutex for creating a new key. Only one goroutine should be able to create a key at a time. // Holds all the keys that are currently associated with an expiry. keysWithExpiry struct { @@ -111,7 +111,7 @@ func NewEchoVault(options ...func(echovault *EchoVault)) *EchoVault { context: context.Background(), commands: make([]utils.Command, 0), config: config.DefaultConfig(), - store: make(map[string]utils.KeyData), + store: make(map[string]internal.KeyData), keyLocks: make(map[string]*sync.RWMutex), keyCreationLock: &sync.Mutex{}, } @@ -120,7 +120,7 @@ func NewEchoVault(options ...func(echovault *EchoVault)) *EchoVault { option(echovault) } - echovault.context = context.WithValue(echovault.context, "ServerID", utils.ContextServerID(echovault.config.ServerID)) + echovault.context = context.WithValue(echovault.context, "ServerID", internal.ContextServerID(echovault.config.ServerID)) // Set up ACL module echovault.ACL = acl.NewACL(echovault.config) @@ -134,6 +134,15 @@ func NewEchoVault(options ...func(echovault *EchoVault)) *EchoVault { EchoVault: echovault, GetCommand: echovault.getCommand, DeleteKey: echovault.DeleteKey, + GetState: func() map[string]internal.KeyData { + state := make(map[string]internal.KeyData) + for k, v := range echovault.getState() { + if data, ok := v.(internal.KeyData); ok { + state[k] = data + } + } + return state + }, }) echovault.memberList = memberlist.NewMemberList(memberlist.Opts{ Config: echovault.config, @@ -150,12 +159,20 @@ func NewEchoVault(options ...func(echovault *EchoVault)) *EchoVault { snapshot.WithDirectory(echovault.config.DataDir), snapshot.WithThreshold(echovault.config.SnapShotThreshold), snapshot.WithInterval(echovault.config.SnapshotInterval), - snapshot.WithGetStateFunc(echovault.GetState), snapshot.WithStartSnapshotFunc(echovault.StartSnapshot), snapshot.WithFinishSnapshotFunc(echovault.FinishSnapshot), snapshot.WithSetLatestSnapshotTimeFunc(echovault.SetLatestSnapshot), snapshot.WithGetLatestSnapshotTimeFunc(echovault.GetLatestSnapshot), - snapshot.WithSetKeyDataFunc(func(key string, data utils.KeyData) { + snapshot.WithGetStateFunc(func() map[string]internal.KeyData { + state := make(map[string]internal.KeyData) + for k, v := range echovault.getState() { + if data, ok := v.(internal.KeyData); ok { + state[k] = data + } + } + return state + }), + snapshot.WithSetKeyDataFunc(func(key string, data internal.KeyData) { ctx := context.Background() if _, err := echovault.CreateKeyAndLock(ctx, key); err != nil { log.Println(err) @@ -173,8 +190,16 @@ func NewEchoVault(options ...func(echovault *EchoVault)) *EchoVault { aof.WithStrategy(echovault.config.AOFSyncStrategy), aof.WithStartRewriteFunc(echovault.StartRewriteAOF), aof.WithFinishRewriteFunc(echovault.FinishRewriteAOF), - aof.WithGetStateFunc(echovault.GetState), - aof.WithSetKeyDataFunc(func(key string, value utils.KeyData) { + aof.WithGetStateFunc(func() map[string]internal.KeyData { + state := make(map[string]internal.KeyData) + for k, v := range echovault.getState() { + if data, ok := v.(internal.KeyData); ok { + state[k] = data + } + } + return state + }), + aof.WithSetKeyDataFunc(func(key string, value internal.KeyData) { ctx := context.Background() if _, err := echovault.CreateKeyAndLock(ctx, key); err != nil { log.Println(err) @@ -292,8 +317,8 @@ func (server *EchoVault) handleConnection(conn net.Conn) { w, r := io.Writer(conn), io.Reader(conn) cid := server.connId.Add(1) - ctx := context.WithValue(server.context, utils.ContextConnID("ConnectionID"), - fmt.Sprintf("%s-%d", server.context.Value(utils.ContextServerID("ServerID")), cid)) + ctx := context.WithValue(server.context, internal.ContextConnID("ConnectionID"), + fmt.Sprintf("%s-%d", server.context.Value(internal.ContextServerID("ServerID")), cid)) for { message, err := internal.ReadMessage(r) diff --git a/pkg/echovault/keyspace.go b/pkg/echovault/keyspace.go index da802f0..b9a9768 100644 --- a/pkg/echovault/keyspace.go +++ b/pkg/echovault/keyspace.go @@ -141,7 +141,7 @@ func (server *EchoVault) CreateKeyAndLock(ctx context.Context, key string) (bool keyLock.Lock() server.keyLocks[key] = keyLock // Create key entry - server.store[key] = utils.KeyData{ + server.store[key] = internal.KeyData{ Value: nil, ExpireAt: time.Time{}, } @@ -170,7 +170,7 @@ func (server *EchoVault) SetValue(ctx context.Context, key string, value interfa return errors.New("max memory reached, key value not set") } - server.store[key] = utils.KeyData{ + server.store[key] = internal.KeyData{ Value: value, ExpireAt: server.store[key].ExpireAt, } @@ -203,7 +203,7 @@ func (server *EchoVault) GetExpiry(ctx context.Context, key string) time.Time { // or the access time on lru eviction policy. // The key must be locked prior to calling this function. func (server *EchoVault) SetExpiry(ctx context.Context, key string, expireAt time.Time, touch bool) { - server.store[key] = utils.KeyData{ + server.store[key] = internal.KeyData{ Value: server.store[key].Value, ExpireAt: expireAt, } @@ -228,7 +228,7 @@ func (server *EchoVault) SetExpiry(ctx context.Context, key string, expireAt tim // The key must be locked prior ro calling this function. func (server *EchoVault) RemoveExpiry(key string) { // Reset expiry time - server.store[key] = utils.KeyData{ + server.store[key] = internal.KeyData{ Value: server.store[key].Value, ExpireAt: time.Time{}, } @@ -245,7 +245,7 @@ func (server *EchoVault) RemoveExpiry(key string) { // functions that require a deep copy of the state. // The copy only starts when there's no current copy in progress (represented by stateCopyInProgress atomic boolean) // and when there's no current state mutation in progress (represented by stateMutationInProgress atomic boolean) -func (server *EchoVault) GetState() map[string]utils.KeyData { +func (server *EchoVault) getState() map[string]interface{} { // Wait unit there's no state mutation or copy in progress before starting a new copy process. for { if !server.stateCopyInProgress.Load() && !server.stateMutationInProgress.Load() { @@ -253,7 +253,7 @@ func (server *EchoVault) GetState() map[string]utils.KeyData { break } } - data := make(map[string]utils.KeyData) + data := make(map[string]interface{}) for k, v := range server.store { data[k] = v } diff --git a/pkg/modules/generic/commands_test.go b/pkg/modules/generic/commands_test.go index 9c69dd9..ba93a35 100644 --- a/pkg/modules/generic/commands_test.go +++ b/pkg/modules/generic/commands_test.go @@ -29,6 +29,11 @@ import ( var mockServer *echovault.EchoVault +type KeyData struct { + Value interface{} + ExpireAt time.Time +} + func init() { mockServer = echovault.NewEchoVault( echovault.WithConfig(config.Config{ @@ -41,7 +46,7 @@ func init() { func Test_HandleSET(t *testing.T) { tests := []struct { command []string - presetValues map[string]utils.KeyData + presetValues map[string]KeyData expectedResponse interface{} expectedValue interface{} expectedExpiry time.Time @@ -81,7 +86,7 @@ func Test_HandleSET(t *testing.T) { }, { // 5. Throw error when value already exists with NX flag passed command: []string{"SET", "SetKey5", "value5", "NX"}, - presetValues: map[string]utils.KeyData{ + presetValues: map[string]KeyData{ "SetKey5": { Value: "preset-value5", ExpireAt: time.Time{}, @@ -94,7 +99,7 @@ func Test_HandleSET(t *testing.T) { }, { // 6. Set new key value when key exists with XX flag passed command: []string{"SET", "SetKey6", "value6", "XX"}, - presetValues: map[string]utils.KeyData{ + presetValues: map[string]KeyData{ "SetKey6": { Value: "preset-value6", ExpireAt: time.Time{}, @@ -273,7 +278,7 @@ func Test_HandleSET(t *testing.T) { }, { // 26. Get the previous value when GET flag is passed command: []string{"SET", "SetKey26", "value26", "GET", "EX", "1000"}, - presetValues: map[string]utils.KeyData{ + presetValues: map[string]KeyData{ "SetKey26": { Value: "previous-value", ExpireAt: time.Time{}, @@ -617,14 +622,14 @@ func Test_HandleMGET(t *testing.T) { func Test_HandleDEL(t *testing.T) { tests := []struct { command []string - presetValues map[string]utils.KeyData + presetValues map[string]KeyData expectedResponse int expectToExist map[string]bool expectedErr error }{ { command: []string{"DEL", "DelKey1", "DelKey2", "DelKey3", "DelKey4", "DelKey5"}, - presetValues: map[string]utils.KeyData{ + presetValues: map[string]KeyData{ "DelKey1": {Value: "value1", ExpireAt: time.Time{}}, "DelKey2": {Value: "value2", ExpireAt: time.Time{}}, "DelKey3": {Value: "value3", ExpireAt: time.Time{}}, @@ -701,18 +706,18 @@ func Test_HandleDEL(t *testing.T) { func Test_HandlePERSIST(t *testing.T) { tests := []struct { command []string - presetValues map[string]utils.KeyData + presetValues map[string]KeyData expectedResponse int - expectedValues map[string]utils.KeyData + expectedValues map[string]KeyData expectedError error }{ { // 1. Successfully persist a volatile key command: []string{"PERSIST", "PersistKey1"}, - presetValues: map[string]utils.KeyData{ + presetValues: map[string]KeyData{ "PersistKey1": {Value: "value1", ExpireAt: timeNow().Add(1000 * time.Second)}, }, expectedResponse: 1, - expectedValues: map[string]utils.KeyData{ + expectedValues: map[string]KeyData{ "PersistKey1": {Value: "value1", ExpireAt: time.Time{}}, }, expectedError: nil, @@ -726,11 +731,11 @@ func Test_HandlePERSIST(t *testing.T) { }, { // 3. Return 0 when trying to persist a non-volatile key command: []string{"PERSIST", "PersistKey3"}, - presetValues: map[string]utils.KeyData{ + presetValues: map[string]KeyData{ "PersistKey3": {Value: "value3", ExpireAt: time.Time{}}, }, expectedResponse: 0, - expectedValues: map[string]utils.KeyData{ + expectedValues: map[string]KeyData{ "PersistKey3": {Value: "value3", ExpireAt: time.Time{}}, }, expectedError: nil, @@ -815,13 +820,13 @@ func Test_HandlePERSIST(t *testing.T) { func Test_HandleEXPIRETIME(t *testing.T) { tests := []struct { command []string - presetValues map[string]utils.KeyData + presetValues map[string]KeyData expectedResponse int expectedError error }{ { // 1. Return expire time in seconds command: []string{"EXPIRETIME", "ExpireTimeKey1"}, - presetValues: map[string]utils.KeyData{ + presetValues: map[string]KeyData{ "ExpireTimeKey1": {Value: "value1", ExpireAt: timeNow().Add(100 * time.Second)}, }, expectedResponse: int(timeNow().Add(100 * time.Second).Unix()), @@ -829,7 +834,7 @@ func Test_HandleEXPIRETIME(t *testing.T) { }, { // 2. Return expire time in milliseconds command: []string{"PEXPIRETIME", "ExpireTimeKey2"}, - presetValues: map[string]utils.KeyData{ + presetValues: map[string]KeyData{ "ExpireTimeKey2": {Value: "value2", ExpireAt: timeNow().Add(4096 * time.Millisecond)}, }, expectedResponse: int(timeNow().Add(4096 * time.Millisecond).UnixMilli()), @@ -837,7 +842,7 @@ func Test_HandleEXPIRETIME(t *testing.T) { }, { // 3. If the key is non-volatile, return -1 command: []string{"PEXPIRETIME", "ExpireTimeKey3"}, - presetValues: map[string]utils.KeyData{ + presetValues: map[string]KeyData{ "ExpireTimeKey3": {Value: "value3", ExpireAt: time.Time{}}, }, expectedResponse: -1, @@ -908,13 +913,13 @@ func Test_HandleEXPIRETIME(t *testing.T) { func Test_HandleTTL(t *testing.T) { tests := []struct { command []string - presetValues map[string]utils.KeyData + presetValues map[string]KeyData expectedResponse int expectedError error }{ { // 1. Return TTL time in seconds command: []string{"TTL", "TTLKey1"}, - presetValues: map[string]utils.KeyData{ + presetValues: map[string]KeyData{ "TTLKey1": {Value: "value1", ExpireAt: timeNow().Add(100 * time.Second)}, }, expectedResponse: 100, @@ -922,7 +927,7 @@ func Test_HandleTTL(t *testing.T) { }, { // 2. Return TTL time in milliseconds command: []string{"PTTL", "TTLKey2"}, - presetValues: map[string]utils.KeyData{ + presetValues: map[string]KeyData{ "TTLKey2": {Value: "value2", ExpireAt: timeNow().Add(4096 * time.Millisecond)}, }, expectedResponse: 4096, @@ -930,7 +935,7 @@ func Test_HandleTTL(t *testing.T) { }, { // 3. If the key is non-volatile, return -1 command: []string{"TTL", "TTLKey3"}, - presetValues: map[string]utils.KeyData{ + presetValues: map[string]KeyData{ "TTLKey3": {Value: "value3", ExpireAt: time.Time{}}, }, expectedResponse: -1, @@ -1001,146 +1006,146 @@ func Test_HandleTTL(t *testing.T) { func Test_HandleEXPIRE(t *testing.T) { tests := []struct { command []string - presetValues map[string]utils.KeyData + presetValues map[string]KeyData expectedResponse int - expectedValues map[string]utils.KeyData + expectedValues map[string]KeyData expectedError error }{ { // 1. Set new expire by seconds command: []string{"EXPIRE", "ExpireKey1", "100"}, - presetValues: map[string]utils.KeyData{ + presetValues: map[string]KeyData{ "ExpireKey1": {Value: "value1", ExpireAt: time.Time{}}, }, expectedResponse: 1, - expectedValues: map[string]utils.KeyData{ + expectedValues: map[string]KeyData{ "ExpireKey1": {Value: "value1", ExpireAt: timeNow().Add(100 * time.Second)}, }, expectedError: nil, }, { // 2. Set new expire by milliseconds command: []string{"PEXPIRE", "ExpireKey2", "1000"}, - presetValues: map[string]utils.KeyData{ + presetValues: map[string]KeyData{ "ExpireKey2": {Value: "value2", ExpireAt: time.Time{}}, }, expectedResponse: 1, - expectedValues: map[string]utils.KeyData{ + expectedValues: map[string]KeyData{ "ExpireKey2": {Value: "value2", ExpireAt: timeNow().Add(1000 * time.Millisecond)}, }, expectedError: nil, }, { // 3. Set new expire only when key does not have an expiry time with NX flag command: []string{"EXPIRE", "ExpireKey3", "1000", "NX"}, - presetValues: map[string]utils.KeyData{ + presetValues: map[string]KeyData{ "ExpireKey3": {Value: "value3", ExpireAt: time.Time{}}, }, expectedResponse: 1, - expectedValues: map[string]utils.KeyData{ + expectedValues: map[string]KeyData{ "ExpireKey3": {Value: "value3", ExpireAt: timeNow().Add(1000 * time.Second)}, }, expectedError: nil, }, { // 4. Return 0, when NX flag is provided and key already has an expiry time command: []string{"EXPIRE", "ExpireKey4", "1000", "NX"}, - presetValues: map[string]utils.KeyData{ + presetValues: map[string]KeyData{ "ExpireKey4": {Value: "value4", ExpireAt: timeNow().Add(1000 * time.Second)}, }, expectedResponse: 0, - expectedValues: map[string]utils.KeyData{ + expectedValues: map[string]KeyData{ "ExpireKey4": {Value: "value4", ExpireAt: timeNow().Add(1000 * time.Second)}, }, expectedError: nil, }, { // 5. Set new expire time from now key only when the key already has an expiry time with XX flag command: []string{"EXPIRE", "ExpireKey5", "1000", "XX"}, - presetValues: map[string]utils.KeyData{ + presetValues: map[string]KeyData{ "ExpireKey5": {Value: "value5", ExpireAt: timeNow().Add(30 * time.Second)}, }, expectedResponse: 1, - expectedValues: map[string]utils.KeyData{ + expectedValues: map[string]KeyData{ "ExpireKey5": {Value: "value5", ExpireAt: timeNow().Add(1000 * time.Second)}, }, expectedError: nil, }, { // 6. Return 0 when key does not have an expiry and the XX flag is provided command: []string{"EXPIRE", "ExpireKey6", "1000", "XX"}, - presetValues: map[string]utils.KeyData{ + presetValues: map[string]KeyData{ "ExpireKey6": {Value: "value6", ExpireAt: time.Time{}}, }, expectedResponse: 0, - expectedValues: map[string]utils.KeyData{ + expectedValues: map[string]KeyData{ "ExpireKey6": {Value: "value6", ExpireAt: time.Time{}}, }, expectedError: nil, }, { // 7. Set expiry time when the provided time is after the current expiry time when GT flag is provided command: []string{"EXPIRE", "ExpireKey7", "1000", "GT"}, - presetValues: map[string]utils.KeyData{ + presetValues: map[string]KeyData{ "ExpireKey7": {Value: "value7", ExpireAt: timeNow().Add(30 * time.Second)}, }, expectedResponse: 1, - expectedValues: map[string]utils.KeyData{ + expectedValues: map[string]KeyData{ "ExpireKey7": {Value: "value7", ExpireAt: timeNow().Add(1000 * time.Second)}, }, expectedError: nil, }, { // 8. Return 0 when GT flag is passed and current expiry time is greater than provided time command: []string{"EXPIRE", "ExpireKey8", "1000", "GT"}, - presetValues: map[string]utils.KeyData{ + presetValues: map[string]KeyData{ "ExpireKey8": {Value: "value8", ExpireAt: timeNow().Add(3000 * time.Second)}, }, expectedResponse: 0, - expectedValues: map[string]utils.KeyData{ + expectedValues: map[string]KeyData{ "ExpireKey8": {Value: "value8", ExpireAt: timeNow().Add(3000 * time.Second)}, }, expectedError: nil, }, { // 9. Return 0 when GT flag is passed and key does not have an expiry time command: []string{"EXPIRE", "ExpireKey9", "1000", "GT"}, - presetValues: map[string]utils.KeyData{ + presetValues: map[string]KeyData{ "ExpireKey9": {Value: "value9", ExpireAt: time.Time{}}, }, expectedResponse: 0, - expectedValues: map[string]utils.KeyData{ + expectedValues: map[string]KeyData{ "ExpireKey9": {Value: "value9", ExpireAt: time.Time{}}, }, expectedError: nil, }, { // 10. Set expiry time when the provided time is before the current expiry time when LT flag is provided command: []string{"EXPIRE", "ExpireKey10", "1000", "LT"}, - presetValues: map[string]utils.KeyData{ + presetValues: map[string]KeyData{ "ExpireKey10": {Value: "value10", ExpireAt: timeNow().Add(3000 * time.Second)}, }, expectedResponse: 1, - expectedValues: map[string]utils.KeyData{ + expectedValues: map[string]KeyData{ "ExpireKey10": {Value: "value10", ExpireAt: timeNow().Add(1000 * time.Second)}, }, expectedError: nil, }, { // 11. Return 0 when LT flag is passed and current expiry time is less than provided time command: []string{"EXPIRE", "ExpireKey11", "5000", "LT"}, - presetValues: map[string]utils.KeyData{ + presetValues: map[string]KeyData{ "ExpireKey11": {Value: "value11", ExpireAt: timeNow().Add(3000 * time.Second)}, }, expectedResponse: 0, - expectedValues: map[string]utils.KeyData{ + expectedValues: map[string]KeyData{ "ExpireKey11": {Value: "value11", ExpireAt: timeNow().Add(3000 * time.Second)}, }, expectedError: nil, }, { // 12. Return 0 when LT flag is passed and key does not have an expiry time command: []string{"EXPIRE", "ExpireKey12", "1000", "LT"}, - presetValues: map[string]utils.KeyData{ + presetValues: map[string]KeyData{ "ExpireKey12": {Value: "value12", ExpireAt: time.Time{}}, }, expectedResponse: 1, - expectedValues: map[string]utils.KeyData{ + expectedValues: map[string]KeyData{ "ExpireKey12": {Value: "value12", ExpireAt: timeNow().Add(1000 * time.Second)}, }, expectedError: nil, }, { // 13. Return error when unknown flag is passed command: []string{"EXPIRE", "ExpireKey13", "1000", "UNKNOWN"}, - presetValues: map[string]utils.KeyData{ + presetValues: map[string]KeyData{ "ExpireKey13": {Value: "value13", ExpireAt: time.Time{}}, }, expectedResponse: 0, @@ -1234,51 +1239,51 @@ func Test_HandleEXPIRE(t *testing.T) { func Test_HandleEXPIREAT(t *testing.T) { tests := []struct { command []string - presetValues map[string]utils.KeyData + presetValues map[string]KeyData expectedResponse int - expectedValues map[string]utils.KeyData + expectedValues map[string]KeyData expectedError error }{ { // 1. Set new expire by unix seconds command: []string{"EXPIREAT", "ExpireAtKey1", fmt.Sprintf("%d", timeNow().Add(1000*time.Second).Unix())}, - presetValues: map[string]utils.KeyData{ + presetValues: map[string]KeyData{ "ExpireAtKey1": {Value: "value1", ExpireAt: time.Time{}}, }, expectedResponse: 1, - expectedValues: map[string]utils.KeyData{ + expectedValues: map[string]KeyData{ "ExpireAtKey1": {Value: "value1", ExpireAt: time.Unix(timeNow().Add(1000*time.Second).Unix(), 0)}, }, expectedError: nil, }, { // 2. Set new expire by milliseconds command: []string{"PEXPIREAT", "ExpireAtKey2", fmt.Sprintf("%d", timeNow().Add(1000*time.Second).UnixMilli())}, - presetValues: map[string]utils.KeyData{ + presetValues: map[string]KeyData{ "ExpireAtKey2": {Value: "value2", ExpireAt: time.Time{}}, }, expectedResponse: 1, - expectedValues: map[string]utils.KeyData{ + expectedValues: map[string]KeyData{ "ExpireAtKey2": {Value: "value2", ExpireAt: time.UnixMilli(timeNow().Add(1000 * time.Second).UnixMilli())}, }, expectedError: nil, }, { // 3. Set new expire only when key does not have an expiry time with NX flag command: []string{"EXPIREAT", "ExpireAtKey3", fmt.Sprintf("%d", timeNow().Add(1000*time.Second).Unix()), "NX"}, - presetValues: map[string]utils.KeyData{ + presetValues: map[string]KeyData{ "ExpireAtKey3": {Value: "value3", ExpireAt: time.Time{}}, }, expectedResponse: 1, - expectedValues: map[string]utils.KeyData{ + expectedValues: map[string]KeyData{ "ExpireAtKey3": {Value: "value3", ExpireAt: time.Unix(timeNow().Add(1000*time.Second).Unix(), 0)}, }, expectedError: nil, }, { // 4. Return 0, when NX flag is provided and key already has an expiry time command: []string{"EXPIREAT", "ExpireAtKey4", fmt.Sprintf("%d", timeNow().Add(1000*time.Second).Unix()), "NX"}, - presetValues: map[string]utils.KeyData{ + presetValues: map[string]KeyData{ "ExpireAtKey4": {Value: "value4", ExpireAt: timeNow().Add(1000 * time.Second)}, }, expectedResponse: 0, - expectedValues: map[string]utils.KeyData{ + expectedValues: map[string]KeyData{ "ExpireAtKey4": {Value: "value4", ExpireAt: timeNow().Add(1000 * time.Second)}, }, expectedError: nil, @@ -1288,11 +1293,11 @@ func Test_HandleEXPIREAT(t *testing.T) { "EXPIREAT", "ExpireAtKey5", fmt.Sprintf("%d", timeNow().Add(1000*time.Second).Unix()), "XX", }, - presetValues: map[string]utils.KeyData{ + presetValues: map[string]KeyData{ "ExpireAtKey5": {Value: "value5", ExpireAt: timeNow().Add(30 * time.Second)}, }, expectedResponse: 1, - expectedValues: map[string]utils.KeyData{ + expectedValues: map[string]KeyData{ "ExpireAtKey5": {Value: "value5", ExpireAt: time.Unix(timeNow().Add(1000*time.Second).Unix(), 0)}, }, expectedError: nil, @@ -1302,11 +1307,11 @@ func Test_HandleEXPIREAT(t *testing.T) { "EXPIREAT", "ExpireAtKey6", fmt.Sprintf("%d", timeNow().Add(1000*time.Second).Unix()), "XX", }, - presetValues: map[string]utils.KeyData{ + presetValues: map[string]KeyData{ "ExpireAtKey6": {Value: "value6", ExpireAt: time.Time{}}, }, expectedResponse: 0, - expectedValues: map[string]utils.KeyData{ + expectedValues: map[string]KeyData{ "ExpireAtKey6": {Value: "value6", ExpireAt: time.Time{}}, }, expectedError: nil, @@ -1316,11 +1321,11 @@ func Test_HandleEXPIREAT(t *testing.T) { "EXPIREAT", "ExpireAtKey7", fmt.Sprintf("%d", timeNow().Add(1000*time.Second).Unix()), "GT", }, - presetValues: map[string]utils.KeyData{ + presetValues: map[string]KeyData{ "ExpireAtKey7": {Value: "value7", ExpireAt: timeNow().Add(30 * time.Second)}, }, expectedResponse: 1, - expectedValues: map[string]utils.KeyData{ + expectedValues: map[string]KeyData{ "ExpireAtKey7": {Value: "value7", ExpireAt: time.Unix(timeNow().Add(1000*time.Second).Unix(), 0)}, }, expectedError: nil, @@ -1330,11 +1335,11 @@ func Test_HandleEXPIREAT(t *testing.T) { "EXPIREAT", "ExpireAtKey8", fmt.Sprintf("%d", timeNow().Add(1000*time.Second).Unix()), "GT", }, - presetValues: map[string]utils.KeyData{ + presetValues: map[string]KeyData{ "ExpireAtKey8": {Value: "value8", ExpireAt: timeNow().Add(3000 * time.Second)}, }, expectedResponse: 0, - expectedValues: map[string]utils.KeyData{ + expectedValues: map[string]KeyData{ "ExpireAtKey8": {Value: "value8", ExpireAt: timeNow().Add(3000 * time.Second)}, }, expectedError: nil, @@ -1344,11 +1349,11 @@ func Test_HandleEXPIREAT(t *testing.T) { "EXPIREAT", "ExpireAtKey9", fmt.Sprintf("%d", timeNow().Add(1000*time.Second).Unix()), "GT", }, - presetValues: map[string]utils.KeyData{ + presetValues: map[string]KeyData{ "ExpireAtKey9": {Value: "value9", ExpireAt: time.Time{}}, }, expectedResponse: 0, - expectedValues: map[string]utils.KeyData{ + expectedValues: map[string]KeyData{ "ExpireAtKey9": {Value: "value9", ExpireAt: time.Time{}}, }, expectedError: nil, @@ -1358,11 +1363,11 @@ func Test_HandleEXPIREAT(t *testing.T) { "EXPIREAT", "ExpireAtKey10", fmt.Sprintf("%d", timeNow().Add(1000*time.Second).Unix()), "LT", }, - presetValues: map[string]utils.KeyData{ + presetValues: map[string]KeyData{ "ExpireAtKey10": {Value: "value10", ExpireAt: timeNow().Add(3000 * time.Second)}, }, expectedResponse: 1, - expectedValues: map[string]utils.KeyData{ + expectedValues: map[string]KeyData{ "ExpireAtKey10": {Value: "value10", ExpireAt: time.Unix(timeNow().Add(1000*time.Second).Unix(), 0)}, }, expectedError: nil, @@ -1372,11 +1377,11 @@ func Test_HandleEXPIREAT(t *testing.T) { "EXPIREAT", "ExpireAtKey11", fmt.Sprintf("%d", timeNow().Add(3000*time.Second).Unix()), "LT", }, - presetValues: map[string]utils.KeyData{ + presetValues: map[string]KeyData{ "ExpireAtKey11": {Value: "value11", ExpireAt: timeNow().Add(1000 * time.Second)}, }, expectedResponse: 0, - expectedValues: map[string]utils.KeyData{ + expectedValues: map[string]KeyData{ "ExpireAtKey11": {Value: "value11", ExpireAt: timeNow().Add(1000 * time.Second)}, }, expectedError: nil, @@ -1386,18 +1391,18 @@ func Test_HandleEXPIREAT(t *testing.T) { "EXPIREAT", "ExpireAtKey12", fmt.Sprintf("%d", timeNow().Add(1000*time.Second).Unix()), "LT", }, - presetValues: map[string]utils.KeyData{ + presetValues: map[string]KeyData{ "ExpireAtKey12": {Value: "value12", ExpireAt: time.Time{}}, }, expectedResponse: 1, - expectedValues: map[string]utils.KeyData{ + expectedValues: map[string]KeyData{ "ExpireAtKey12": {Value: "value12", ExpireAt: time.Unix(timeNow().Add(1000*time.Second).Unix(), 0)}, }, expectedError: nil, }, { // 13. Return error when unknown flag is passed command: []string{"EXPIREAT", "ExpireAtKey13", "1000", "UNKNOWN"}, - presetValues: map[string]utils.KeyData{ + presetValues: map[string]KeyData{ "ExpireAtKey13": {Value: "value13", ExpireAt: time.Time{}}, }, expectedResponse: 0, diff --git a/pkg/utils/types.go b/pkg/utils/types.go index b09f904..0d0a4a7 100644 --- a/pkg/utils/types.go +++ b/pkg/utils/types.go @@ -20,12 +20,6 @@ import ( "time" ) -// KeyData holds the structure of the in-memory data stored at a string key. -type KeyData struct { - Value interface{} - ExpireAt time.Time -} - type EchoVault interface { KeyLock(ctx context.Context, key string) (bool, error) KeyUnlock(ctx context.Context, key string) @@ -39,7 +33,6 @@ type EchoVault interface { SetExpiry(ctx context.Context, key string, expire time.Time, touch bool) RemoveExpiry(key string) DeleteKey(ctx context.Context, key string) error - GetState() map[string]KeyData GetAllCommands() []Command GetACL() interface{} GetPubSub() interface{} @@ -51,22 +44,6 @@ type EchoVault interface { RewriteAOF() error } -type ContextServerID string -type ContextConnID string - -type ApplyRequest struct { - Type string `json:"Type"` // command | delete-key - ServerID string `json:"ServerID"` - ConnectionID string `json:"ConnectionID"` - CMD []string `json:"CMD"` - Key string `json:"Key"` -} - -type ApplyResponse struct { - Error error - Response []byte -} - type KeyExtractionFunc func(cmd []string) ([]string, error) type HandlerFunc func(ctx context.Context, cmd []string, echovault EchoVault, conn *net.Conn) ([]byte, error) @@ -95,8 +72,3 @@ type ACL interface { } type PubSub interface{} - -type SnapshotObject struct { - State map[string]KeyData - LatestSnapshotMilliseconds int64 -}