()
| 48 | } |
| 49 | |
| 50 | func ExampleConsumer() { |
| 51 | db, err := sql.Open("postgres", "user=postgres password=postgres host=localhost port=5432 dbname=postgres") |
| 52 | if err != nil { |
| 53 | log.Fatal("Error opening database:", err) |
| 54 | } |
| 55 | defer db.Close() |
| 56 | const queueName = "test_queue" |
| 57 | c, err := pgq.NewConsumer(db, queueName, &Handler{}) |
| 58 | if err != nil { |
| 59 | log.Fatal("Error creating consumer:", err) |
| 60 | } |
| 61 | ctx, _ := signal.NotifyContext(context.Background(), os.Interrupt) |
| 62 | if err := c.Run(ctx); err != nil && !errors.Is(err, context.Canceled) { |
| 63 | log.Fatal("Error running consumer:", err) |
| 64 | } |
| 65 | } |
nothing calls this directly
no test coverage detected