feat: 🎉 postgresql broker first commit of forked prototype from my original code

This commit is contained in:
2026-01-02 20:56:39 +02:00
parent e90e5902cd
commit 19e469ff54
29 changed files with 3325 additions and 2 deletions

88
Makefile Normal file
View File

@@ -0,0 +1,88 @@
.PHONY: all build clean test install deps help
# Build variables
BINARY_NAME=pgsql-broker
BIN_DIR=bin
CMD_DIR=cmd/broker
GO=go
GOFLAGS=-v
LDFLAGS=-w -s
# Version information
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
BUILD_TIME=$(shell date -u '+%Y-%m-%d_%H:%M:%S')
COMMIT=$(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
# Inject version info
LDFLAGS += -X 'main.Version=$(VERSION)' -X 'main.BuildTime=$(BUILD_TIME)' -X 'main.Commit=$(COMMIT)'
all: clean deps build ## Build everything
build: ## Build the broker binary
@echo "Building $(BINARY_NAME)..."
@mkdir -p $(BIN_DIR)
$(GO) build $(GOFLAGS) -ldflags "$(LDFLAGS)" -o $(BIN_DIR)/$(BINARY_NAME) ./$(CMD_DIR)
@echo "Built: $(BIN_DIR)/$(BINARY_NAME)"
clean: ## Remove build artifacts
@echo "Cleaning..."
@rm -rf $(BIN_DIR)
@$(GO) clean
@echo "Clean complete"
deps: ## Download dependencies
@echo "Downloading dependencies..."
@$(GO) mod download
@$(GO) mod tidy
@echo "Dependencies ready"
test: ## Run tests
@echo "Running tests..."
@$(GO) test -v -race -cover ./...
install: build ## Install the binary to GOPATH/bin
@echo "Installing to GOPATH/bin..."
@$(GO) install $(GOFLAGS) -ldflags "$(LDFLAGS)" ./$(CMD_DIR)
@echo "Installed: $(BINARY_NAME)"
run: build ## Build and run the broker
@echo "Running $(BINARY_NAME)..."
@$(BIN_DIR)/$(BINARY_NAME)
fmt: ## Format the code
@echo "Formatting code..."
@$(GO) fmt ./...
@echo "Formatting complete"
vet: ## Run go vet
@echo "Running go vet..."
@$(GO) vet ./...
@echo "Vet complete"
lint: ## Run golangci-lint (if installed)
@if command -v golangci-lint >/dev/null 2>&1; then \
echo "Running golangci-lint..."; \
golangci-lint run ./...; \
else \
echo "golangci-lint not installed, skipping"; \
fi
sql-install: build ## Install SQL tables and procedures using broker CLI
@echo "Installing SQL schema..."
@$(BIN_DIR)/$(BINARY_NAME) install
sql-install-manual: ## Install SQL tables and procedures manually via psql
@echo "Installing SQL schema manually..."
@if [ -z "$$PGDATABASE" ]; then \
echo "Error: PGDATABASE environment variable not set"; \
exit 1; \
fi
@psql -f pkg/broker/install/sql/tables/00_install.sql
@psql -f pkg/broker/install/sql/procedures/00_install.sql
@echo "SQL schema installed"
help: ## Show this help message
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " %-15s %s\n", $$1, $$2}'