From 6cb38ee51df2fff25cf8718d4b60812ade6f26a2 Mon Sep 17 00:00:00 2001 From: Kelvin Clement Mwinuka Date: Wed, 14 Feb 2024 21:38:57 +0800 Subject: [PATCH] Removed Plugin struct and it's receiver functions in all the modules --- src/modules/acl/commands.go | 19 ------------------- src/modules/admin/commands.go | 18 ------------------ src/modules/etc/commands.go | 18 ------------------ src/modules/get/commands.go | 19 ------------------- src/modules/hash/commands.go | 18 ------------------ src/modules/list/commands.go | 19 ------------------- src/modules/ping/commands.go | 18 ------------------ src/modules/pubsub/commands.go | 19 ------------------- src/modules/set/commands.go | 19 ------------------- src/modules/sorted_set/commands.go | 19 ------------------- src/modules/string/commands.go | 18 ------------------ 11 files changed, 204 deletions(-) diff --git a/src/modules/acl/commands.go b/src/modules/acl/commands.go index be09edfe..6db9ccaa 100644 --- a/src/modules/acl/commands.go +++ b/src/modules/acl/commands.go @@ -14,25 +14,6 @@ import ( "strings" ) -type Plugin struct { - name string - commands []utils.Command - description string - acl *ACL -} - -func (p Plugin) Name() string { - return p.name -} - -func (p Plugin) Commands() []utils.Command { - return p.commands -} - -func (p Plugin) Description() string { - return p.description -} - func handleAuth(ctx context.Context, cmd []string, server utils.Server, conn *net.Conn) ([]byte, error) { if len(cmd) < 2 || len(cmd) > 3 { return nil, errors.New(utils.WRONG_ARGS_RESPONSE) diff --git a/src/modules/admin/commands.go b/src/modules/admin/commands.go index 539b7648..46da2884 100644 --- a/src/modules/admin/commands.go +++ b/src/modules/admin/commands.go @@ -8,24 +8,6 @@ import ( "net" ) -type Plugin struct { - name string - commands []utils.Command - description string -} - -func (p Plugin) Name() string { - return p.name -} - -func (p Plugin) Commands() []utils.Command { - return p.commands -} - -func (p Plugin) Description() string { - return p.description -} - func Commands() []utils.Command { return []utils.Command{ { diff --git a/src/modules/etc/commands.go b/src/modules/etc/commands.go index 663d9cc1..2854bcf6 100644 --- a/src/modules/etc/commands.go +++ b/src/modules/etc/commands.go @@ -14,24 +14,6 @@ type KeyObject struct { locked bool } -type Plugin struct { - name string - description string - commands []utils.Command -} - -func (p Plugin) Name() string { - return p.name -} - -func (p Plugin) Commands() []utils.Command { - return p.commands -} - -func (p Plugin) Description() string { - return p.description -} - func handleSet(ctx context.Context, cmd []string, server utils.Server, conn *net.Conn) ([]byte, error) { ctx, cancel := context.WithCancel(ctx) defer cancel() diff --git a/src/modules/get/commands.go b/src/modules/get/commands.go index 8bb0656d..a73c6c8d 100644 --- a/src/modules/get/commands.go +++ b/src/modules/get/commands.go @@ -8,25 +8,6 @@ import ( "net" ) -type Plugin struct { - name string - commands []utils.Command - categories []string - description string -} - -func (p Plugin) Name() string { - return p.name -} - -func (p Plugin) Commands() []utils.Command { - return p.commands -} - -func (p Plugin) Description() string { - return p.description -} - func handleGet(ctx context.Context, cmd []string, server utils.Server, conn *net.Conn) ([]byte, error) { if len(cmd) != 2 { return nil, errors.New(utils.WRONG_ARGS_RESPONSE) diff --git a/src/modules/hash/commands.go b/src/modules/hash/commands.go index c8142d33..6a4b131c 100644 --- a/src/modules/hash/commands.go +++ b/src/modules/hash/commands.go @@ -12,24 +12,6 @@ import ( "strings" ) -type Plugin struct { - name string - commands []utils.Command - description string -} - -func (p Plugin) Name() string { - return p.name -} - -func (p Plugin) Commands() []utils.Command { - return p.commands -} - -func (p Plugin) Description() string { - return p.description -} - func handleHSET(ctx context.Context, cmd []string, server utils.Server, conn *net.Conn) ([]byte, error) { if len(cmd) < 4 { return nil, errors.New(utils.WRONG_ARGS_RESPONSE) diff --git a/src/modules/list/commands.go b/src/modules/list/commands.go index d5a7370f..0a533cc4 100644 --- a/src/modules/list/commands.go +++ b/src/modules/list/commands.go @@ -11,25 +11,6 @@ import ( "strings" ) -type Plugin struct { - name string - commands []utils.Command - categories []string - description string -} - -func (p Plugin) Name() string { - return p.name -} - -func (p Plugin) Commands() []utils.Command { - return p.commands -} - -func (p Plugin) Description() string { - return p.description -} - func handleLLen(ctx context.Context, cmd []string, server utils.Server, conn *net.Conn) ([]byte, error) { if len(cmd) != 2 { return nil, errors.New(utils.WRONG_ARGS_RESPONSE) diff --git a/src/modules/ping/commands.go b/src/modules/ping/commands.go index e59e6a69..4779d533 100644 --- a/src/modules/ping/commands.go +++ b/src/modules/ping/commands.go @@ -8,24 +8,6 @@ import ( "net" ) -type Plugin struct { - name string - commands []utils.Command - description string -} - -func (p Plugin) Name() string { - return p.name -} - -func (p Plugin) Commands() []utils.Command { - return p.commands -} - -func (p Plugin) Description() string { - return p.description -} - func handlePing(ctx context.Context, cmd []string, server utils.Server, conn *net.Conn) ([]byte, error) { switch len(cmd) { default: diff --git a/src/modules/pubsub/commands.go b/src/modules/pubsub/commands.go index 65fb9b74..1b550dc5 100644 --- a/src/modules/pubsub/commands.go +++ b/src/modules/pubsub/commands.go @@ -7,25 +7,6 @@ import ( "net" ) -type Plugin struct { - name string - commands []utils.Command - description string - pubSub *PubSub -} - -func (p Plugin) Name() string { - return p.name -} - -func (p Plugin) Commands() []utils.Command { - return p.commands -} - -func (p Plugin) Description() string { - return p.description -} - func handleSubscribe(ctx context.Context, cmd []string, server utils.Server, conn *net.Conn) ([]byte, error) { pubsub, ok := server.GetPubSub().(*PubSub) if !ok { diff --git a/src/modules/set/commands.go b/src/modules/set/commands.go index 81fa2934..6b470e65 100644 --- a/src/modules/set/commands.go +++ b/src/modules/set/commands.go @@ -10,25 +10,6 @@ import ( "strings" ) -type Plugin struct { - name string - commands []utils.Command - categories []string - description string -} - -func (p Plugin) Name() string { - return p.name -} - -func (p Plugin) Commands() []utils.Command { - return p.commands -} - -func (p Plugin) Description() string { - return p.description -} - func handleSADD(ctx context.Context, cmd []string, server utils.Server, conn *net.Conn) ([]byte, error) { if len(cmd) < 3 { return nil, errors.New(utils.WRONG_ARGS_RESPONSE) diff --git a/src/modules/sorted_set/commands.go b/src/modules/sorted_set/commands.go index 1baa3907..980bebc8 100644 --- a/src/modules/sorted_set/commands.go +++ b/src/modules/sorted_set/commands.go @@ -13,25 +13,6 @@ import ( "strings" ) -type Plugin struct { - name string - commands []utils.Command - categories []string - description string -} - -func (p Plugin) Name() string { - return p.name -} - -func (p Plugin) Commands() []utils.Command { - return p.commands -} - -func (p Plugin) Description() string { - return p.description -} - func handleZADD(ctx context.Context, cmd []string, server utils.Server, conn *net.Conn) ([]byte, error) { if len(cmd) < 4 { return nil, errors.New(utils.WRONG_ARGS_RESPONSE) diff --git a/src/modules/string/commands.go b/src/modules/string/commands.go index 340e8066..a495f66a 100644 --- a/src/modules/string/commands.go +++ b/src/modules/string/commands.go @@ -8,24 +8,6 @@ import ( "net" ) -type Plugin struct { - name string - commands []utils.Command - description string -} - -func (p Plugin) Name() string { - return p.name -} - -func (p Plugin) Commands() []utils.Command { - return p.commands -} - -func (p Plugin) Description() string { - return p.description -} - func handleSetRange(ctx context.Context, cmd []string, server utils.Server, conn *net.Conn) ([]byte, error) { if len(cmd[1:]) != 3 { return nil, errors.New(utils.WRONG_ARGS_RESPONSE)