victorbjorklund

victorbjorklund

Specify which parts of library to compile or not

I’m going to try to build a library (that I can hopefully publish) that allows access to statistics reports from the Swedish Statistics Authority. Basically they have a bunch of statistics data but the issue is they use very weird API:s for accessing them so I wanna provide a more easy way to get the data by wrapping the api:s in a nice library.

However they have a lot of reports and data so I will probably have to write a module per report. And it seems a bit wasteful to include all (I’m not sure how many reports in total they got but wouldn’t be surprised if it is over 500) for a project that just wanna access how the population size of each municipality.

I get that it might be hard/impossible to “tree-shake” since code can be called dynamically at runtime but can I provide a way to for example specify in the config which reports they want to actually use? Something like this:

config :scb_ex,
  reports: [:municipality_population]

Most Liked

al2o3cr

al2o3cr

There was just a post on the Dashbit blog arguing for smaller SDK surfaces:

Are the many reports different enough to need different code?

arcyfelix

arcyfelix

I guess you could hack it by slightly changing your approach.
Instead of a single mix project, you can have a single umbrella project and your modules will become small libraries.
You can control what has access to what with Boundary — boundary v0.10.3 to provide a meaningful error when one “module/report” depends on another that is not compiled (strongly advised against it).
Or you can extract these common pieces to the Core which is exposed to all Reports.

Where Next?

Popular in Questions Top

vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
yawaramin
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
LegitStack
I’m hoping you guys can give me some general advice and perhaps code examples if you’re feeling up to it. I’m very interested in Elixir,...
New
JorisKok
I have a server on AWS, and was running a load test using artillery. When looking at the Phoenix dashboard I see the Ports going to 100% ...
New
itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
lk-geimfari
What is most correct way to open, read and parse JSON file with poison? For example if we have example.json file in root of some projec...
New
johnnyicon
Hi all, I've just started learning Elixir and Phoenix Framework, so please pardon my n00bness at this stage. I'm trying to use Postg...
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New

Other popular topics Top

peerreynders
Manning 2016 Halloween weekend sale via Deal of the Day Friday, October 28 - Half off all MEAPs - code WM102816LT Saturday, October 29 ...
326 29600 154
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
977 41022 311
New
William
I would like to know that is there any online source for learning Phoenix Framework for building E-Commerce Store? Any advantage on build...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
_russellb
I want to try my hand at web scraping. What tools/libraries do I need to use. I’m hoping to turn this into something professional so don’...
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New

We're in Beta

About us Mission Statement