This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Gorush is a push notification microserver written in Go that supports sending notifications to iOS (APNS), Android (FCM), and Huawei (HMS) devices. It provides both HTTP REST API and gRPC interfaces.
- main.go parses CLI flags, loads config, initializes platform clients (APNS/FCM/HMS), then starts HTTP (Gin) and gRPC servers via
graceful.Manager - router/ receives push requests at
POST /api/push, validates them, and enqueuesPushNotificationmessages into the queue - app/worker.go creates the queue worker (local/NSQ/NATS/Redis) with
notify.Run(cfg)as the processing function - notify/ dispatches notifications to platform-specific push functions (
PushToIOS,PushToAndroid,PushToHuawei) - status/ + storage/ track success/failure counts across configurable backends
- app/: Application orchestration — CLI send helpers (
sender.go), config validation/merge (config.go), CLI options (options.go), queue worker creation (worker.go) - config/: YAML config with Viper, env var overrides. Reference config:
config/testdata/config.yml - core/: Shared types and interfaces —
Platformenum, queue engine constants (core/queue.go), storage interface (core/storage.go), health check interface (core/health.go) - notify/: Platform-specific push implementations. Each platform has its own file (
notification_apns.go,notification_fcm.go,notification_hms.go).global.goholds shared client state - router/: Gin HTTP server with REST endpoints and Prometheus metrics
- rpc/: gRPC server. Proto definitions in
rpc/proto/ - storage/: Storage backends (memory, Redis, BoltDB, BuntDB, LevelDB, BadgerDB) all implement
core.Storage - logx/: Logging utilities wrapping zerolog/logrus
make build # Build binary to release/gorush
make install # Install to $GOPATH/bin
make dev # Hot reload with air# Full test suite (requires FCM credentials)
export FCM_CREDENTIAL="/path/to/firebase-credentials.json"
export FCM_TEST_TOKEN="your_test_device_token"
make test
# Run a single test
go test -v -tags sqlite -run TestFunctionName ./package/...
# Run tests for a specific package
go test -v -tags sqlite ./notify/...
go test -v -tags sqlite ./config/...The -tags sqlite flag is required for all test commands (it's the default build tag).
make lint # Run golangci-lint (auto-installs if missing)
make fmt # Format code with golangci-lint fmtLinter config is in .golangci.yml (v2 format). Uses golangci-lint v2.
make generate_proto # Generate both Go and JS proto filessqlite— default tag, required for standard builds and testslambda— for AWS Lambda builds (replaces sqlite)- Set custom tags via
TAGSenvironment variable
Config uses Viper with YAML files. Key sections: core, grpc, android, ios, huawei, queue, stat, log, api. See config/testdata/config.yml for all options. Environment variables can override any config value.
POST /api/push— send push notificationsGET /api/stat/go— Go runtime statsGET /api/stat/app— push statisticsGET /api/config— current configGET /metrics— Prometheus metricsGET /healthz— health check