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

Add node generation and proactive expiration policies #58

Merged
merged 2 commits into from
Mar 2, 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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# vendor/

/.idea/
*.tmp
*coverage.txt
*lint.txt
**/bin/
Expand Down
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ test: test.unit ## Run all the tests
.PHONY: test.unit
test.unit: ## Run all unit tests
@echo 'mode: atomic' > coverage.txt
go test -covermode=atomic -coverprofile=coverage.txt -coverpkg=./... -v -race ./...
go test -covermode=atomic -coverprofile=coverage.txt.tmp -coverpkg=./... -v -race ./...
cat coverage.txt.tmp | grep -v "/generated/" > coverage.txt
rm coverage.txt.tmp

.PHONY: cover
cover: test.unit ## Run all the tests and opens the coverage report
Expand All @@ -34,7 +36,7 @@ ci: lint test ## Run all the tests and code checks

.PHONY: generate
generate: ## Generate files for the project
go generate ./...
go run ./cmd/generator ./internal/generated/node

.PHONY: clean
clean: ## Remove temporary files
Expand Down
3 changes: 3 additions & 0 deletions builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type baseOptions[K comparable, V any] struct {
capacity int
initialCapacity int
statsEnabled bool
withCost bool
costFunc func(key K, value V) uint32
}

Expand All @@ -49,6 +50,7 @@ func (o *baseOptions[K, V]) collectStats() {

func (o *baseOptions[K, V]) setCostFunc(costFunc func(key K, value V) uint32) {
o.costFunc = costFunc
o.withCost = true
}

func (o *baseOptions[K, V]) setInitialCapacity(initialCapacity int) {
Expand All @@ -75,6 +77,7 @@ func (o *baseOptions[K, V]) toConfig() core.Config[K, V] {
InitialCapacity: initialCapacity,
StatsEnabled: o.statsEnabled,
CostFunc: o.costFunc,
WithCost: o.withCost,
}
}

Expand Down
Loading
Loading