Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor HandlerFunc to accept a params struct containing all values & functions instead of an instance of EchoVault interface #32

Merged
merged 6 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading