BitGonzo
Here is my current structure:
- scheduler app (Elixir app)
- background worker app x 2 (Elixir app)
- web app x 2 (Phoenix app)
The scheduler, background workers and web apps are completely separate applications (not part of an umbrella app); they could be on different nodes, even in different regions.
However, all of these applications need to speak to my database, and for that I have common ecto schemas.
My question is two-fold:
- would you use a library for the common domain model?
- what is the best way to handle that during development?
For example, in the past I would reference a local copy of the library in order to develop on, but unsure if this is straight-forward in Elixir, or if there are gotchas I need to be aware of (noting that only the web app is a Phoenix app).
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
apply_graft/2 doesn’t rewrite an add_many sub-workflow’s deps on an add step. Grafted jobs cancel with “upstream job was deleted”
Version...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
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
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #blog-post
- #ai
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 6- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
aseigo
What I have done in this situation is create a mix project that contains the migrations and schemas (and usually some of the common interaction functions, like ones to generate useful changesets) and then use that as a dependency in all the individual projects.
During development, I replace the usual git path to that library in the mix dependency with a local path, e.g. this:
becomes
Then changes during devel to the schemas gets picked up in further calls to
mix compilewithout having to commit, push,mix deps.updateetc. Very handy! Then before committing into the feature branch of the application repo(s), I revert the mix.exs change (git stashis pretty handy here), so that the path version does not polute the app repo.nsweeting
I feel like you might be forcing separation of concerns without reason. If all the apps rely on the same schemas and database - why not just join them into a singular app? If you want some nodes to run certain services, but not others (ie. Your background workers to not run your endpoint) - you can just use env flags to control what is started in your supervision tree.
BitGonzo
This is how I’ve setup my current worker/web (as worker currently relies on schemas in web).
It has resulted in:
Not entirely happy scaling that for every new application I introduce. Maybe if there were just two apps (worker/web), but not now I have a scheduler and [potentially] more apps down the line. The apps have separate responsibilities along with dependencies and, as you say, supervision trees, different configs.. very messy to dump all that in a singular app.
But fair point.
Cheers. I think this is likely what I’ll end up doing.
aseigo
It does get a bit ugly as more and more business logic related to a variety of modules and config ends up in the supervisor(s). One possible route is to
Enum.reducea children list by calling a function in each of the children which returns a spec or not, and is thereby included in the children list or not, e.g.:.. or some such. At least then the decision making logic is in each child. For child implementations you don’t control (e.g. deps), creating a factory module that produces child specs based on env would do (the module in the children list does not need to return a child spec that resolves to itself!)
In fact, I wonder if this couldn’t be added as a general feature in the standard library. I know I would have used it in projects already if it were .. something like this patch .. @josevalim: what do you think? Obviously that patch only covers Supervisor and would need similar implementations in all the child_spec() implementations and supervisors…
OvermindDL1
Don’t forget that a mix.exs file is code, you can always conditionally pull a local path or git, or from an environment, or whatever.
benwilson512
Folks tend to forget you can return
:ignorefrom astart_linkfunction. GenServer — Elixir v1.20.2. If you return:ignorefrom a start link it’ll just get ignored. This means you can have your worker list be a nice full worker list, and then the start_link function of each child can determine whether it should actually start or not.This tactic works great for sort of “feature flag” style workers where they’re all pretty independent. Not so great for tightly coupled workers.