Skip to content

Commit

Permalink
Merge pull request #32 from EchoVault/refactor/handler-params
Browse files Browse the repository at this point in the history
Refactor HandlerFunc to accept a params struct containing all values & functions instead of an instance of EchoVault interface
  • Loading branch information
kelvinmwinuka authored Apr 25, 2024
2 parents 2b01c73 + 6ad3b7b commit 8be29f7
Show file tree
Hide file tree
Showing 59 changed files with 3,847 additions and 6,093 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ build:
run:
make build && docker-compose up --build

test:
test-unit:
go clean -testcache && go test ./... -coverprofile coverage/coverage.out

test-race:
Expand Down
2 changes: 0 additions & 2 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"context"
"github.com/echovault/echovault/internal"
"github.com/echovault/echovault/internal/config"
"github.com/echovault/echovault/pkg/commands"
"github.com/echovault/echovault/pkg/echovault"
"log"
"os"
Expand Down Expand Up @@ -49,7 +48,6 @@ func main() {
server, err := echovault.NewEchoVault(
echovault.WithContext(ctx),
echovault.WithConfig(conf),
echovault.WithCommands(commands.All()),
)

if err != nil {
Expand Down
3,138 changes: 0 additions & 3,138 deletions coverage/coverage.out

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions internal/acl/acl.go → internal/modules/acl/acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/echovault/echovault/internal"
"github.com/echovault/echovault/internal/config"
"github.com/echovault/echovault/pkg/constants"
"github.com/echovault/echovault/pkg/types"
"github.com/gobwas/glob"
"gopkg.in/yaml.v3"
"log"
Expand Down Expand Up @@ -286,7 +286,7 @@ func (acl *ACL) AuthenticateConnection(_ context.Context, conn *net.Conn, cmd []
return errors.New("could not authenticate user")
}

func (acl *ACL) AuthorizeConnection(conn *net.Conn, cmd []string, command types.Command, subCommand types.SubCommand) error {
func (acl *ACL) AuthorizeConnection(conn *net.Conn, cmd []string, command internal.Command, subCommand internal.SubCommand) error {
acl.RLockUsers()
defer acl.RUnlockUsers()

Expand All @@ -303,7 +303,7 @@ func (acl *ACL) AuthorizeConnection(conn *net.Conn, cmd []string, command types.
readKeys := keys.ReadKeys
writeKeys := keys.WriteKeys

if !reflect.DeepEqual(subCommand, types.SubCommand{}) {
if !reflect.DeepEqual(subCommand, internal.SubCommand{}) {
comm = fmt.Sprintf("%s|%s", comm, subCommand.Command)
categories = append(categories, subCommand.Categories...)
keys, err = subCommand.KeyExtractionFunc(cmd)
Expand Down
Loading

0 comments on commit 8be29f7

Please sign in to comment.