bbhoss
I recently announced my work on Cainophile, and it was suggested I post it here for further dissemination and feedback. Cainophile is a library to assist you in building change data capture systems with Postgres and Elixir. I also have released a separate library for decoding the logical Postgres replication log directly in case that is helpful. You can find full details on the announcement.
Trending in Announcing
The repo is at GitHub - cyberchitta/openai_ex: Community maintained Elixir library for OpenAI API · GitHub.
Docs are at OpenaiEx User Gu...
New
WebAuthnLiveComponent WebAuthnComponents
See this post about renaming the package.
Passwordless authentication for Phoenix LiveView app...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
In 2021 I started a new library called Tempo with the objective of modelling time as a set of intervals - not as instants. In 2022 I gave...
New
I’ve recently created a small library phoenix_vite integrating the vite build tooling with phoenix.
It
provides an igniter.installer t...
New
Other Trending Topics
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with.
But I don’t use it anymore.
Serverless was the promis...
New
(I just needed to vent somewhere and LinkedIn is full of hope, or hype, I’m not sure which exactly)
AI dream has many faces, but general...
New
What IDE or editor are you using for Elixir development?
Personally, I use Zed, and I really like it, but sometimes I wish there were a ...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #ai
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixirconf-us
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #security
- #performance











Showing Posts 1 to 5- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
slashdotdash
Looks really useful and is something I’ve been wanting to do with Postgres in Elixir for a while.
Does using
:temporaryas the replication slot mean that only new changes will be received by the subscriber and it won’t receive any historical changes when restarted? For a use case I have in mind this is the behaviour I want whereby the subscriber only receives the changes made while its running.bbhoss
Glad to hear that it might be useful! Honestly I have not attempted a full sync with it, I’m not sure how that would work but presumably if you kept all of you WAL logs around and postgres has access to them, you could request the initial WAL position and go from there. As far as temporary, it really just refers to if you want a persistent slot or not. Persistent slots keep track of what has been acknowledged by the subscriber, and survive across connections. For production use cases, persistent slots are probably the best option, as you can be sure that you’re not missing out on changes due to network issues/subscriber failure. However, if you have a replication slot hanging around and not being acknowledged, I believe it will eventually fill up and cause problems.
Temporary slots just create an ephemeral replication slot that goes away when the subscriber disconnects. This is useful for testing or quick trials as it doesn’t keep garbage around. If you want to try this on a production database for example (after staging!), you could start with temporary to minimize the impact.
As far as what you’re trying to do, it sounds like temporary or named slots would work. What you’ll want to do is specify
{0,0}for the wal position (it defaults to this), which means “let postgres decide what to send me”. In the case of temporary slots, you will just receive what is new with{0,0}, as there will be no previously acknowledged wal position that Postgres will try to send. With a named slot, it seems that postgres will start sending you info from where you left off.slashdotdash
Thanks for the reply. Useful to know that
{0, 0}for temporary means to receive only new data.benwilson512
Hey @bbhoss, I’m not sure if you’re still working on this, but I’ve been looking into this library with interest lately. Two things stand out to me:
I’d like to find the right way to allow my application code to decide when to confirm a message. Right now, when a transaction commits, Cainophile sends the message off to any subscribers, and then confirms. If those subscribers however crash or are unable to do anything useful with that value, it is lost. User space confirmation would be key to avoid data loss.
I see you had to implement postgres binary value decoding. I’m surprised there wasn’t something in epgsql or postgrex that you could reuse there. In particular I’m concerned about extensibility over time with custom types. Is there something about the values sent by Postgres that are a different binary format from what epgsql and postgrex deal with today?
cpursley
This is something I’m wondering about as well. It would be nice to be able to decode directly to erlang/elixir types (especially integers, booleans).
I slapped together a library that borrows the Supbase realtime / Cainophile code. The main change I made was add a process to accept the changes so that you can act on the data right in Elixir (and send off wherever you like).
One of the todos is to address the type decoding if that’s even possible (and it would be nice to have an adapter approach so that you can specify the type you want). Another is to swap out epgsql now that Postgrex has native replication.
https://github.com/cpursley/walex/issues/3