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

Renaming all appropriate variables from Redis to DiceDB #940

Merged
merged 52 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
033d258
removed unwanted goroutine
Sep 27, 2024
c6eb707
more refactor of eval
AshwinKul28 Sep 28, 2024
9e498b6
Update cmd_meta.go
AshwinKul28 Sep 28, 2024
ea94736
Merge branch 'master' into refactor
AshwinKul28 Sep 28, 2024
df58e9a
added lint check
AshwinKul28 Sep 28, 2024
030c600
Merge branch 'refactor' of https://github.com/AshwinKul28/dice into r…
AshwinKul28 Sep 28, 2024
65d05c0
pkg updates
AshwinKul28 Sep 28, 2024
037572c
Update migrated_errors.go
AshwinKul28 Sep 28, 2024
2dfd647
Update results.go
AshwinKul28 Sep 28, 2024
def50f4
Update results.go
AshwinKul28 Sep 28, 2024
32c6682
more fixes
Sep 29, 2024
cd5a84a
Update server.go
Sep 29, 2024
c76ccca
more fixes :(
AshwinKul28 Sep 29, 2024
52bbc97
fixed get
AshwinKul28 Sep 29, 2024
9e38ea6
Merge branch 'DiceDB:master' into master
AshwinKul28 Sep 29, 2024
9d15f1f
Merge branch 'master' into refactor
AshwinKul28 Sep 29, 2024
5474698
fix hoja bhai
AshwinKul28 Sep 29, 2024
8a443a3
Update store_eval.go
AshwinKul28 Sep 29, 2024
9451016
feat: fix http for eval refactor
pratikpandey21 Sep 29, 2024
e4093d5
Merge branch 'refactor' of https://github.com/AshwinKul28/dice into r…
AshwinKul28 Sep 29, 2024
afb0d25
added enum
AshwinKul28 Sep 29, 2024
a4bf6ca
Merge branch 'DiceDB:master' into master
AshwinKul28 Sep 30, 2024
b216f3f
Merge branch 'master' into refactor
Sep 30, 2024
ce2a96a
more refactor for http and websocket
AshwinKul28 Sep 30, 2024
c2c54f7
Update bit_ops_string_int_test.go
AshwinKul28 Sep 30, 2024
213acc7
test cases passed
AshwinKul28 Sep 30, 2024
9577e1c
Fixing http QWATCH integration tests
lucifercr07 Sep 30, 2024
5697fbb
Fixing Websocket tests
lucifercr07 Sep 30, 2024
bd084c2
lint fixes
AshwinKul28 Sep 30, 2024
f401596
Update setup.go
AshwinKul28 Sep 30, 2024
712bbde
fixed unit tests
AshwinKul28 Sep 30, 2024
8ebf0d8
Merge branch 'DiceDB:master' into master
AshwinKul28 Sep 30, 2024
e9e9b93
Merge branch 'master' into refactor
AshwinKul28 Sep 30, 2024
c1a64d8
unit tests
AshwinKul28 Sep 30, 2024
17638dd
fix unit tests
AshwinKul28 Sep 30, 2024
70481f3
Update netconn.go
AshwinKul28 Sep 30, 2024
95f1d6c
Update max_conn_test.go
AshwinKul28 Sep 30, 2024
36009ce
more refactor - clean
AshwinKul28 Oct 1, 2024
abd303b
Update errors.go
AshwinKul28 Oct 1, 2024
f274a00
Update results.go
AshwinKul28 Oct 1, 2024
0921cca
Add integration tests for RESP multi-threaded server
soumya-codes Oct 2, 2024
ee4ec24
Merge branch 'DiceDB:master' into master
AshwinKul28 Oct 2, 2024
8ba1081
Merge branch 'master' into refactor
AshwinKul28 Oct 2, 2024
67b2b92
Update server.go
AshwinKul28 Oct 2, 2024
8ecd966
Update epoll_linux.go
AshwinKul28 Oct 2, 2024
fc986b5
Update server.go
AshwinKul28 Oct 2, 2024
0c425ac
more refactoring!!!!
AshwinKul28 Oct 2, 2024
61d7810
migrated code from redis to dicedb
AshwinKul28 Oct 3, 2024
d192f5e
Merge branch 'DiceDB:master' into master
AshwinKul28 Oct 3, 2024
cee3ff3
Merge branch 'master' into rename
AshwinKul28 Oct 3, 2024
1ee689e
changes to naming
AshwinKul28 Oct 3, 2024
49bb194
fix lint
AshwinKul28 Oct 3, 2024
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 internal/clientio/requestparser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@ import (
)

type Parser interface {
Parse(data []byte) ([]*cmd.RedisCmd, error)
Parse(data []byte) ([]*cmd.DiceDBCmd, error)
}
10 changes: 5 additions & 5 deletions internal/clientio/requestparser/resp/respparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ func (p *Parser) SetData(data []byte) {
p.pos = 0
}

// Parse parses the entire input and returns a slice of RedisCmd
func (p *Parser) Parse(data []byte) ([]*cmd.RedisCmd, error) {
// Parse parses the entire input and returns a slice of DiceDBCmd
func (p *Parser) Parse(data []byte) ([]*cmd.DiceDBCmd, error) {
p.SetData(data)
var commands []*cmd.RedisCmd
var commands []*cmd.DiceDBCmd
for p.pos < len(p.data) {
c, err := p.parseCommand()
if err != nil {
Expand All @@ -68,7 +68,7 @@ func (p *Parser) Parse(data []byte) ([]*cmd.RedisCmd, error) {
return commands, nil
}

func (p *Parser) parseCommand() (*cmd.RedisCmd, error) {
func (p *Parser) parseCommand() (*cmd.DiceDBCmd, error) {
if p.pos >= len(p.data) {
return nil, ErrUnexpectedEOF
}
Expand All @@ -84,7 +84,7 @@ func (p *Parser) parseCommand() (*cmd.RedisCmd, error) {
return nil, fmt.Errorf("error while parsing command, empty command")
}

return &cmd.RedisCmd{
return &cmd.DiceDBCmd{
Cmd: strings.ToUpper(elements[0]),
Args: elements[1:],
}, nil
Expand Down
25 changes: 13 additions & 12 deletions internal/clientio/requestparser/resp/respparser_test.go
Original file line number Diff line number Diff line change
@@ -1,47 +1,48 @@
package respparser

import (
"github.com/dicedb/dice/mocks"
"log/slog"
"reflect"
"testing"

"github.com/dicedb/dice/mocks"

"github.com/dicedb/dice/internal/cmd"
)

func TestParser_Parse(t *testing.T) {
tests := []struct {
name string
input string
want []*cmd.RedisCmd
want []*cmd.DiceDBCmd
wantErr bool
}{
{
name: "Simple SET command",
input: "*3\r\n$3\r\nSET\r\n$3\r\nkey\r\n$5\r\nvalue\r\n",
want: []*cmd.RedisCmd{
want: []*cmd.DiceDBCmd{
{Cmd: "SET", Args: []string{"key", "value"}},
},
},
{
name: "GET command",
input: "*2\r\n$3\r\nGET\r\n$3\r\nkey\r\n",
want: []*cmd.RedisCmd{
want: []*cmd.DiceDBCmd{
{Cmd: "GET", Args: []string{"key"}},
},
},
{
name: "Multiple commands",
input: "*2\r\n$4\r\nPING\r\n$4\r\nPONG\r\n*3\r\n$3\r\nSET\r\n$3\r\nkey\r\n$5\r\nvalue\r\n",
want: []*cmd.RedisCmd{
want: []*cmd.DiceDBCmd{
{Cmd: "PING", Args: []string{"PONG"}},
{Cmd: "SET", Args: []string{"key", "value"}},
},
},
{
name: "Command with integer argument",
input: "*3\r\n$6\r\nEXPIRE\r\n$3\r\nkey\r\n:60\r\n",
want: []*cmd.RedisCmd{
want: []*cmd.DiceDBCmd{
{Cmd: "EXPIRE", Args: []string{"key", "60"}},
},
},
Expand All @@ -58,28 +59,28 @@ func TestParser_Parse(t *testing.T) {
{
name: "Command with null bulk string argument",
input: "*3\r\n$3\r\nSET\r\n$3\r\nkey\r\n$-1\r\n",
want: []*cmd.RedisCmd{
want: []*cmd.DiceDBCmd{
{Cmd: "SET", Args: []string{"key", "(nil)"}},
},
},
{
name: "Command with Simple String argument",
input: "*3\r\n$3\r\nSET\r\n$3\r\nkey\r\n+OK\r\n",
want: []*cmd.RedisCmd{
want: []*cmd.DiceDBCmd{
{Cmd: "SET", Args: []string{"key", "OK"}},
},
},
{
name: "Command with Error argument",
input: "*3\r\n$3\r\nSET\r\n$3\r\nkey\r\n-ERR Invalid argument\r\n",
want: []*cmd.RedisCmd{
want: []*cmd.DiceDBCmd{
{Cmd: "SET", Args: []string{"key", "ERR Invalid argument"}},
},
},
{
name: "Command with mixed argument types",
input: "*5\r\n$4\r\nMSET\r\n$3\r\nkey\r\n$5\r\nvalue\r\n:1000\r\n+OK\r\n",
want: []*cmd.RedisCmd{
want: []*cmd.DiceDBCmd{
{Cmd: "MSET", Args: []string{"key", "value", "1000", "OK"}},
},
},
Expand All @@ -96,7 +97,7 @@ func TestParser_Parse(t *testing.T) {
{
name: "Command with empty bulk string",
input: "*3\r\n$3\r\nSET\r\n$3\r\nkey\r\n$0\r\n\r\n",
want: []*cmd.RedisCmd{
want: []*cmd.DiceDBCmd{
{Cmd: "SET", Args: []string{"key", ""}},
},
},
Expand All @@ -113,7 +114,7 @@ func TestParser_Parse(t *testing.T) {
{
name: "Large bulk string",
input: "*2\r\n$4\r\nECHO\r\n$1000\r\n" + string(make([]byte, 1000)) + "\r\n",
want: []*cmd.RedisCmd{
want: []*cmd.DiceDBCmd{
{Cmd: "ECHO", Args: []string{string(make([]byte, 1000))}},
},
},
Expand Down
4 changes: 2 additions & 2 deletions internal/cmd/cmds.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package cmd

type RedisCmd struct {
type DiceDBCmd struct {
RequestID uint32
Cmd string
Args []string
}

type RedisCmds struct {
Cmds []*RedisCmd
Cmds []*DiceDBCmd
RequestID uint32
}
10 changes: 5 additions & 5 deletions internal/comm/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ func (c *Client) TxnBegin() {
}

func (c *Client) TxnDiscard() {
c.Cqueue.Cmds = make([]*cmd.RedisCmd, 0)
c.Cqueue.Cmds = make([]*cmd.DiceDBCmd, 0)
c.IsTxn = false
}

func (c *Client) TxnQueue(redisCmd *cmd.RedisCmd) {
c.Cqueue.Cmds = append(c.Cqueue.Cmds, redisCmd)
func (c *Client) TxnQueue(diceDBCmd *cmd.DiceDBCmd) {
c.Cqueue.Cmds = append(c.Cqueue.Cmds, diceDBCmd)
}

func NewClient(fd int) *Client {
cmds := make([]*cmd.RedisCmd, 0)
cmds := make([]*cmd.DiceDBCmd, 0)
return &Client{
Fd: fd,
Cqueue: cmd.RedisCmds{
Expand All @@ -57,7 +57,7 @@ func NewClient(fd int) *Client {
}

func NewHTTPQwatchClient(qwatchResponseChan chan QwatchResponse, clientIdentifierID uint32) *Client {
cmds := make([]*cmd.RedisCmd, 0)
cmds := make([]*cmd.DiceDBCmd, 0)
return &Client{
Cqueue: cmd.RedisCmds{Cmds: cmds},
Session: auth.NewSession(),
Expand Down
8 changes: 4 additions & 4 deletions internal/errors/migrated_errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,18 @@ import (
)

// Package errors provides error definitions and utility functions for handling
// common Redis error scenarios within the application. This package centralizes
// error messages to ensure consistency and clarity when interacting with Redis
// common DiceDB error scenarios within the application. This package centralizes
// error messages to ensure consistency and clarity when interacting with DiceDB
// commands and responses.

// Standard error variables for various Redis-related error conditions.
// Standard error variables for various DiceDB-related error conditions.
var (
ErrAuthFailed = errors.New("AUTH failed") // Indicates authentication failure.
ErrIntegerOutOfRange = errors.New("ERR value is not an integer or out of range") // Represents a value that is either not an integer or is out of allowed range.
ErrInvalidNumberFormat = errors.New("ERR value is not an integer or a float") // Signals that a value provided is not in a valid integer or float format.
ErrValueOutOfRange = errors.New("ERR value is out of range") // Indicates that a value is beyond the permissible range.
ErrOverflow = errors.New("ERR increment or decrement would overflow") // Signifies that an increment or decrement operation would exceed the limits.
ErrSyntax = errors.New("ERR syntax error") // Represents a syntax error in a Redis command.
ErrSyntax = errors.New("ERR syntax error") // Represents a syntax error in a DiceDB command.
ErrKeyNotFound = errors.New("ERR no such key") // Indicates that the specified key does not exist.
ErrWrongTypeOperation = errors.New("WRONGTYPE Operation against a key holding the wrong kind of value") // Signals an operation attempted on a key with an incompatible type.
ErrInvalidHyperLogLogKey = errors.New("WRONGTYPE Key is not a valid HyperLogLog string value") // Indicates that a key is not a valid HyperLogLog value.
Expand Down
2 changes: 1 addition & 1 deletion internal/eval/execute.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
dstore "github.com/dicedb/dice/internal/store"
)

func ExecuteCommand(c *cmd.RedisCmd, client *comm.Client, store *dstore.Store, httpOp, websocketOp bool) *EvalResponse {
func ExecuteCommand(c *cmd.DiceDBCmd, client *comm.Client, store *dstore.Store, httpOp, websocketOp bool) *EvalResponse {
diceCmd, ok := DiceCmds[c.Cmd]
if !ok {
return &EvalResponse{Result: diceerrors.NewErrWithFormattedMessage("unknown command '%s', with args beginning with: %s", c.Cmd, strings.Join(c.Args, " ")), Error: nil}
Expand Down
7 changes: 3 additions & 4 deletions internal/eval/worker_eval.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package eval

// This file contains functions required by worker nodes to
// evaluate specific Redis-like commands (e.g., INFO, PING).
// These evaluation functions are exposed to the worker,
// allowing them to process commands and return appropriate responses.
// These evaluation functions are exposed to the worker, without
// making any contact with shards allowing them to process
// commands and return appropriate responses.

import (
"github.com/dicedb/dice/internal/clientio"
Expand Down
2 changes: 1 addition & 1 deletion internal/object/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package object

type Obj struct {
TypeEncoding uint8
// Redis allots 24 bits to these bits, but we will use 32 bits because
// Redis allocates 24 bits to these bits, but we will use 32 bits because
// golang does not support bitfields, and we need not make this super-complicated
// by merging TypeEncoding + LastAccessedAt in one 32-bit integer.
// But nonetheless, we can benchmark and see how that fares.
Expand Down
16 changes: 8 additions & 8 deletions internal/ops/store_op.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import (
)

type StoreOp struct {
SeqID uint8 // SeqID is the sequence id of the operation within a single request (optional, may be used for ordering)
RequestID uint32 // RequestID identifies the request that this StoreOp belongs to
Cmd *cmd.RedisCmd // Cmd is the atomic Store command (e.g., GET, SET)
ShardID uint8 // ShardID of the shard on which the Store command will be executed
WorkerID string // WorkerID is the ID of the worker that sent this Store operation
Client *comm.Client // Client that sent this Store operation. TODO: This can potentially replace the WorkerID in the future
HTTPOp bool // HTTPOp is true if this Store operation is an HTTP operation
WebsocketOp bool // WebsocketOp is true if this Store operation is a Websocket operation
SeqID uint8 // SeqID is the sequence id of the operation within a single request (optional, may be used for ordering)
RequestID uint32 // RequestID identifies the request that this StoreOp belongs to
Cmd *cmd.DiceDBCmd // Cmd is the atomic Store command (e.g., GET, SET)
ShardID uint8 // ShardID of the shard on which the Store command will be executed
WorkerID string // WorkerID is the ID of the worker that sent this Store operation
Client *comm.Client // Client that sent this Store operation. TODO: This can potentially replace the WorkerID in the future
HTTPOp bool // HTTPOp is true if this Store operation is an HTTP operation
WebsocketOp bool // WebsocketOp is true if this Store operation is a Websocket operation
}

// StoreResponse represents the response of a Store operation.
Expand Down
18 changes: 9 additions & 9 deletions internal/querymanager/query_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
)

type (
cacheStore common.ITable[string, *object.Obj]
CacheStore common.ITable[string, *object.Obj]

// QuerySubscription represents a subscription to watch a query.
QuerySubscription struct {
Expand Down Expand Up @@ -54,7 +54,7 @@ type (
// Manager watches for changes in keys and notifies clients.
Manager struct {
WatchList sync.Map // WatchList is a map of query string to their respective clients, type: map[string]*sync.Map[int]struct{}
QueryCache common.ITable[string, cacheStore] // QueryCache is a map of fingerprints to their respective data caches
QueryCache common.ITable[string, CacheStore] // QueryCache is a map of fingerprints to their respective data caches
QueryCacheMu sync.RWMutex
logger *slog.Logger
}
Expand Down Expand Up @@ -86,23 +86,23 @@ func NewClientIdentifier(clientIdentifierID int, isHTTPClient bool) ClientIdenti
}
}

func NewQueryCacheStoreRegMap() common.ITable[string, cacheStore] {
return &common.RegMap[string, cacheStore]{
M: make(map[string]cacheStore),
func NewQueryCacheStoreRegMap() common.ITable[string, CacheStore] {
return &common.RegMap[string, CacheStore]{
M: make(map[string]CacheStore),
}
}

func NewQueryCacheStore() common.ITable[string, cacheStore] {
func NewQueryCacheStore() common.ITable[string, CacheStore] {
return NewQueryCacheStoreRegMap()
}

func NewCacheStoreRegMap() cacheStore {
func NewCacheStoreRegMap() CacheStore {
return &common.RegMap[string, *object.Obj]{
M: make(map[string]*object.Obj),
}
}

func NewCacheStore() cacheStore {
func NewCacheStore() CacheStore {
return NewCacheStoreRegMap()
}

Expand Down Expand Up @@ -221,7 +221,7 @@ func (m *Manager) updateQueryCache(queryFingerprint string, event dstore.QueryWa

store, ok := m.QueryCache.Get(queryFingerprint)
if !ok {
m.logger.Warn("Fingerprint not found in cacheStore", slog.String("fingerprint", queryFingerprint))
m.logger.Warn("Fingerprint not found in CacheStore", slog.String("fingerprint", queryFingerprint))
return
}

Expand Down
14 changes: 7 additions & 7 deletions internal/server/cmd_meta.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"github.com/dicedb/dice/internal/shard"
)

// CmdType defines the type of Redis command based on how it interacts with shards.
// CmdType defines the type of DiceDB command based on how it interacts with shards.
// It uses an integer value to represent different command types.
type CmdType int

Expand All @@ -21,15 +21,15 @@ const (
Custom // Custom commands involve direct client communication.
)

// CmdsMeta stores metadata about Redis commands, including how they are processed across shards.
// CmdsMeta stores metadata about DiceDB commands, including how they are processed across shards.
// CmdType indicates how the command should be handled, while Breakup and Gather provide logic
// for breaking up multishard commands and gathering their responses.
type CmdsMeta struct {
Cmd string // Command name.
Breakup func(mgr *shard.ShardManager, redisCmd *cmd.RedisCmd, c *comm.Client) []cmd.RedisCmd // Function to break up multishard commands.
Gather func(responses ...eval.EvalResponse) []byte // Function to gather responses from shards.
RespNoShards func(args []string) []byte // Function for commands that don't interact with shards.
CmdType // Enum indicating the command type.
Cmd string // Command name.
Breakup func(mgr *shard.ShardManager, DiceDBCmd *cmd.DiceDBCmd, c *comm.Client) []cmd.DiceDBCmd // Function to break up multishard commands.
Gather func(responses ...eval.EvalResponse) []byte // Function to gather responses from shards.
RespNoShards func(args []string) []byte // Function for commands that don't interact with shards.
CmdType // Enum indicating the command type.
}

// WorkerCmdsMeta is a map that associates command names with their corresponding metadata.
Expand Down
Loading