1
0
mirror of https://github.com/ebosas/microservices.git synced 2025-06-18 22:17:48 +02:00

Create messages page

This commit is contained in:
ebosas
2021-10-06 15:30:52 +03:00
parent 9383cef0d7
commit ed3ce70b37
10 changed files with 369 additions and 143 deletions

View File

@ -58,8 +58,16 @@ func insertToDB(d amqp.Delivery, c *pgx.Conn) bool {
log.Fatalf("insert into database: %s", err)
}
// Alternatively, send Cache messages from here
// instead of server and backend services
// An alternative query that returns the id of the inserted row.
// var id int64
// err = c.QueryRow(context.Background(), "insert into messages (message, created) values ($1, to_timestamp($2)) returning id", message.Text, message.Time/1000).Scan(&id)
// if err != nil {
// log.Fatalf("insert into database: %s", err)
// }
// fmt.Println(id)
// For cache, could send messages from here instead
// of doing it from the server and backend services.
// err = <Rabbit conn>.Publish(conf.Exchange, conf.KeyCache, d.Body)
return true