PostgreSQL has a replication feature which is called logical replication. In earliest versions there is a native extension called pgoutput for logical decoding.
Logical Replication consist of a publisher and a subscriber which result into 1-1 replication. My question is, if I can create my own subscriber though a PostgreSQL function in order to stream changes and make lightweight modification before applied to the destination table.
For instance, there is the way of test_decoding
SELECT * FROM pg_create_logical_replication_slot('test_slot', 'test_decoding');
DROP PUBLICATION PUB;
CREATE PUBLICATION PUB FOR ALL TABLES;
SELECT * FROM pg_logical_slot_get_changes('test_slot', NULL, NULL, 'stream-changes', '1');
But this way I have to sent select queries again and again and this is not exactly streaming....
Any ideas?