|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +`move` is a Go CLI tool that moves Senzing records between files and queues. It's part of the senzing-tools suite. The tool validates each record as JSON with required `RECORD_ID` and `DATA_SOURCE` fields before moving. |
| 8 | + |
| 9 | +**Supported inputs:** Local files (`file://`), HTTP/HTTPS URLs, stdin |
| 10 | +**Supported outputs:** RabbitMQ (`amqp://`), AWS SQS (`sqs://` or `https://`), local files, stdout |
| 11 | +**File formats:** JSONL (`.jsonl`), GZIP-compressed JSONL (`.gz`) |
| 12 | + |
| 13 | +## Build & Development Commands |
| 14 | + |
| 15 | +```bash |
| 16 | +# Build |
| 17 | +make clean build # Build binary for current platform |
| 18 | +make build-all # Build for all platforms (darwin/linux/windows, amd64/arm64) |
| 19 | + |
| 20 | +# Test |
| 21 | +make clean setup test # Run tests with gotestfmt output |
| 22 | +go test -v ./... # Run tests directly |
| 23 | + |
| 24 | +# Run single test |
| 25 | +go test -v -run TestName ./path/to/package |
| 26 | + |
| 27 | +# Lint |
| 28 | +make lint # Run golangci-lint, govulncheck, cspell |
| 29 | + |
| 30 | +# Coverage |
| 31 | +make clean setup coverage # Generate coverage report (opens in browser) |
| 32 | +make check-coverage # Run coverage with threshold check |
| 33 | + |
| 34 | +# Run locally |
| 35 | +make run # Run via go run |
| 36 | +./target/linux-amd64/move # Run built binary |
| 37 | + |
| 38 | +# Dependencies |
| 39 | +make dependencies-for-development # Install dev tools (golangci-lint, gotestfmt, etc.) |
| 40 | +make dependencies # Update Go module dependencies |
| 41 | +``` |
| 42 | + |
| 43 | +## Architecture |
| 44 | + |
| 45 | +### Package Structure |
| 46 | + |
| 47 | +- `main.go` - Entry point, calls `cmd.Execute()` |
| 48 | +- `cmd/` - CLI layer using Cobra/Viper |
| 49 | + - `root.go` - Command definition, flag bindings, creates `BasicMove` and calls `Move()` |
| 50 | + - `context_*.go` - OS-specific context variables |
| 51 | +- `move/` - Core business logic |
| 52 | + - `main.go` - `Move` interface definition, component ID (6202), log message catalog |
| 53 | + - `move.go` - `BasicMove` implementation with read/write goroutines |
| 54 | + - `szRecord.go` - `SzRecord` implements `queues.Record` interface |
| 55 | + |
| 56 | +### Data Flow |
| 57 | + |
| 58 | +1. `BasicMove.Move()` spawns two goroutines connected by a buffered channel (capacity 10) |
| 59 | +2. Read goroutine: Parses input (file/URL/stdin), validates JSON records, sends to channel |
| 60 | +3. Write goroutine: Consumes from channel, writes to output (queue/file/stdout) |
| 61 | +4. Record validation uses `github.com/senzing-garage/go-helpers/record.Validate()` |
| 62 | + |
| 63 | +### Key Dependencies |
| 64 | + |
| 65 | +- `go-cmdhelping` - CLI flag/option handling |
| 66 | +- `go-queueing` - RabbitMQ and SQS producers (`rabbitmq.StartManagedProducer`, `sqs.StartManagedProducer`) |
| 67 | +- `go-logging` - Structured logging with Senzing message IDs |
| 68 | +- `cobra/viper` - CLI framework |
| 69 | + |
| 70 | +### Configuration |
| 71 | + |
| 72 | +All options can be set via CLI flags or `SENZING_TOOLS_*` environment variables: |
| 73 | +- `--input-url` / `SENZING_TOOLS_INPUT_URL` - Source URL |
| 74 | +- `--output-url` / `SENZING_TOOLS_OUTPUT_URL` - Destination URL |
| 75 | +- `--input-file-type` / `SENZING_TOOLS_INPUT_FILE_TYPE` - Override file type detection (JSONL) |
| 76 | +- `--record-min`, `--record-max` - Record range filtering |
| 77 | +- `--json-output` - Enable JSON-formatted log output |
0 commit comments