// send-test-push enqueues a one-shot Asynq push notification task. The worker // picks it up and routes it through internal/push/Client.SendToAll, which now // hits APNs production. Verifies end-to-end that push delivery is working // without waiting for the next cron tick. // // Usage: // // # Port-forward Redis from the cluster first: // kubectl --kubeconfig=~/.kube/honeydue-k3s.yaml -n honeydue port-forward svc/redis 6379:6379 // // # Then in another shell: // go run ./cmd/send-test-push --user-id 6 --title "Test" --message "Hello from notif-diag" package main import ( "flag" "fmt" "os" "strconv" "github.com/hibiken/asynq" "github.com/treytartt/honeydue-api/internal/worker/jobs" ) func main() { userID := flag.Uint("user-id", 0, "Target auth_user.id (required)") title := flag.String("title", "Test push", "Notification title") message := flag.String("message", "Hello from send-test-push", "Notification body") redisAddr := flag.String("redis", "localhost:6379", "Redis host:port (use kubectl port-forward to reach the in-cluster redis)") flag.Parse() if *userID == 0 { fmt.Fprintln(os.Stderr, "--user-id is required") os.Exit(2) } task, err := jobs.NewSendPushTask(*userID, *title, *message, map[string]string{ "type": "test", "user_id": strconv.FormatUint(uint64(*userID), 10), }) if err != nil { fmt.Fprintf(os.Stderr, "build task: %v\n", err) os.Exit(1) } client := asynq.NewClient(asynq.RedisClientOpt{Addr: *redisAddr}) defer func() { _ = client.Close() }() info, err := client.Enqueue(task, asynq.Queue("default"), asynq.MaxRetry(3)) if err != nil { fmt.Fprintf(os.Stderr, "enqueue: %v\n", err) os.Exit(1) } fmt.Printf("Enqueued task: id=%s queue=%s type=%s\n", info.ID, info.Queue, info.Type) fmt.Printf("Tail worker logs to see the result:\n") fmt.Printf(" kubectl --kubeconfig=~/.kube/honeydue-k3s.yaml -n honeydue logs deploy/worker --tail=20 -f\n") }