Skip to content

Instantly share code, notes, and snippets.

View ArseniySavin's full-sized avatar
😏

savars ArseniySavin

😏
View GitHub Profile
@albscui
albscui / how-to-postgres-listener.md
Last active July 9, 2025 16:28
Postgres trigger and listener mechanism (Go)

How to listen to events in Postgres (with a bit of Go)

Postgres has built-in mechanism for notifying clients (listeners) of events such as INSERT, UPDATE, and DELETE on tables.

Note that for this to work, a listener must have a dedicated direct connection to Postgres. Connection poolers like pgbouncer would not work.

First, lets go over some key Postgres components:

  • triggers - automatically executes some function when an event on a table occurs
  • channels - a communication mechanism identified by a string in postgres
@miguelmota
miguelmota / insert.go
Last active May 28, 2024 15:34
Golang SQL insert row and get returning ID example
func InsertOrder(order *Order) (int, error) {
var id int
tx, err := db.Begin()
if err != nil {
return id, err
}
{
public class SomeClass {
public void SomeMethod() {
this.Log().Info(() => "Here is a log message with params which can be in Razor Views as well: '{0}'".FormatWith(typeof(SomeClass).Name));
}
}
@vijayganeshpk
vijayganeshpk / OracleDynamicParameters.cs
Last active February 8, 2024 09:04
OracleDynamicParameters class for Dapper
using Dapper;
using Oracle.ManagedDataAccess.Client;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
public class OracleDynamicParameters : Dapper.SqlMapper.IDynamicParameters {
private static Dictionary<SqlMapper.Identity, Action<IDbCommand, object>> paramReaderCache = new Dictionary<SqlMapper.Identity, Action<IDbCommand, object>>( );