()
| 58 | } |
| 59 | |
| 60 | func (l *PostgresTransactionLogger) Run() { |
| 61 | events := make(chan Event, 16) // Make an events channel |
| 62 | l.events = events |
| 63 | |
| 64 | errors := make(chan error, 1) // Make an errors channel |
| 65 | l.errors = errors |
| 66 | |
| 67 | go func() { // The INSERT query |
| 68 | query := `INSERT INTO transactions |
| 69 | (event_type, key, value) |
| 70 | VALUES ($1, $2, $3)` |
| 71 | |
| 72 | for e := range events { // Retrieve the next Event |
| 73 | _, err := l.db.Exec( // Execute the INSERT query |
| 74 | query, |
| 75 | e.EventType, e.Key, e.Value) |
| 76 | |
| 77 | if err != nil { |
| 78 | errors <- err |
| 79 | } |
| 80 | |
| 81 | l.wg.Done() |
| 82 | } |
| 83 | }() |
| 84 | } |
| 85 | |
| 86 | func (l *PostgresTransactionLogger) Wait() { |
| 87 | l.wg.Wait() |
nothing calls this directly
no outgoing calls
no test coverage detected