Skip to content

Commit

Permalink
merge master and fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
xanish committed Dec 27, 2024
2 parents f636322 + b39869c commit 358ff95
Show file tree
Hide file tree
Showing 518 changed files with 26,012 additions and 15,759 deletions.
2 changes: 1 addition & 1 deletion .air.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ tmp_dir = "tmp"
exclude_regex = []
exclude_unchanged = false
follow_symlink = false
full_bin = "GO_ENV=development ./dicedb --enable-multithreading=true --enable-profiling=false"
full_bin = "GO_ENV=development ./dicedb --enable-profiling=false"
include_dir = []
include_ext = ["go", "tpl", "tmpl", "yaml", "env"]
kill_delay = "1s"
Expand Down
11 changes: 3 additions & 8 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-golint-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-golint-
- uses: actions/setup-go@v5
with:
go-version: stable
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
bin/dice
*.aof
*.out
*.prof
.vscode/
dice-server
dicedb
Expand All @@ -10,6 +12,7 @@ __pycache__
*.rdb
dice
main
tmp/

# build output
dist/
Expand Down
661 changes: 661 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

110 changes: 0 additions & 110 deletions LICENSE.md

This file was deleted.

116 changes: 63 additions & 53 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Adapted from https://www.thapaliya.com/en/writings/well-documented-makefiles/

THREADS ?= 4 #number of threads
CLIENTS ?= 50 #number of clients per thread
REQUESTS ?= 10000 #number of requests per client
Expand All @@ -14,71 +16,42 @@ VERSION=$(shell bash -c 'grep -oP "DiceDBVersion string = \"\K[^\"]+" config/con

.PHONY: build test build-docker run test-one

.DEFAULT_GOAL := build

# Help command
help:
@echo "Available commands:"
@echo " build - Build the project"
@echo " format - Format the code"
@echo " run - Run the project"
@echo " test - Run the integration tests"
@echo " test-one - Run a specific integration tests"
@echo " unittest - Run unit tests"
@echo " unittest-one - Run a specific unit test"
@echo " build-docker - Build docker image"
@echo " push-docker - Push docker image"
@echo " lint - Run linter"
@echo " run_benchmark - Run benchmark"
@echo " run_benchmark-small - Run small benchmark"
@echo " run_benchmark-large - Run large benchmark"
@echo " clean - Remove build artifacts"

build:
.DEFAULT_GOAL := help

##@ Helpers

help: ## Display this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)

##@ Building

build: ## generate the dicedb binary for the current OS and architecture
@echo "Building for $(GOOS)/$(GOARCH)"
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -o ./dicedb

format:
go fmt ./...
build-debug: ## generate the dicedb binary for the current OS and architecture
@echo "Building for $(GOOS)/$(GOARCH)"
CGO_ENABLED=0 GOOS=$(GOOS) GOARCH=$(GOARCH) go build -gcflags="all=-N -l" -o ./dicedb

run:
go run main.go
##@ Testing

# Changing the parallel package count to 1 due to a possible race condition which causes the tests to get stuck.
# TODO: Fix the tests to run in parallel, and remove the -p=1 flag.
test:
go test -v -race -count=1 -p=1 ./integration_tests/...
test: ## run the integration tests
go test -race -count=1 -p=1 ./integration_tests/...

test-one:
test-one: ## run a single integration test function by name (e.g. make test-one TEST_FUNC=TestSetGet)
go test -v -race -count=1 --run $(TEST_FUNC) ./integration_tests/...

unittest:
unittest: ## run the unit tests
go test -race -count=1 ./internal/...

unittest-one:
unittest-one: ## run a single unit test function by name (e.g. make unittest-one TEST_FUNC=TestSetGet)
go test -v -race -count=1 --run $(TEST_FUNC) ./internal/...

release:
git tag $(VERSION)
git push origin --tags
docker build --tag dicedb/dicedb:latest --tag dicedb/dicedb:$(VERSION) .
docker push dicedb/dicedb:$(VERSION)
docker push dicedb/dicedb:latest

GOLANGCI_LINT_VERSION := 1.60.1

lint: check-golangci-lint
golangci-lint run ./...
##@ Benchmarking

check-golangci-lint:
@if ! command -v golangci-lint > /dev/null || ! golangci-lint version | grep -q "$(GOLANGCI_LINT_VERSION)"; then \
echo "Required golangci-lint version $(GOLANGCI_LINT_VERSION) not found."; \
echo "Please install golangci-lint version $(GOLANGCI_LINT_VERSION) with the following command:"; \
echo "curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.60.1"; \
exit 1; \
fi

run_benchmark:
run_benchmark: ## run the memtier benchmark with the specified parameters
@echo "Running memtier benchmark..."
memtier_benchmark \
--threads=$(THREADS) \
Expand All @@ -89,13 +62,50 @@ run_benchmark:
--port=$(PORT)
@echo "Benchmark complete."

run-benchmark-small:
run-benchmark-small: ## run the memtier benchmark with small parameters
$(MAKE) run_benchmark THREADS=2 DATA_SIZE=512 CLIENTS=20 REQUESTS=5000

run-benchmark-large:
run-benchmark-large: ## run the memtier benchmark with large parameters
$(MAKE) run_benchmark THREADS=8 DATA_SIZE=4096 CLIENTS=100 REQUESTS=50000

clean:

##@ Development
run: ## run dicedb with the default configuration
go run main.go

run-docker: ## run dicedb in a Docker container
docker run -p 7379:7379 dicedb/dicedb:latest

format: ## format the code using go fmt
go fmt ./...

GOLANGCI_LINT_VERSION := 1.60.1

lint: check-golangci-lint ## run golangci-lint
golangci-lint run ./...

check-golangci-lint:
@if ! command -v golangci-lint > /dev/null || ! golangci-lint version | grep -q "$(GOLANGCI_LINT_VERSION)"; then \
echo "Required golangci-lint version $(GOLANGCI_LINT_VERSION) not found."; \
echo "Please install golangci-lint version $(GOLANGCI_LINT_VERSION) with the following command:"; \
echo "curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.60.1"; \
exit 1; \
fi

clean: ## clean the dicedb binary
@echo "Cleaning build artifacts..."
rm -f dicedb
@echo "Clean complete."

##@ Deployment

release: ## build and push the Docker image to Docker Hub with the latest tag and the version tag
git tag $(VERSION)
git push origin --tags
docker build --tag dicedb/dicedb:latest --tag dicedb/dicedb:$(VERSION) .
docker push dicedb/dicedb:$(VERSION)
docker push dicedb/dicedb:latest

push-binary-remote:
$(MAKE) build
scp -i ${SSH_PEM_PATH} ./dicedb ubuntu@${REMOTE_HOST}:.
Loading

0 comments on commit 358ff95

Please sign in to comment.