SendSignal sends a notification to the bytebase_signal channel.
(ctx context.Context, signalType storepb.Signal_Type, projectID string, uid int64)
| 14 | |
| 15 | // SendSignal sends a notification to the bytebase_signal channel. |
| 16 | func (s *Store) SendSignal(ctx context.Context, signalType storepb.Signal_Type, projectID string, uid int64) error { |
| 17 | payload, err := protojson.Marshal(&storepb.Signal{ |
| 18 | Type: signalType, |
| 19 | Uid: uid, |
| 20 | Project: projectID, |
| 21 | }) |
| 22 | if err != nil { |
| 23 | return errors.Wrap(err, "failed to marshal signal payload") |
| 24 | } |
| 25 | _, err = s.GetDB().ExecContext(ctx, "SELECT pg_notify($1, $2)", SignalChannel, string(payload)) |
| 26 | return errors.Wrap(err, "failed to send signal") |
| 27 | } |
no test coverage detected